5 ms·
Oi vey. This sort of QA is exactly what's wrong with the "modern" C++. It's just ugly. I've been using C++ as my main language since it was barely out of C wi
by eps 5y ago
Oi vey. This sort of QA is exactly what's wrong with the "modern" C++.
It's just ugly.
I've been using C++ as my main language since it was barely out of C with Classes stage and it pains me to see how it evolved from a language that extended C in clever and welcomed ways into this piece of committee-designed monstrosity with not a trace of its former elegance left in it.
- snickerbockers 5y agoIt's absolutely disgusting how many of C++'s recent additions exist to work around problems introduced by C++'s other recent additions.
- bigcheesegs 5y agoDo you have any examples? std::launder fixes an issue that has existed since C++98.
- tialaramex 5y agoIn C++ 03 they realise their pointer (inherited from C) is awful. Do they fix it? No, they add a new type named std::auto_ptr which is "smart". Thanks to operator overloading it can behave like the existing pointer. Kind of. std::auto_ptr is pretty bad, and so in C++ 11 they deprecate auto_ptr and introduced std::shared_ptr and std::unique_ptr so now finally their language has halfway usable pointers, with these unwieldy names and some odd semantics you just have to get used to. C-style pointers remain all of: Simpler to use by virtue of their terse syntax, still necessary, and unsafe. std::auto_ptr still exists forever, but is officially deprecated. At first C lacks strings, promoting string literals to a strange array with an extra zero value in it. Eventually C++ gets std::string and std::wstring but, nothing of value about these strings is defined, so they're both pretty useless and of course dangerous. In C++ 17 it gets std::string_view which finally expresses one of the things you probably first wanted, but it provides no enforcement of the most obvious expectation you have - C++ allows a string_view to outlive the underlying string, causing Undefined Behaviour. In C++ 20 you get to use ranged behaviour, and, that extra zero value bites you hard because of course you didn't mean the zero value but in C++ that's "part" of your string. They also, finally, decide that UTF-8 might be a good idea and define yet another type of string to mean UTF-8 encoded, about five years after everybody who matters was of course encoding strings as UTF-8.
- gpderetta 5y agoShared_ptr and unique_ptr are not replacement for raw C pointers. And the reason they are not blessed with language syntax is because user can and often do implement their own, so those two library types are not particularly special.
- BenFrantzDale 5y agoAgreed. And a huge strength of C++ is that you can write low-level classes like these and have them be fully performant and have reasonable native-feeling syntax. Almost no other languages provide that.
- IiydAbITMvJkqKf 5y agoSpecifically, both shared_ptr and unique_ptr are owning pointers. Using plain old pointers for non-owning variables is idiomatic.
- tialaramex 5y agoNon-owning pointers are a genuinely useful tool, but as a tool they're more welding torch than hammer, if that's what you needed it's really what you needed - but most often it probably isn't what you needed at all and will cause more harm than good. So it's strange to provide them with stuff like terse built-in syntax, while not providing anything similar for the thing people will want all the time, ownership. Result: The Right Thing™ is harder to do and wastes visual space compared to the Wrong Thing. A "correct" program ends up full of boilerplate just to get what you'd obviously want.
- nemetroid 5y ago> std::auto_ptr still exists forever, but is officially deprecated. std::auto_ptr is fully removed since C++17. I agree with most of your comment, but I think it reinforces the grandparent's point. The warts of std::string and null terminated strings are not "problems introduced by C++'s other recent additions".
- saagarjha 5y ago
- thriftwy 5y agoSee also: https://yosefk.com/c++fqa/ https://yosefk.com/c++fqa/ as a long set of rants about this.
- teitoklien 5y agoWhoever reads this , note that its a very outdated rant (although some parts are still true). > Well, the standard library doesn't have matrices or regular expressions, either C++ does provide a standard regex library now, matrices can be made either with vectors or you can use boost libs for it. > The standard library doesn't support listing directories Same for filesystems, it now comes with the standard set of libraries For C++, it’s time and time again seen, that Boost libs are used as the experimentation stage to filter things and add to the C++ standard library, and boost is pretty feature rich with all sorts of utilities you might need to build a robust program. > In C++, things are different - there are no modules. C++20 is adding features related to modules support like in other programming languages (haskell, etc). Sure C++ is an old programming language with too many weird features, which end up hurting devs , but as long as you stick to the fine features. C++ is pretty fun to use. It has type inference now, those ugly looking long type-declarations, can easily be fixed by appropriate use of the “using” keyword in local scope (if you’re that worried about polluting the global namespace i.e) I think C++ gets unnecessary hate , every language has its quirks, you just avoid the bad stuff and stick with the good bits.
- spoiler 5y agoI don't think anyone hates C++, they hate how it makes them feel when they have to work in it. Also, I think it's a bit ludicrous to say "just use a subset" because there's no definitive guide to "sane" or safe subset. Also, regarding boost: I'm extremely conflicted about it... On one hand, it's made my life easier, but on the other it feels like once you add it to the codebase it metastases everywhere; it's not a C++ codebase anymote, but a boost codebase. Also, it ill-composes with most things that aren't boost (and sometimes even within other parts of boost, because boost is an amalgamation of libraries)
- xigoi 5y agoIt's 2002 and `import <iostream>;` still doesn't compile.
- Razengan 5y agoAt this point the C probably stands for Cthulhu because the language borders on becoming a summoning ritual for eldritch horrors.