5 ms·
What I would like to see is a (convincing) list of why use C++ (in new projects) at all. In my opinion (and experience) when you need the performance advantage
by CrLf 14y ago
What I would like to see is a (convincing) list of why use C++ (in new projects) at all.
In my opinion (and experience) when you need the performance advantages of C++, you are usually within the domain where C is good enough (and perhaps a better choice for its simplicity). When you need the features of C++, you are probably better off with something like Python (not specifically, but in the same "league").
Seeing how easy it is to use a higher-level language combined with C for critical sections, I just don't see the point of C++ anymore.
Disclaimer: I don't really like C++. The only pleasant experience I had with it involved ignoring the STL completely and using Qt (http://qt.nokia.com/ http://qt.nokia.com/). I like C though.
- bjoernbu 14y agolet's say you write a search engine, a route planning system, a database, rule-based NLP (for most ML-based approaches fast, native math libs + python may be great enough because nearly all the time is spent in the math part) on HUGE datasets, etc, etc pretty much any system involving long list- or set-like types with a decent level of complexity. Most other languages enforce far too much indirection, padding et. al for collection types. Especially generics fail miserably compared to templates for that particular matter. C, on the other hand, will make everything MUCH harder. Especially proper use of RAII and (const) references allow (almost) zero overhead and almost no error-prone pointers (especially zero pointer arithmetic) in the whole system.
- CrLf 14y agoI wasn't saying that C++ had no use. I'm saying that its domain is narrower that what's commonly believed. It is false that C "will make everything MUCH harder". How hard something is to implement in a particular language depends on the problem and the people doing the implementation. C is only perceived to be much harder because people have become overly-dependent on language features (aka "syntactic sugar") and cannot reason about problems in terms that do not require those features. I'm not talking about using assembly here. It is not a matter of an unstructured language vs. a structured one. I'm talking about features. This is particularly relevant because in many places where C++ is used, the coding standards prohibit the use of more than a limited subset of the language, effectively transforming it into "C with classes".
- adestefan 14y agoI don't think that C "will make everything MUCH harder," but with C you'll end up spending a lot of time just getting the groundwork in place before you even start to work on the problem at hand.
- norswap 14y agoC is good and simple but C is not expressive. There are a whole hosts of situation where code has to be duplicated or slightly modified. For instance, it's really hard to do good generic data structures in C without ending up with casts everywhere. Polymorphism is even worse. For me, that really is the edge that C++ holds over C.
- Jimmie 14y agoI agree. I kind of wish there was a middle ground between C and C++. C++ is bloated but C is not enough.
- shuaib 14y agoObjective-C?
- agumonkey 14y agoIt seems that C++ really requires one to be subtle in his coding style. Stroustrup discusses this here: http://channel9.msdn.com/Events/GoingNative/GoingNative-2012/Keynote-Bjarne-Stroustrup-Cpp11-Style http://channel9.msdn.com/Events/GoingNative/GoingNative-2012...
- Leynos 14y agoDoes D not aim to fill this niche? (I suppose in terms of exposure and infrastructure, D is lacking relative to C and C++).
- heretohelp 14y agoNo, it's closer to a garbage collected Algol but with way more features.
- Jun8 14y agoPeople generally master and commonly use only a subset of C++, i.e. C+.
- CrLf 14y ago
- Estragon 14y agoI've had good luck with python and cython when I need to get close to the metal. I'd really like to see a comparison between C++ and that kind of arrangement, some time.
- iambvk 14y ago> What I would like to see is a (convincing) list of why use C++ (in new projects) at all. C is my obvious choice, but... When it comes to deciding between C and C++, C++ beats C in one aspect: templates. For example, quick sort in C++ performs a lot better than C because templates enable lots of compiler optimizations. (Rest of the C++ features are just garbage for my purposes.) I just hope next C revision adds some form of template support into the language.