by CrLf · 14y ago · 0 comments
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/). I like C though.
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.
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".
For me, that really is the edge that C++ holds over C.
Polymorphism and "good generic data structures" (in the sense you are implying) are not a necessary requirement of elegant and maintainable code. It is part of the problem that programmers have taken OO concepts as the end-all of good code, and must apply those concepts everywhere even if that means implementing them from scratch at the cost of (unnecessary) complexity.
Large systems have been written in C. Many large open-source projects use C. There is no evidence that these are less maintainable (in general) because of language choices.
Some of these graft OO concepts onto C. GTK is noticeable for this (although it doesn't seem to be too bad for application developers, I'm afraid for those tasked to maintain the libraries themselves).
Procedural programming is not a sin (if "procedural programming" exists at all today, as most of the simplest object concepts have become common practice and are now though as an integral part of it).
As far as I know, there is no such 'old saying'.
However, The determined Real Programmer can write FORTRAN programs in any language.
I have an example. The Squid proxy code used calling via function pointers everywhere as DIY polymorphism. That made it quite difficult for me (ymmv) to follow the code.
Things like ctags would have worked if they'd used "real" C++ polymorphism.
IMHO. YMMV.
If from OO, I could have only Java-like interfaces, it would probably be enough. Implicit type conversions could also work I suppose.
Stroustrup discusses this here:
http://channel9.msdn.com/Events/GoingNative/GoingNative-2012...
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.