4 ms·
> Writing new C++ code with all the modern approaches and tooling doesn't sound so bad. Uh, but it still kinda sucks, if only because the nice way that looks i
by spoiler 4y ago
> Writing new C++ code with all the modern approaches and tooling doesn't sound so bad.
Uh, but it still kinda sucks, if only because the nice way that looks idiomatic is usually the incorrect way for either performance (anything newly added like std::variant or std::optional) or safety (operator[]).
The correct way is usual the ugly way, because it seems like the committee puts C++ arcanum knowledge above all else, instead of developer satisfaction or maintainability
- s9w 4y ago[dead]
- bluGill 4y agoC++ puts you don't pay for [at runtime!] what you don't use above all use. However that often means you have to know the arcanum bits to decide if need to pay for something. You can save a bit of CPU time if you don't check if a pointer is null - which is a great thing to do if you have knowledge that the pointer cannot be null - and also something that is very easy to screw up so most languages don't give you the option. (which is the right thing for them to do - a lot of people are writing C++ where they could write something else)
- gary_0 4y agoThe "correct" way is also template-heavy so enjoy long compile times followed by utterly incomprehensible error messages.
- peteradio 4y agoYou mean coffee breaks and job security are baked into the language?
- intelVISA 4y agoShhhhh. You're supposed to trick people into learning the "other" langs.
- raverbashing 4y agoIf you call PTSD job security, sure
- peteradio 4y agoYou know what they say: ya can't get PTSD twice!
- Shorel 4y agoI prefer C++ compile times than Node.js webpack copying plain text around 'transpile' times. At least the C++ compiler is doing actual work. And it is faster than the webpack madness.
- logicchains 4y ago> the incorrect way for either performance (anything newly added like std::variant or std::optional) or safety I don't know where you got that idea from, but with an up-to-date compiler variants are safer and more performant than the traditional approach (classes hierarchies), and std::optional is safer and 99.9% as performant as a nullable pointer.
- ben-schaaf 4y ago> and std::optional is safer and 99.9% as performant as a nullable pointer. Except for it taking up twice the memory as a pointer (https://godbolt.org/z/5We9zEbvh https://godbolt.org/z/5We9zEbvh) and it not doing anything in regards to safety when using pointers. Even if you're replacing a nullable-pointer with a std::optional you're still handling landmines when using operator* or operator-> - the most convenient ways to use std::optional.
- pornel 4y agoThe fact that modern C++ still added more easy to hit UB in std::optional blows my mind. "But making it safe would be slow!" and "-> being safe would be inconsistent with the rest of the language". C++ is doomed forever to have safety-third design.