Ask HN: Do you still enjoy coding in C++?
In recent years C++ has received a lot of backlash due to its complexity and perceived feature creep. However, since C++11 I've 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 it can be very tricky to write a correct iterator, get rvalue reference handling right, or read error messages involving templates. So, do you enjoy or dislike writing C++ source code, and why?
I still enjoy C++ because it gives me precise control over memory and performance, and modern features like smart pointers and constexpr make it safer and more expressive than ever.
I've moved away from C++ for most projects; the complexity and long compile times are not worth it when Rust or Go offer better safety and tooling for my needs.
C++ is enjoyable if you stick to a disciplined subset—avoiding heavy template metaprogramming and using static analysis tools—but the full language is a minefield.
The error messages from templates are still a nightmare, but the power of the type system and zero-cost abstractions keeps me coming back for high-performance work.
- simonask
Oh, C++.
C++ feels like an old lover who I think fondly of. We were together many years, until about C++20, through thick and thin. It was exhilarating - blazingly fast, perhaps irresponsibly so, but heck, the ride was wild. It taught me so many things, and shaped me into the programmer I am today. But we went our separate ways when its shortcomings became too large to bear, and its behavior - too often undefined - no longer excusable.
I keep up with it because I still have love for it, but I have to admit I am deeply concerned about many of the life choices it is making. I should have seen how problematic it was, because I knew its history, but I had hope that it could change, and it just looks like it never will.
I'm still rooting for C++, even though I am very happy with my new primary language, Rust. I hope it changes to the better, because I really want the best for it, but right now I'm just not seeing it. It keeps repeating old mistakes (e.g., more UB footguns with every new feature), without addressing any of the big flaws (insufficient tools for building robust software).
I sometimes still write C++, but I'm not excited about it the way I used to be. When I do write C++, it's because I have to. When given the choice, Rust is simply just a better choice for almost everything I do. Right now, I don't see a future for C++ and me.
- chris_j
I'm really torn about C++. I love C++ but there are things that I really don't like about it as well. It's a fantastic language in a lot of ways, but it carries around 40+ years of cruft, of things that you wouldn't do like that if you were inventing a programming language today.
I haven't written C++ professionally for many years at this point, and my memories of using it professionally (pre C++ 11) are not happy ones: having to agree on a strict subset of the language that we were allowed to use, which avoided features that any of the compilers didn't support well, or that my teammates didn't like. Sadly back then the list of forbidden features included templates and namespaces.
But using C++ on personal projects nowadays, and being able to choose which bits of the language to use - and which to avoid - is much more enjoyable. And honestly, the language did get a lot better from C++ 11 onwards.
- adev_
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.
- mort96
I enjoy writing C++ code.
I acknowledge that C++ is a bad language in a lot of ways, but it's a bad language which I know really well, and it fits with how I think about code. And it lets me effortlessly do "clever" things with how memory is managed to avoid unnecessary allocations etc. I've already learned most of its idiosyncrasies, handling rvalue references/move semantics, how to go about implementing contracts like iterators and containers, etc.
I also like writing Rust, and I like how Rust makes sure I don't make mistakes. I think Rust is a better language in many ways and I think it's the future of low-level programming (and I think it's wild that it took so many decades to get a proper competitor to C++!). But I also like how C++ doesn't care and lets me do whatever I want without acting as a nanny. I would never ever dare to write a publicly exposed web server in C++, but a game? Sure!