Currently I'm an IT student and I'm wondering what is still important in C++ today, what for is it used? I completed basic C++ course in my university but I can't imagine where can I use my knowledge and in which direction should I go learning C++.

In other words what should I learn to become a successful C++ programmer?

Currently I'm learning Java just because I don't see clearly in which area C++ could be useful today, but I clearly know which kind of work I'll be doing as a Java programmer. But I still hope that C++ isn't dead.

  • 2
    This is my point of view. C++ is very useful in real time situation (and videogames). I also use C++ for desktop applications (don't forget about Qt) for performances reasons. – hosomaki Mar 23 '11 at 21:24
  • 1
    @stign IMO it is likely that it will eventually die since there will likely come a time when all languages today are obsolete (probably due to massive changes in the hardware being used). – Kenneth Mar 23 '11 at 22:05
  • 17
    C++ is far from dead (I write new code in it every day), and if COBOL is any indication, I'll have work for many, many years to come. – Michael Kohne Mar 23 '11 at 22:26
  • 2
    Take a look at The Programming Languages Beacon and make your own conclusion: lextrait.com/vincent/implementations.html – Nemanja Trifunovic Mar 23 '11 at 22:32
  • 1
    Recently I have watched some interesting videos on Microsoft's channel 9. Microsoft has spent millions on market research and based on its research it's talking about a C++ renaissance. See this video. – grokus Mar 24 '11 at 3:19

The killer feature of C++ is scope-bound resource management, SBRM (more commonly known as "RAII"). It is the only industrial programming language that is built around this concept. In C++, life times of all objects are exactly known, and (well-written) C++ programs guarantee that resources are acquired and released in fully deterministic manner. In comparison, garbage-collected or otherwise managed languages do not provide any such guarantees; in fact objects in those languages may persist after the end of their lifetime.

That is the reason why C++ is used in finance, video games, high-performance embedded and real-time systems, transportation, manufacture, and other industries where determinism and precision are important. There are no alternatives.

Granted, it was used for a lot more tasks than this, and those tasks are being lost to C# and Python and other more suitable languages, but that is not affecting its core niche.

  • 20
    Anyone who uses malloc in C++ I'd like to hit their head with a hard object. Also, there a is a lesser known feature of the operator new in C++ called placement. It allows to reuse a currently occupied memory space. So if someone wanted to avoid (or minimize) fragmentation they can, in theory do that. And predictable is not the same deterministic. – Tamás Szelei Mar 23 '11 at 21:51
  • 4
    @Apalala C++ has reference counting too, but it is much worse than SBRM in terms of object lifetime management. I'm not just talking about hard-RT determinism, I'm talking about deterministic behavior of the object model. – Cubbi Mar 23 '11 at 22:06
  • 4
    When I learned C++, RAII was not particulary widely known; I learned new and delete and brain-based pointer management. So I don't think you can characterize it as being "built around the concept". The libraries and other support structures that are used today may have, but not the core language or syntax. – jprete Mar 23 '11 at 22:09
  • 7
    @jprete True that many of the C++'s strengths were discovered rather than designed. This post is about post-2005 language. – Cubbi Mar 23 '11 at 22:15
  • 5
    RAII was designed into C++. But most C++ programmers just kept on writing C, replacing malloc with new and free with delete. – kevin cline May 30 '12 at 20:53

There are a few markets for C and C++ (to my albeit limited understanding)

  1. Existing code. C and C++ have some of the largest existing codebases around. Code of this size can't simply be thrown out just because the "next hot new language" has come around. C bindings are pretty much the standard of inter-langauge interaction on most platforms, so being able to author (at the very least) wrapper libraries in C or C++ is useful.
  2. High performance applications (e.g. high frequency finance). C and C++ still achieve better overall performance than most other programming languages. Most importantly in C++, one often builds abstractions with compiler-only things like templates, which moves computation from runtime to compile time (making your overall app faster).
  3. (Similar to 2) Low latency applications. Languages which run on e.g. the CLR or the JVM can often be nearly as fast as C++ depending on the application, but one still needs to load the CLR or JVM themselves into memory before your program can execute. If you have hard startup requirements this is important. EDIT FROM COMMENT: For that matter, hard latency requirements of any description are of note here. Languages which run on virtual machines rarely offer hard time limits because running of e.g. garbage collection is not a deterministic process.
  4. Embedded systems. Some embedded systems have the hardware to run e.g. the JVM (Google's Android (Okay, it's not really the JVM, but it's close), RIM's Blackberry) or the CLR (Windows Phone), but most embedded systems don't have the power to run languages which require more runtime support than that required for C or C++ (which is next to no runtime support at all).
  5. Deployment constrained applications. Sometimes requiring installation of the JVM or CLR is massive overkill if your entire program is only a few hundred KB. (E.g. most of the programs I work on must be deployed as a single .EXE file without any kind of installer or anything like that; for this there are no alternatives)
  • 2
    Startup latency isn't the only kind of latency to be concerned with: Hard realtime requirements can be a much bigger dealbreaker. – greyfade Mar 23 '11 at 23:02
  • 1
    Add in anything where you don't want to be locked into a particular maker (C# or Objective-C) or don't want your language to disappear into a bunch of lawsuits (Java) – Martin Beckett Mar 24 '11 at 4:45
  • @greyfade: That's kind of what I meant by (2), but I agree that's not clear. Edited. @Martin: While I think that's a good strength for C++, I don't think it answers the question -- which is in what markets is C++ commonly used. Also I don't think I'd call C# locked to a particular maker when a <S>BSD</S> (OOPS: It's LGPL) licensed version of the CLR exists (mono). – Billy ONeal Mar 24 '11 at 5:05
  • 1
    Also 5. Operating systems and core framework. You can do a lot in a virtual machine, but the virtual machine still has to be implemented in C and/or C++. – Jan Hudec Nov 1 '11 at 12:49
  • 1
    @Jan: Yes it would. Things like reflection and friends would trigger problems 2-4. The only subset you would really need to write the garbage collector would be some object which represents physical memory. – Billy ONeal Nov 1 '11 at 17:14

C++ is still very useful and by no means dead. If you want to read a serious comparison between some different programming languages check the paper An empirical comparison of C, C++, Java, Perl, Python, Rexx, and Tcl. It's not the most updated but I believe that most things still hold.

Not the answer you're looking for? Browse other questions tagged or ask your own question.