12 ms·
Every time I read about obscure C++ features, the more I'm convinced that the language needs to be torn down and rebuilt from scratch.
by wyager 13y ago
Every time I read about obscure C++ features, the more I'm convinced that the language needs to be torn down and rebuilt from scratch.
- k00pa 13y agoSo every language should be dump down version of Python or something?
- TazeTSchnitzel 13y agoHave a look at D: It's what C++ should be.
- nikbackm 13y agoAlready been done a few times. (See D and Rust) But the result will no longer be C++ for better and worse.
- evincarofautumn 13y agoYup. That seems to be the prevailing opinion. C++ is still relevant, but not all of the applications that want its performance can justify its complexity. So various language designers are working on alternatives. The frontrunner is undoubtedly Rust; D and Nimrod are also relevant. And I have a cat in the fight too. ;)
- btmorex 13y agoWhenever I read something like this, I'm reminded of that Winston Churchill quote "It has been said that democracy is the worst form of government except all the others that have been tried". I think C++ usage is one of those things that you don't truly understand until you've decided to start a new project in C++ even in 2013. For a reasonably common feature set in real project (i.e. not a side project for fun), C++ is the only option. Specifically most alternatives exhibit one or more of the following: * automatically managed memory (enough said) * not expressive enough (I would throw C in this category even though C is a fine choice and often times the best choice for many projects) * not nearly mature enough in terms of compiler/toolset/language in general (often, it's unclear whether the language will ever achieve that necessary maturity) * not fast enough, usually for one of the above reasons, but sometimes for other reasons
- reikonomusha 13y agoAutomatically managed memory is almost always a good thing. Aside from preventing a huge class of bugs, it also is often more performant. Why disparage it? And I'd hardly label C++ as the epitome of expressiveness. A broad, haphazard feature set doesn't necessarily imply it's expressive.
- 10098 13y agoI think he's talking about garbage collection, which is often perceived as slow. But you can certainly have automatic memory management in C++ as well. Stack-allocated objects manage themselves, for dynamically allocated objects one can use scoped/shared pointers. One added perk is that you can extend this approach to deterministically manage not only memory, but any other resource that can be acquired and released (e.g. locks). I actually like this approach very much. The only problem I see there is that since you're still using raw pointers, the runtime can't really move things around for efficiency since that would invalidate the pointers. But in a garbage-collected language that doesn't expose pointers, the heap can be defragmented during runtime, which is nice.
- pcwalton 13y ago
- verroq 13y agoIf you felt that most of these were obscure then you don't know enough C++ to make a comment on it.
- pjmlp 13y agoA few of those items are actually caused by its C compatibility and would apply to Objective-C as well. Like the issues numbered 1, 3, 4, 6.
- jheriko 13y agoits a very messy language - its annoying to see that its the best extension to C. i constantly want something better than C - something where the compiler has freedom to optimise my memory layout with a keyword for types that have to cross boundaries. something with metaprogramming built in. something where const is not just a promise, but the law etc...
- jokoon 13y agothen make it, and watch it fail Also "C is quirky, flawed, and an enormous success" Denis Ritchie.
- pjmlp 13y agoAnd the cause we have security exploits caused by bad pointers and arrays out of bounds.
- jokoon 13y agoI don't know what to think of this comment. Does this mean we should not use C or C++ ? Security does not necessarily always matter when you're programming something, it does when you make widely used libraries or application or drivers or an OS, which are done by experts and tightly reviewed, so the language is not an issue. Sometime you'll need pure performance or very low power consumption, and there will be no concerns of security between there will absolutely no way to compromise it (no "vector"). Security is not a particular feature of any particular programming language anyways, every program, whatever the language, is subject to security concern, it's not a language concern.
- pjmlp 13y ago> I don't know what to think of this comment. Does this mean we should not use C or C++ ? Yes. Although the insecure design of C and C++ (thanks to its C underpinnings) are just an attack vector from many possible ones, it is quite easy to get exploited thanks to the skills of many people writing applications on those languages. Removing away the possibility of out of bounds errors and pointer misuse, not possible in other safer systems programming languages, already removes away many of those attacks. So nowadays we have to deal with compiling with -Wall -Wpedatic -Werror, coupled with valgrind like tools and static analyzers to achieve some level of confidence that undefined behaviors and pointer misuses are not creeping in the code. You are right, this is only a small step in the whole security picture, there is also SQL injection, social engineering and many other forms of attacks. Still buffer overflow exploits remain one of the first forms of attack. I do code in C++ since the ARM days, so I do know it quite well. Not making this argument as an anti-C++ zealot.
- camus2 13y agoOr maybe devs should stick to a subset instead of using every feature to make the code unreadable.
- sacado2 13y agoTrue. While most languages are just plain "basic" tools, C++ is a swiss-army knife. A swiss-army knife is both dangerous and ineffective if you try to use all of its features at the same time.
- mcguire 13y agoThe downside is that you and I will inevitably pick different subsets, leaving someone trying to combine our two projects with dangerously sharp edges in inconvenient places.
- jokoon 13y agoHere you go: "There are only two kinds of languages: the ones people complain about and the ones nobody uses" Bjarne Stroustrup
- shin_lao 13y agoDon't worry, the language doesn't sit idle. C++ 11 and C++ 14 are significant improvements, almost a new language.
- kajecounterhack 13y agoI can attest to this. C++11 is amazing. Pseudo type-inference with the "auto" keyword, specific "nullptr" rather than null being conflated with an int, smart pointers, list initializations, for (elem : lis) loops... an actual hash table implementation that isn't backed by trees?! Is this even C++ anymore?! I've mostly written scripting languages until C++ but man C++11 has made the transition way easier. A lot of small stuff that makes your day so much better. Some big stuff that also makes your day better.
- pjmlp 13y agoI do bash C++ a lot, not because of the complexity, rather due to the C underpinnings that make the language unsafe by default. As a Pascal refugee that really enjoys the languages developed by Wirth for systems programming, I would rather see C and C++ replaced by something that was rather safe by default, unsafe only when really required. Having said this, I do enjoy coding in C++, when I am able to work with developers of the same skill level that are able to fully code in modern C++ and not C compiled with a C++ compiler guys. C++11 and C++14 are nice improvements to make the language better, that are just spoiled for the C historical baggage. Now back to JVM/.NET land.