Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

none of the posts I read here mentioned the true advantage of C++ over other languages: It's the only language that offers enough flexibility to write 1) generic, 2) correct and 3) efficient code. With C you get only 3. With Haskell you get 1 and 2. With ML you get some of 1 (yes I contend that C++, in the hands of a competent programmer, can be as good as ML or even better for writing generic code) some of 2 and some of 3. C++ allows you to have cheap abstractions (using them does not require paying significant penalty, unlike Scheme or Smalltalk). Java and similar managed languages excel in neither of these criteria in particular.


Felt like expanding a bit more: Note that this is a result of evolution in the language: What's referred to as modern style of C++ that has emerged from the works of people involved in the STL/boost tradition and for the large part informed the new standard. It's a noticeably different style from what you would see in a codebase written in mid-90s. It's arguably less object-oriented than most Java systems, and adopted certain concepts from functional programming, while exploring several innovations hitherto unseen in other languages.

What also enables this is advances in modern architecture. 64bit processors allow for large address spaces and large stack frame sizes, which obviate the need to allocate every single bit on the heap. You can often see sizable C++ programs measuring around 100KLOC or larger which use new/delete in a handful of places. Automatic storage is, well, automatically managed. For when free store semantics is needed, smart-pointers abstract the complexity of several common cases where automatic-management is not adequate.

Using value semantics, streams, lambdas, regular expressions, and a good library for command line flags processing (e.g., boost) C++ can even be a perfectly apt choice of language for scripting. The development effort need not be much longer than python but with no optimization the result can be easily 10 times as fast.


It's nice to learn C, then learn C++98, then learn C++11, stick with it for 5 years and still find that the language has 8379483 quirks you've never heard of.

Bjarne vouches for abstractions. Everyone does. What does Bjarne + standards commitee do? Make old stuff useless, yet make sure the user has to deal with it. Make new stuff so the language becomes more complex. Why do we want abstractions again? Because we want to get rid of useless stuff and make things simple instead of make them complex! What does C++11 do? It goes to the wrong direction. Very, very nice.

When will we have something simple instead?


C++ abstractions aren't about making things simpler or about hiding complexity from the programmer. They're about reducing duplication and allowing solutions to be expressed in the domain of the problem. C++11 intentionally made things more complicated to add more ways to do that.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: