HACKER Q&A
📣 DistrictFun7572

Modern C++ Workflow?


Hello HN.

I'm about to take on a C++ project and have never programmed in C++ before (usually use Java/TypesScript/Python). Could someone with more experience please a give brief overview of a modern and "best practices" approach for developing products based on C++? Things I'd find interesting to know:

1. What does modern C++ look like? Any good books on the topic?

2. Are Makefiles still being used? Or is it more common to use something like Bazel?

3. Package managers?

4. Linters? Formatters?

5. IDEs people use? VSCode?

6. DevOps workflow? Any best practices for integrating everything into a CI/CD pipeline?

7. Testing frameworks / approaches?

Thank you!


  👤 ivars Accepted Answer ✓
1. Modern C++ is obviously a huge topic but if I had to describe it in one sentence I'd go for "use smart pointers and containers instead of raw pointers and raw arrays" or "c++ is more than c with classes". If you are completely new to C++ I would recommend "Professional C++" 4th or 5th edition by Marc Gregoire. After that read everything by Scott Meyers and Bjarne Stroustrup you can get (released after 2011).

2. You could use Bazel. Also look into CMake, it's an industry standard, so to speak, and will let you generate build files for almost any kind of build system including Makefiles.

3. I don't use any but some people have success with vcpkg.

4. Clangd is a good choice.

5. A quick one that works is VSCode + clangd and CMake extensions. Clangd will let you format, lint and do some basic static code analysis. Installing clangd extension will install clangd automatically. Or, if you are on Windows, "Visual Studio: Community edition" is even easier to start with right away.


👤 manuel2258
I developed the entire C++ devops integration and workflow at my current job. While not having that much of background in it we ended up with an quite good setup.

2. CMake is the standard, works well and is very powerful, but also a bit of hasel and learning to set it up the first time. Personally I also liked meson, however its not as generic.

3. Conan is pretty cool, but still buggy at some cornors.

4. Clang and its tools a pretty nice.

5. We use VSCode, with the default C++ plugin from microsoft. The key for a good integration is the compile_commands.json file, so make sure to link it in the plugin and let it be generated by your build system.

6. Cache as much as possible, especially depedencies.

7. We use googletest, however personally i enjoyed catch2


👤 AnimalMuppet
I'd start with Stroustrup's "A Tour of C++". It is by far not an in-depth book[1], but it's great for getting oriented to modern C++.

[1] By "not in-depth", I mean that it doesn't try to have all the detail. It still has a fair amount of specific detail, but it's selective.


👤 gquiniou
If your project does not rely on on specific C++ libraries, I would recommend going with Rust.

The C++ build systems and package managers are a pain to use compared with cargo.

Also learning Rust is easier than learning C++.