4 ms·
C++ has very little "magic" once you get an okay mental-model for how the compiler looks at things. And in fact you can write okay but sub-optimal/"unsafe" C++
by ryanianian 8y ago
C++ has very little "magic" once you get an okay mental-model for how the compiler looks at things. And in fact you can write okay but sub-optimal/"unsafe" C++ that looks kinda like C without that much headache and without using things like unique_ptr (or even really refs to a certain extent).
However C++ does let you get as low-level as you want and micro-optimize things and write extremely precise types that other languages can really only dream about.
This said: the language is quite complicated which leads to it being "hard" to compile (and hard to learn if you care about some of the more interesting aspects).
> C++ developers are masochists
In my experience you have to have a very different mindset when writing production-quality C++. It's a lot "slower" to write (at least for me), but in the end you can end up writing some extremely expressive and efficient code that scripting languages can't even express very well (let alone run quickly).
(The C++ tooling around build systems and compilers and linkers / arcane black-magic is a real tragedy. I'm holding out for a sane C++ build-and-module system but the language-designers don't seem interested in standardizing these things.)
> Show me simplicity and elegance. Show me boring but powerful.
Many languages value these as design-goals and you may want to use those languages instead. C++ makes a different set of tradeoffs. It has its own sense of elegance.
- fhood 8y agoThis is a very romantic view of C++, but not (in my opinion) an accurate one. C++ feels like a language developed without a road map. I agree with the original comment. Many C++ updates are full of band aids to address issues so blatant that they had to fixed by others a long time ago (see boost). > C++ has very little "magic" once you get an okay mental-model for how the compiler looks at things. This is a meaningless statement. I could make the worlds most obtuse and complicated language and you could still say this. Just because after years, and I do mean years, of experience C++ stops regularly blindsiding you does not mean it is a well designed language. There are parts of C++ that are good, beautiful even, but that does not give it a free pass from being among the messiest languages in widespread use.
- ryanianian 8y agoI don't give C++ a free-pass for its warts, I just think it's important to realize where those warts actually live so that I can direct frustration appropriately :) > C++ feels like a language developed without a road map. Many of the warts are there due to the committee's very strong stance on requiring backward-compatibility. This does detract from the language sure, but the tradeoff is code that will continue to compile for many years which is important for huge codebases that want to continue to adopt the latest features. Other languages tend to solve this with breaking-changes (python3, perl6, even java8 or ES* to some extent which arguably changed the whole paradigms of their languages). Ultimately the roadmap is dictated by time-tested experience with existing features and what the community deems the most necessary and practical (see boost which is in many ways an incubator for language ideas). Recent releases are explicitly around new roadmap items like better RAII-pointers and (finally) a standard threading API. There are also new language-features that make the language easier (lambdas, more auto, etc) and faster (rvals/move operations). These are "optional" and can be ignored if you prefer. > Just because ... C++ stops regularly blindsiding you does not mean it is a well designed language. I'm still blind-sided when the compiler does crazy things I hadn't expected, but almost always I end up cursing the tooling not the language. IMHO this is the fault of (1) the documentation being terse and separated from stdlib headers etc, (2) compilers/linkers being rather nasty and slow to work with, and (3) terrible error messages in general. These are problems with the ecosystem and not so much with the language-proper. It's fair to say they sour the whole experience (and they really really do sour it), but the language itself is actually not that surprising once you get past the tooling.