News for hackers. Stuff that matters.
Re:Programming languages endorsed for server-side use at Meta by powersurge360 on Wednesday July 27, 2022 @01:31PM (#32253522)
I'm very surprised that C++ is one of the recommended languages for backend services. I occasionally am interested in learning C++ but with my context as a web developer I find it doesn't really fit any of my use cases.

How would one go about building a rest service in C++? Do you have to write everything yourself or are there libraries and frameworks. I did some light looking into it after reading the article but I would love to hear from folks who actually do it and what the state of the art is for C++ web services.

Re:Programming languages endorsed for server-side use at Meta by pjmlp on Wednesday July 27, 2022 @01:36PM (#32253634)
There are libraries and frameworks.

Note that before Java adoption push we had stuff like ATLServer, and the first version of ASP were basically COM libraries being called from VBscript/JScript.

On our case, we were calling C code from TCL scripts, using plugins like mod_tcl.

Nowadays you have stuff like Boost ASIO and Wt.

However I wouldn't plug C or C++ directly into the Internet, rather call them from managed languages, as native libraries, reducing the risk of possible exploits.

Re:Programming languages endorsed for server-side use at Meta by powersurge360 on Wednesday July 27, 2022 @02:24PM (#32254444)
This is what I had considered to be the state of things. The phrasing on initial read suggested to me that C++ & Rust were the default now for performance critical services (with Rust being a new add) and Hack was used where it made sense but not necessarily by default anymore. I think I may have discounted Hack's role too much.
Re:Programming languages endorsed for server-side use at Meta by xrikcus on Wednesday July 27, 2022 @02:20PM (#32254391)
Clearly one can write web services in C++. Meta does not really, though. It is Hack code that talks to most web clients (and python for Instagram). The C++ code sits behind that. All of the databases, the caches, the indexing services, the ads ranking and selection are written in C++ and talk Thrift to each other and to the Hack code.
Re:Programming languages endorsed for server-side use at Meta by jcelerier on Wednesday July 27, 2022 @04:31PM (#32256474)
> How would one go about building a rest service in C++?

I'd use https://github.com/drogonframework/drogon if the app needs to be pure C++ or Cutelyst (https://cutelyst.org/) if it's a Qt app which needs to expose an http server

Re:Programming languages endorsed for server-side use at Meta by TillE on Wednesday July 27, 2022 @01:45PM (#32253773)
I haven't built anything serious with it, but cpp-httplib is a very easy-to-use framework for processing HTTP requests.
Re:Programming languages endorsed for server-side use at Meta by tuetuopay on Wednesday July 27, 2022 @01:34PM (#32253581)
"backend" does not necessarily means the part that receives the HTTP request from the client. It could be a microservice that speaks some other protocol, a load-balancer that sits in front of the web workers, and task runner, etc.
Re:Programming languages endorsed for server-side use at Meta by coxley on Wednesday July 27, 2022 @06:21PM (#32257800)
> How would one go about building a rest [service.]

At Meta, you wouldn't. Everything is Thrift. For WWW, you'll have more graphql.

Meta also has a shit ton of libs to make service development easier than exists publicly.

Re:Programming languages endorsed for server-side use at Meta by didip on Wednesday July 27, 2022 @04:09PM (#32256155)
If you have organizational backing, it is not hard to use C++ because the company would have already standardized on libraries like Boost and Folley.

And the company would already have a build farm.

Re:Programming languages endorsed for server-side use at Meta by pletnes on Wednesday July 27, 2022 @03:22PM (#32255427)
I’d bet they use e.g. Python to receive the HTTP calls and do basic logic at that level, but use C++ libs to chew through lots of multimedia, ML/AI, etc.
Re:Programming languages endorsed for server-side use at Meta by astlouis44 on Wednesday July 27, 2022 @04:16PM (#32256283)
Check out WebAssembly.