Lurker News
In the recent years C++ received a lot of backlash due to its complexity and (perceived) feature creep. However, since C++11 I really enjoyed writing C++ with its strict type system (including const), range-based for loops, smart pointers, and how much you can do with templates. On the other hand, I know that it can be very tricky to write, for instance, a correct iterator, to get handling of rvalue references right, or to read error messages that involve templates.

So, do you enjoy or dislike writing C++ source code and why?

Comments (93) 66 threads

Show all comments

Showing thread 3 of 66

adev_4 replies#
In one word: Power.

C++ is by far the most powerful language around. And this is for the best and (often) also the worst.
In term of generic programming, control on hardware, capacity of abstraction and more generally expressivity: Nothing, even today, come even close to C++.
It is a language full of foot guns and it has its fair share of legacy problems.
But if you learn to avoid it (throught experience and pain). You can reach a productivity and a level of performance in C++ which is very difficult to beat with anything else, including Rust.
Ironically, I find it particularly true in the age of A.I.
Because the amount of C++ around is so tremendous, that agents are currently pretty good at it if guided properly.

gmueckl#
When it comes to generics/templates and expressivity, there are some arguably better languages around. But the range of having access to absolute low level control at the same time as highly abstract generic programming is virtually unmatched.

But the footguns are also impressive and formidable. And one of the unique powers of the language is that it allows the user to build constructs that improve the power of those footguns by several orders of magnitude. And teams can happily build footgun force multipliers without individually recognizing what they are working on.
I still write lots of C++, and the overall reason has more to do with the ecosystem (which is unmatched for what I do) than the language itself. I like it, but learning other languages made me yearn for features that C++ won't likely get before I retire a few decades from now (curse you, Walter Bright, for your awesome ideas! ;) ). In some ways, I feel about C++ like a child who saw ads of awesome toys, but they aren't available for purchase.

a1o1 reply#
I find Claude just terrible at writing C++ in comparison to how well it codes everything else I throw at it. It does bad choices, like it writes up new functions to do stuff that is already in the codebase, additionally seemingly can’t leverage the standard library, leans too much on the exact architecture of my computer vs what the codebase is meant to run, don’t seem to figure proper naming standards, keeps ignoring outputs from benchmarks or tooling and instead claim decisions on performance from thin air.

With all other languages I guess because things are more standard it can probably more easily guess than having to follow specific project guidelines, but my experience with C++ with it is not good at all.
It is amazing at python, Rust and pretty all web stuff I tried. But with C++ it requires a ton of guiding and I need to correct all generated lines all the time it seems.

adev_#
> I find Claude just terrible at writing C++

I dont use Claude. I use DeepSeek and it is very capable. I have found Gemini and Mistral4 equally capable.
One thing I realised however is that Agents adapts to the existing code style:
- Give them a modern, polish C++ codebase and they will produce clean modern C++ - Give them a legacy codebase and they will produce a festival of raw pointer spaghetti and loose themselves. It seems that evem for A.I there is 10^6 variations of C++.
- Force them to use span and string_view and 90% of boundaries problem and lifetime go away. It seems to ease their reasoning.
- A single line in the AGENTS.md is enough for them to properly use fully sanitizers in their test. - They are pretty good at leveraging defensive programming if asked to.
Few negative points: - They are still pretty bad at reasoning about memory hierarchy and memory allocation. But thats hardly surprising, very few codebase do it properly. - You need to explicitly list your dependencies and build system or it's a festival of reimplementation. I have beem pretty successful with Nix so far.

cookiengineer1 reply#
> (...) that agents are currently pretty good at it if guided properly.

I think I partially agree with that.
If you create your type system and templates first, agents can be pretty helpful filling in the blanks or "wiring"/integrating an external API into your own type system.
The issue is that I always have to force agents to read that type system before I can prompt them with a task like this, and always have to prompt them to not touch/extend/modify that type system and to use existing codestyles etc.
So I guess I haven't figured out a good type system discovery in my workflows yet. Would be interesting to see how you work with agents here.
Got an open sourced repo by chance where the structure worked out well?

adev_#
> Got an open sourced repo by chance where the structure worked out well?

I have an AGENTS.md that I bring around in every repo.
Few things I found:
- On new project is that it is much more efficient to point the agent on an old, existing project and simply say "Copy the code style" than to try to document everything in a markdown file.
- Explicit listing of both headers and implementation in CMake target seems to help for dependency resolution.
- A simple "Analyze this codebase" on a folder helps a lot for context prefilling on complex type system. I have a compiler where the entire language grammar is defined as C++ types with mutual relations. DeepSeek is completely capable to understand it and debug grammar mistakes in a blink of an eye.

1122331 reply#
Perfomance? Mostly agree, you need dynamic code generation to get much better than C++.

Productivity? Bwahahaha. This is language where 50% of code cannot even be debugged (like, for real. Nothing that executes at compile time is debuggable). Most crazy features are usually passed over with "normal users should simply use well written library and so this complexity does not concern them", then the normal user gets error, sees "decltype(auto)" or some sfinae monster, and is taken by ambulance (since last year, to chatgpt).
C++ is terrible for productivity.

adev_1 reply#
> like, for real. Nothing that executes at compile time is debuggable

Debugging constexpr is trivial with static_assert. In addition, most UBs are entirely eliminated at compile time which is excellent for testing.
> then the normal user gets error, sees "decltype(auto)" or some sfinae monster
Thats a non-issue in the age of Agents. They can reason about that very well. This kind of problem disappeared entirely.
Additionally, I would say that if you are still using SFINAE post C++20, the problem is you and not C++.

112233#
ah yes. binary search for new value of implicit constant using "change static_assert and recompile" loop, such trivial.

Also, if you find debugging requires clauses, sfinae clauses or expressions using static_assert trivial, please share your techniques!