21 ms·
This decade old article describes an ancient and obsolete language (C++03 probably though some of the text suggests it might be C++98). It's not worth reading
by gumby 7y ago
This decade old article describes an ancient and obsolete language (C++03 probably though some of the text suggests it might be C++98). It's not worth reading in 2020.
Modern C++ is a very different language though it can still almost completely interoperate with quite old code. C++11 and C++14 already addressed most of the things brought up, and contemporary C++ (obviously most code is not in it yet) even supports generic template functions with a straightforward syntax (i.e. use auto instead of <..>).
- JonathonW 7y agoThe author also seems to really, really want C++ to be Python, despite that they're completely different languages for completely different purposes that make completely different sets of design tradeoffs. In that respect, the author probably wouldn't be happy with modern C++, either. For example, C++ is never going to be a garbage-collected language (by default, at least). Modern C++ gives you better tools to deal with that, but the core design concerns that make C++ the way it is haven't gone away.
- Someone 7y agoI’m not aware any exist, but implementations of C++11 can have garbage collection by default. https://isocpp.org/wiki/faq/cpp11-library#gc-abi https://isocpp.org/wiki/faq/cpp11-library#gc-abi: ”Garbage collection (automatic recycling of unreferenced regions of memory) is optional in C++; that is, a garbage collector is not a compulsory part of an implementation. However, C++11 provides a definition of what a GC can do if one is used and an ABI (Application Binary Interface) to help control its actions.”
- deaddodo 7y agoThat's not "by default". The compiler doesn't provide it, the language provides for you as the developer using the language to implement your own (or use a third-party) GC and utilize it. D and Rust both offer the same amenities and are not "garbage collected" languages.
- kllrnohj 7y ago> D and Rust both offer the same amenities and are not "garbage collected" languages. Rust isn't but D is absolutely a garbage collected language. The GC is provided by default and expected to exist. https://dlang.org/overview.html#resource https://dlang.org/overview.html#resource & https://dlang.org/spec/garbage.html https://dlang.org/spec/garbage.html There's a non-GC'd subset of D, though. That would be the BetterC subset https://dlang.org/spec/betterc.html https://dlang.org/spec/betterc.html
- bachmeier 7y agoI think it's more accurate to say D's GC is expected to exist if you want to use the full language. That's sensible, because the option to use GC makes some things practical that otherwise wouldn't be. You can disable or simply avoid the GC, and you can add @nogc attributes to your code if you want to be certain there won't be any GC allocations. BetterC certainly does guarantee there's no GC, but that's a limited (for now at least) subset of the full language.
- dfox 7y agoThe quote seems to be about the compiler/environment being permitted to offer GC, ie. permits you to write C++ implementation on top of some GC'd runtime. It does not say anything about you as a language user having enough introspection capabilities to write an GC. As a side note it seems that one can (ab)use smart pointers enough to build essentially working tracing GC on top of that, I've seen that done and well, the performance is horrible, obviously.
- pjmlp 7y agoActually C++11 introduced a GC API.
- gpderetta 7y agoIt seems to me that just a couple of do nothing placeholders were added to please Hans Boehm and get him to work on the c++ memory model :).
- pjmlp 7y agoEven so, there are the .NET, Unreal and COM/UWP programming models as well, which while not taking advantage of C++11 GC, do bring a GC into C++ world. :)
- downerending 7y agoYou wish. Unless I'm terribly misinformed, "modern C++" contains all of the features of the prior versions, which means that in the real world you have to learn and deal with all of it.
- jfkebwjsbx 7y agoThat is the point of backwards compatibility. It is a feature, not a bug. Whether that feature is a good idea or not and to what degree, is the question.
- Quekid5 7y ago... but it's worth considering that this is a 'question' from 2010. Just saying...
- downerending 7y agoI'm not saying it's a bug. I'm saying that backwards compatibility means that you still have to deal with all of the historic flaws of the language today. The article is indeed still relevant.
- UncleMeat 7y agoBut that’s true for literally everything. If you have a cpp code base and are building new stuff in rust to interop then you still have legacy cpp code even though rust has fewer problems.
- KptMarchewa 7y agoNot really. Legacy stuff can be contained. For example, you could specify language version level in file and it would disable removed/deprecated stuff.
- UncleMeat 7y agoLinters can prevent you from using outdated C++ constructs with ease.
- carterehsmith 7y agoSure, "if" all of that old code (how many billions of lines of code?) was rewritten and redeployed since. If not, then... the above statement does not stand.
- Rusky 7y agoTo the contrary, modern C++ has solved very few, if any, of the problems described in the article. Being generous: * There's now `std::string_view` to address some of the problems with `std::string`, but the rest are still there. There are some attempts to specify the encoding now, at least. * Lambdas and `std::function` pretty much solve the function pointer complaints, with some added complexity. * Containers still do silly things when you use `c[..]` syntax with no element there. (Both when trying to insert and when trying to retrieve!) * The general level of language size and complexity, especially around templates, has only gotten worse. Concepts will finally help in some ways here.
- UncleMeat 7y agoI think most people agree that operator[] is a big footgun for containers, but rigorous use of const helps at least prevent surprises.
- gumby 7y agoAnd operator new is hardly used any more in modern C++ code.
- cmroanirgo 7y agoIf everyone can forgive my ignorance... I used to call everything in the std:: namespace as just that, the standard template library (STL) (whatever it's iteration). So is this C++03 /C++11 stuff just updates to this library, or is std::string recognised at the compiler level? (Genuinely confused). (In old man voice) We ended up rolling out own stuff and marking std:: verboten. Why? Stl was too slow, too verbose, and too hard to grok the stack when debugging. We ended up with less memory fragmentation, less dangling ptrs, etc etc. In the rare case there was something in STL that was actually cool (or faster, which was very rare), we'd gut it and reef out the part that was cool to use in our implementation. I presume these comments aren't popular (sorry about that, but this is during 90s and early 00s when dev cycles were clearly different). Eg. We had string classes in all different flavours, some would interop, some wouldn't. Eg. We had tree and hash classes that, while templateable, had a few core implementations that made compilation fast. We had various ptr management systems (ref counted, stack based, etc). We made STL between verboten in all APIs because we been burnt so many times using (/trying to use) other ppls APIs that exposed STL in its library. (We were exclusively a windows shop, if that helps understand my confusion... PS. I'm retired these days and have been out of the c++ game >10yrs)
- kevin_thibedeau 7y agoSome of us still have to use outdated C++ compilers where the ::std namespace doesn't exist and all the modern goodies are but a dream.
- nmeofthestate 7y agoTrue - some of the specific problems have been handled, but C++ is still kind of a disaster. The language has got even more complex in many ways. Some coders like that and get really into understanding the byzantine complexities, so the codebase inevitably gets dragged into unmaintainable, hard-to-debug cleverness. From my experience, C++ development is getting better, largely because tools are getting better at hand-holding and pointing out all the foot-shooting mistakes you can and do easily make on pretty much every line. Maybe C++30 will have fixed everything...
- kazinator 7y agoC++11 was just around the corner then, in draft form. The article shows awareness of it.