So, do you enjoy or dislike writing C++ source code and why?
So, do you enjoy or dislike writing C++ source code and why?
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.
One I enjoy programming. Another I dread.
I'm beginning to believe that some of the Rust evangelists are there just because they'd rather write code in anything but <some dialects of> C++...
"C++, but codebase is 20 years old"
"C++, but we ban or dont like most of C++ features"
"C++, but everything must be a template"
"C++, but codebase is completely new and we only use the new features"
"C++, but its the stl codebase"
"C++, but you are reading Stroustrup's book"
However, I stopped writing C++ once I switched to Rust. I assume I would still enjoy writing C++, as long as I can avoid a lot of the templating features. (I might have a different opinion if I worked on different kinds of C++ projects, eg more people, more library oriented, etc.)
Languages like C++, Scala, Haskell, is where I get the most fun coding, unfortunately the question can be reformulated as "Do you still enjoy coding?", as we get pushed to program into natural languages instead.
The templating system is more powerful than any other language I have significant experience with, but that also lets people write incomprehensible systems. And the compile times always have been really long.
I think the lurking question is about Rust. I've read a book about it and it has some attractions but also what I think are some poor decisions. I suppose I'll have to use it for something sometime. C++ is sort of like Perl, it seems to me. A lot of what seems like bloat is actually affordances, so the thing you want is often surprisingly close at hand. Some things of course are awful.
I wouldn't call C++ a good language but it does most of the things. Enjoyment doesn't always mean productivity anyway. I enjoy using Forth but that's almost like enjoying riding a unicycle. I wouldn't do anything substantial with Forth except for recreation. I do feel fairly productive in C++.
You've reached the end!
mort96•42m ago
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!