Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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.

share|improve this question
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
12  
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
show 5 more comments

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

migrated from stackoverflow.com Mar 23 '11 at 21:15

This question came from our site for professional and enthusiast programmers.

5 Answers

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.

share|improve this answer
16  
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
3  
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
show 18 more comments

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)
share|improve this answer
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
show 2 more comments

I have used C++ for embedded products such as: ticket printers, laser printers, tape drives, hard drives, Personal GPS Navigation products, mailing machines, ink jet printers and tape libraries.

The C++ language may be migrating to embedded systems, which is why many student's don't see, notice or know about. Its fad time has long passed by, but it is not dead by any means.

share|improve this answer
add comment

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.

share|improve this answer
add comment

This is a personal opinion, but one based on experiences since the first C++ compiler became available.

C++ was originally and continues to be a a programming language for research. It has been and is the test bed for new concepts and ways of implementing them. In the real world, the behavior of C++ programs is very compiler and platform dependent, unlike what happens with C.

The findings from the research in C++ are readily incorporated into other mainstream languages in less risky ways, and C++ (STL, BOOT) remains an experimental, hard to learn, and hard to scale programming languange.

Bjarne Stroustrup, the creator of C++, has stated that C++ was an experiment in designing a better C with OO support [reference needed]. The standardization effort for C++ was a long and painful one, with a result that satisfied none of the parties involved.

The introduction of generics through macro replacement in a statically-typed and compiled language was one of the largest mistakes made in the design of C++. It took years of errors, and the STL effort to have a generics library that was somewhat usable, and it still takes years of study to become productive with the standard library. Problems that had been theoretically and practically solved in languages like Eiffel and ML were reinvented for C++ only to spend years trying implement solutions over ill-born designs. The experience of having hundreds of errors being reported for a missing colon in a generic class declaration is one that any programmer can spare.

To ultimately judge C++, its role, and it's future, one would have to consider Objective-C, which is everything C++ was supposed to be, but without the history of traumas.

Delivering projects over C++ continues to be so painful that the benefits attributed to the language gets eclipsed into irrelevance, more so when one can always resource to old, tried, and trusted plain C.

share|improve this answer
    
There have been up and down votes on this answer, so I'll edit it in the same tone so it gets away from its current zero. –  Apalala Mar 24 '11 at 17:29
5  
Primarily I downvoted it because it appears you haven't considered, say, the last fifteen years or more of development. –  DeadMG Dec 23 '12 at 18:59
    
has the author looked at C++ at all in the last decade? –  BeyondSora Jul 9 '13 at 19:39
    
No, the author hasn't done professional work in C++ in over a decade. –  Apalala Jul 10 '13 at 11:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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