Linked by anonymous on Tue 29th Mar 2011 16:05 UTC
General Development The C++ programming language is about to be updated, as the ISO steering committee for the language has approved the final draft specifying its next version. The ISO/IEC Information Technology Task Force will review the steering committee's Final Draft International Standard will review and, barring any complications, publish the draft later this year. It will be known as C++ 2011.
Thread beginning with comment 468245
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE: someone explain C++ popularity?
by rom508 on Tue 29th Mar 2011 22:35 UTC in reply to "someone explain C++ popularity?"
rom508
Member since:
2007-04-20

Two main reasons:

1) Good compatibility with C. This is important when you want to do systems programming. Most operating systems and system libraries are written in C, so for example, if I want to program in Ada and I need to have the ability to call system library functions, etc., I need Ada bindings. With C++ you can use all C constructs directly.

2) Object-oriented programming model. You can do OO programming in C, but it's a bit more effort and requires discipline and experience. Certain programming constructs are expressed better with OO paradigm. I mainly write C code, however when needed I tend to write C code that uses abstract data types, inheritance and polymorphism. If you have a large team of programmers C++ makes OO programming more formal, this makes it easier for inexperienced programmers to write conforming interfaces.

Personally I'm not keen on C++, I find it too messy and wacky. The language as a whole has too many holes, i.e. it allows you to do things which result in undefined behavior and are hard to debug. I would really like to switch to Ada 2005, however until major Unix platforms (Linux, BSD, Solaris) decide to fully support Ada and provide complete Ada bindings for all their system libraries, I will stick with C.

Reply Parent Score: 4

project_2501 Member since:
2006-03-20

Thank you for your response - I appreciate it. I am still not convinced.

(1) You can bind to C using lots of other languages. If you're primarily doing high level programming - you shouldn't need to do this often. So I still don't see why we pay the price of C++ just for this reason. Binding to C is done rarely and therefore the effort can be done there .. eg Python to C bindings. The majority of time is spent doing high level coding in a nicer language.

(2) There are lots of other much less hazardous OO languages. Again why use something like C++ to gain the safety and convenience benefits of C++ when the language itself has so many pitfalls that negate these benefits?

I can only conclude that C++ is a macho choice. Like driving manual cars whenin fact automatic or even driver-less cars would be safer, more convenient, but just wouldn't be seen as macho.

I'm still open to ideas ... keep them coming.

Reply Parent Score: 2

dsmogor Member since:
2005-09-01

C++ was just at the right place/ right time.
It capitalised on C syntax popularity (java, c# in turn capitalised on C++ syntax ) and delivered good natural integration with existing C code / libs.
Other languages / runtimes provide some support for C ABI but none of them can consume C headers directly. This made C++ a natural "upgrade" path for projects that were moving up abstraction ladder.

Current popularity is mostly outcome of that reinforced by excellent tool support (hundreds manyears of optimization compiler research) and availability of libs of all kind (both low and high level).
Actually, when used dilligently it delivers.
It's biggest advantage is that the progammer has a big freedom in deciding how highlevel his/her code is going to be. From the C/asm level to almost java levels with a good library (ask QT devs). And all of this in a single codeset! Most advanced / dangerous features are for use of libs developers, usuall code cruchers will get by by using only a small subset of the language and sticking to usage patterns mandated by the standard lib of choice.

Edited 2011-03-29 23:44 UTC

Reply Parent Score: 5

vivainio Member since:
2008-12-26


(2) There are lots of other much less hazardous OO languages. Again why use something like C++ to gain the safety and convenience benefits of C++ when the language itself has so many pitfalls that negate these benefits?


C++ is an industry standard, cross platform, vendor neutral language without a fat runtime (i.e. runs on metal). It will be around long after C# and Java (both vendor specific languages, to varying extent) are gone. C++ is not a lot "worse" than those languages, esp. after C++11, and it will always be faster and have leaner memory profile in practice.

With Qt being LGPL and C++11 coming, C++ is more relevant than ever.

The pitfalls of the language are not really a problem unless you want to make it a problem, i.e. write contorted code. Libraries like Qt mostly eliminate the memory management headaches, which has been the main gripe against C++.

Reply Parent Score: 5

ndrw Member since:
2009-06-30

3. C++ was around when Microsoft was deciding the language to write most of their software in.

Just like Obj-C, which unless picked by Apple would be a yet another language used only by enthusiasts.

To me, C++ is lacking only one feature - a garbage collector. GC isn't only for convenience, it allows more abstract data structures be used in the API. In C++ a function/method may take objects as parameters and return objects but someone has to specify who is responsible for their allocation and, more importantly, for cleaning them. Often, if the object is a part of a larger data collection, or if is being passed between object many times it is simply impossible to decide who should clean it up.

This is why most of frameworks written in C++ still feel like a set of C functions (operating on primitive data) conveniently grouped into classes.

Reply Parent Score: 3

dsmogor Member since:
2005-09-01

There are number of GC solutions for C/C++ info form of libraries. One of them is even used in GCC compiler code AFAIK.

Reply Parent Score: 3

MORB Member since:
2005-07-06

Regarding garbage collection and objects ownership, shared_ptr and weak_ptr help a ton (and you can have them using boost in pre c++0x compilers).

There's the downside compared to GC that you have to be careful to avoid cycles, but on the other hand the deterministic aspect of it (objects are finalized as soon as no one needs them anymore and not some indefinite time later on) make some things easier than with GC.

Reply Parent Score: 4

Tuishimi Member since:
2005-07-06

I would really like to switch to Ada 2005, however until major Unix platforms (Linux, BSD, Solaris) decide to fully support Ada and provide complete Ada bindings for all their system libraries, I will stick with C.


Just for liking Ada, I like you.

Reply Parent Score: 2

ricegf Member since:
2007-04-25

I invested several full-time years into Ada 83, and moved some of the code to Ada 95. In my experience, Ada had the pleasant property of minimal debug - if we could get our code to compile, because of the explicitness, it would probably work pretty well.

I rather miss that.

I can't find a reference now (and my memory may be off - if you have a reference pro or con, I'd be much obliged), but I recall that in the twilight of the Ada Mandate, a commission studied what was required to launch Ada as a successful commercial language. The commission recommended that the government invest either $15 million (which would make Ada a success) or $0 million (which would allow Ada to fail), because anything less than $15 million wouldn't achieve widespread success anyway.

Naturally, the government "saved" money by investing $10 million.

The US fiscal crisis distilled.

Reply Parent Score: 3