Take the 2-minute tour ×

C++ is one of the most used programming language in the world since like 25+ years.

My first job as programmer was in C++ and I coded in C++ everyday for nearly 4 years. Now I do mostly PHP, but I will forever cherish this C++ background.

C++ has helped me understand many "under the hood" features/behaviors/restrictions of many other (and different) programming languages like PHP and Delphi.

I'm a full time programmer for 7+ years now and since I have a quite varied programming background I often get questions by "newbies" as where to start to become a "good" programmer.

I think C++ is one of the best language to start with because it gives you a real useful experience that will last and will teach you how things work under the hood. It's not the easier one to learn for a newbie, but in my opinion it's one that will reward in the long term. I would like to know your opinion on this matter to add to my arguments when I guide "newbies".

After this introduction, here's my question :

Is C++ (one of) the best language to learn at first nowadays?

Since it's subjective, I've marked this question as community wiki.

EDIT: This question is not about why Java (or C# or any other language) is better than C++ to start with, it's about what's make C++ a good choice or not a good choice to learn as one of your firsts languages. For example, for me C++ made me understand how the memory works. Now today in many languages everything is managed by the garbage collector and some people don't even know that. I'm glad I know how it works underneath and I think it can help you to write better code.

share|improve this question

closed as not constructive by Daniel Fischer, Kev May 1 '12 at 22:54


While C++ is really used a lot, TIOBE is not a good measure of the popularity of the language. –  KennyTM May 26 '10 at 14:14
Yeah nothing can classify "the most used programming language" in the world but I found this link quite interesting. –  AlexV May 26 '10 at 14:17
Funny that the question was closed as subjective and argumentative, as the author actually pointed out in the last sentence... –  David Rodríguez - dribeas May 26 '10 at 14:21
I guess it boils down to trying to avoid flamewars as much as possible. Actually I am surprised at how well SO has managed to deal with this... in other forums you get a lot of not-so-nice not-so-polite responses to anything that is a language comparison. –  David Rodríguez - dribeas May 26 '10 at 15:43
"This question is not about why Java (or C# or any other language) is better than C++ to start with ..." I call flamebait; if you're asking "Is C++ (one of) the best language to learn at first" then you are certainly asking if it's better than Java (or C#). Learning C++ first by definition requires learning it before Java or anything else. –  Dour High Arch Aug 12 '10 at 20:19

20 Answers 20

up vote 23 down vote accepted

In my opinion, C++ is NOT a good first language.

You are exposed to way too much at first. Pointers? Memory Management? Templates? Classes? Compiler errors (as opposed to scripting)? AAAAGGGGHHHHH! Way too much to confuse and discourage beginners.

I'd much recommend another language without all this stuff going on.

  • C might work, you still learn the low level pointer and memory stuff, but you get to skip OOP, templates, etc. I'd stil have a hard time recommending C though (it was my 2nd language in college courses, about 5th overall)
  • Java gives you OOP, but saves you from the black hole that is memory management. Lot's of prebuilt classes and libraries so you don't reinvent the wheel too.
  • Python gives you quick feedback since it's interpreted. A lot less complicated stuff going on at first too (but it's there later when you get better)

It's not that C++ is a bad language, the learning curve is just too steep for a first language.

share|improve this answer
@Brendan If you start with assembly language, pointers become second nature. Does that mean beginners should start with assembler? –  FredOverflow May 27 '10 at 8:33
The problem with char* is that you have to deal with all of C's ugly memory management. All that work to save 1 size_t worth of memory? People think C++ is hard because of libraries and examples where people still don't just use strings. –  Brendan Long May 27 '10 at 16:27
Brendan your argument is confusing. You say C++ is good because you have to deal with pointers and memory management, but then you say that C is bad because you have to use char* and memory management... You can't have it both ways ;) –  samoz May 27 '10 at 17:15
No C++ is good because you can deal with pointers and memory management. C is bad because you have to. –  Brendan Long May 28 '10 at 1:33
No I mean in C++ you don't have to use new/delete or deal with pointers (at least when you're doing trivial things like you're likely to do in a beginning class). Not to mention that it's much easier once you start if you use classes (if you have new in your constructor, use delete in the destructor and you won't have any problems). And @samoz: I don't like starting with Java because of all the hand-waving about what everything is. Like how there's value types, and then objects, which are kind of like pointers, but not really ("but pointers are hard so don't think about it"). –  Brendan Long May 28 '10 at 16:12

I like C++ but I'd never recomend it as a first language.

As others have suggested C++'s complexity makes it unsuitable for a first language, beginners don't need to worry about backward compatability.

Once you have some programming experience under your belt then there are things C++ can teach you.

  • low level stuff - memory and pointers and RAII oh my!
  • highlevel stuff - templates, generic programming and meta-programming

and looking to the future the good stuff seems to keep comming (c++0x rvalue refs, variadic templates, user defined literals). for a language of its age it is pretty progressive in looking at new concepts, in comparison some much newer languages have virtually no core language change.

share|improve this answer
I agree - I have been writing C++ for 10 years and I still ask newbie questions on SO. New programmers don't need to be discouraged like that... –  BlueRaja - Danny Pflughoeft May 26 '10 at 14:20
I disagree. My first programming language was C++, and thanks for that prof. because he chose it over python years ago. It is just not C++ that is impossible to learn, it is how you teach it. –  AraK May 26 '10 at 14:23
@BlueRaja: New programmers don't need to know std::mem_fun_ref. Yours is definitely not a newbie question. –  KennyTM May 26 '10 at 14:23
@AraK sure if you learned C++ first and stuck with programming it won't do you any harm, the problem as I see it is it is more likely to put you off programming altogether than another langugae taught at the same level –  jk. May 26 '10 at 15:42
C++ was not my first language, however it made other languages I knew then look like children's toys. –  Secko May 26 '10 at 16:47

Your "question" (which doesn't contain a single question mark!) is full of non sequiturs.


I'm not sure what relevance popularity has. McDonald's is one of the most popular restaurants, but I'd never recommend it to someone looking to eat out for the first time. I wouldn't recommend "pop" music to anyone wanting to learn about music.

I think C++ is one of the best language to start with because it gives you a real usefull (sic) experience that will last

I can't tell what this means. Are other languages not "real"? not "useful"? not "experiences"? don't "last"?

and will teach you how things work under the hood.

Kind of. It will teach you how things work at the level of C++. Whether that's useful really depends on whether you're a C++ programmer. How many C++ programmers do you know who can describe the implementation of new/delete?

If you really want to learn how things work, I don't see how you can avoid going down to at least the level of assembly language and syscalls.


Ignoring the issue that these languages aren't all that different, you've offered nothing to suggest that C++ is in any way unique here. Couldn't C have offered the same benefit? Or Fortran? Or Algol? To claim that C++ is the "best" is to claim that others are worse, and you've not addressed any other language, nor any unique feature of C++.

For example, for me C++ made me understand how the memory works. Now today in many languages everything is managed by the garbadge collector and some people don't even know that. I'm glad I know how it works underneath and I think it can help you to write better code.

If you understand the design and implementation of new/delete/malloc/free, you're probably a 99th percentile C++ programmer. Almost all of the ones I've met (or interviewed) assume that new is an atomic O(1) operation. Or that new/delete (and malloc/free) are the only way to allocate memory, and don't know about obstacks, or various GC strategies, or how threading and memory allocation interact. But by the time you learn "how the memory works", you've had to go way past C++. No one language can teach you everything you need to know about any one subject, and I still see no evidence that any one is better to learn first.

share|improve this answer
I know every programming language have it's legetimity and that no programming language is the best (or maybe even better) compared to each other. ANY experience with ANY programming language is worth something. But since C and C++ are "old" and well established I can fairly think that I can have more job opportunities with them than with let's say COBOL... Anyway this "question" was not intended to prove the C++ supremacy (it's not even my favorite language) nor to start a flame wars. I just wanted to know the positive (and why not the negatives) of learning C++ as one of your first language. –  AlexV May 26 '10 at 15:52
Assembly is still too high-level. There is no such thing as add eax, [ebx] -- you must learn about micro-operations to really understand what's going on ;) –  FredOverflow May 27 '10 at 8:31
"I can have more job opportunities" is like "one of the most used programming languages", in that it's completely different from "best language to learn at first". In the food business, being a McDonald's burger-flipper would give you the most job opportunities, but that doesn't mean it's the best thing to learn -- first, or at all. –  Ken May 30 '10 at 17:05

I think that C++ makes a wonderful first programming language. An instructor doesn't have to introduce classes until he's ready. He also doesn't have to introduce the whole idea of references (as implemented in most OO languages) until he's ready, and when you do implement those, it's very explicit when you're using them and how they work. You want arrays? Introduce a bounds-checked vector class.

share|improve this answer
Agreed. C++ is great because you don't have to know any of the hard things, but once you're ready, it's all there. –  Brendan Long May 26 '10 at 17:59
Well said. A lot of the comments on this question assumes the student needs to swallow all that C++ has to offer. –  Rev316 Jun 1 '10 at 21:11
This should be the answer. Other languages are toys with lead paint all over them. Go with C++ for 'actual' work. –  ActiveTrayPrntrTagDataStrDrvr Nov 15 '12 at 10:47
Unfortunately, with C++, doing anything useful is considerably more difficult and with more potholes than with other languages. So while the instructor can introduce things slowly, it will be a long while before the students can do anything interesting. –  weberc2 May 23 '13 at 16:42

Well, it's not for me. By far the best language I've ever taught is Python. C is of course the best I've ever learnt but I come from a time when dinosaurs roamed the earth :-).

The learning curve there for students to get a program running and understood is far less than with any other language I've tried (including C++).

share|improve this answer
You can learn all you need to about Object Oriented Design with Python, then if you really want to, get into C++ and learn memory micromanagement. –  Mike DeSimone May 26 '10 at 15:00
Hurray for C! Have an upvote. –  samoz May 26 '10 at 18:00

I believe C++ is a fine first language.

It has concepts of:

  • memory
  • typing
  • objects
  • inheritance
  • functions
  • iterators
  • strings
  • compilation
  • arrays
  • containers
  • bit-operations

It has libraries for DB access and threading.

It is not easy, but it gets the needed information(both high-level and low-level) into you. It is imperative that a competent programmer know everything from malloc to database access. It presents most concepts in first principle forms, instead of papering over the leaky abstractions. C++ has volumes of information written about it; some of it is even good information. :-)

Its primary power downfall is a lack of closures and first-order functions. Everything else, it has.

C++ has a simple enough start point that complexity can be managed and ramped up from the teacher's standpoint.

Forcing yourself to understand - really understand memory - is required to program at the maximum level of skill. Why defer that?

Yes, C++ is hard. But - programming a real computer is hard. The typical C++ complaints simply expose the essential difficulties of programming a real computer(memory, resources).

There are other good first languages, but I consider C++ to be one of the best due to its depth of expression, combined with its nearness to the 'metal'.

share|improve this answer
C++0x introduces anonymous functions and closures. And C++ always had first-order functions from the beginning, I assume you mean higher-order functions? ;) That also comes in C++0x in the form of functions that take std::function<bool(int, int)> or something like that. –  FredOverflow May 27 '10 at 8:36
@Fred - yeah. I know the Next C++ Standard will add more power. It's just not here yet. :) –  Paul Nathan May 27 '10 at 15:12
Vorfreude ist die schönste Freude. Maybe someone can translate that :) –  FredOverflow May 27 '10 at 18:18
@Fred: yes, dealing with the C++1x in practicality won't be as fun as thinking about the permitted awesomeness. :P –  Paul Nathan May 27 '10 at 18:38
So... the chase is better than the catch? :) –  FredOverflow May 27 '10 at 18:41

Just found an article that represent what I'm thinking...

I am actually physically disgusted that so many computer science programs think that Java is a good introductory language, because it's "easy" and you don't get confused with all that boring string/malloc stuff but you can learn cool OOP stuff which will make your big programs ever so modular. This is a pedagogical disaster waiting to happen. Generations of graduates are descending on us and creating Shlemiel The Painter algorithms right and left and they don't even realize it, since they fundamentally have no idea that strings are, at a very deep level, difficult, even if you can't quite see that in your perl script. If you want to teach somebody something well, you have to start at the very lowest level. It's like Karate Kid. Wax On, Wax Off. Wax On, Wax Off. Do that for three weeks. Then Knocking The Other Kid's Head off is easy.

From Joel on Software Back to Basics.

share|improve this answer
right :) Wax On, Wax Off. –  ucefkh Dec 3 '12 at 2:59

I don't really think there's so much an issue with the concepts that C++ exposes you to. These are all important concepts; they have to be learned, and in my opinion it's best not to go along sugar-coating them for too long.

About thirteen years ago, I tried to learn C++ as a second language (after QBASIC). I failed, miserably, but the primary reason for my failure was not the concepts involved in C++, but the unfriendliness of the environment. In order to see your C++ program run at all, it has to be completely syntactically correct to even compile, and it has to avoid segfaulting right off the bat due to some silly oversight. And when you are unable to satisfy these requirements, the diagnostics provided are monumentally unhelpful for a novice trying to learn a programming language on their own.

The most important part of the learning process when you are self-teaching is trial and error. In C++ (and C, and largely Java too) if you make an error, you can't even get to the trial part. I remember many times having a small C++ program that worked, and trying to make some tiny change, addition, or improvement to it, only to wind up with a handful of syntax mistakes that caused the compiler to barf out a cascade of a dozen errors and perhaps a hundred warnings. Being a complete novice, of course, I had no way to distinguish which of these pointed to the real problem to give me even the most vague indication of what I did wrong. Normally, at that point, I just had to start over (since of course I knew nothing of version control either!).

Eventually, I abandoned C++ for a year or so and programmed in Visual Basic instead. While I would never recommend VB to a new programmer these days, its advantages for me were that it was very forgiving and allowed me to try things out and see what I did wrong without having my program be an all-or-nothing affair. Later, when I came back to C++ with some additional knowledge of how to interpret errors, and of programming in general, it was much more accessible.

So in short, I'd recommend starting with a language that allows a rapid trial-and-error cycle, has a somewhat forgiving syntax, and provides relatively friendly diagnostics. These days, I think the best candidate for that is Python. It's certainly not C, C++, or Java, although these are all languages that are worthwhile to learn eventually.

On the other hand, it's not unreasonable for C++ to be a first language if it is taught as part of a course where the student has access to a instructor or TA to help them understand what the compiler is trying to tell them.

share|improve this answer
I taught myself C++ after learning QBASIC. It wasn't 'easy', but I learned how to program in a detailed fashion. –  Paul Nathan May 26 '10 at 17:20

C++ is a terrible first language because it's intrinsically confusing. When teaching programming, you are concerned with teaching logic. decisions, looping, arithmetic, overflow. That's the same in most languages. You can even teach a c-like language like Java, or python. But C++ (and C) have too many obstacles getting in the way. I'll give you a partial list.

  1. auto variables aren't initialized. So students have to remember. It's better, when you're learning it all, to have to worry about the logic, not that your language neglects to initialize variables to save a few clock cycles. I love that about C++, but I don't love it from a pedagogical aspect.

  2. Compiling and linking offer issues that are much better dealt with later on. Of course, when I teach C++, I start with a single file, which solves this problem for a while.

  3. There's no built in set of libraries for everything. Graphics is an excellent way to teach Java, both because it's exciting and fun, and because you can see some of your mistakes. But in C++, graphics is not exactly built in. And doing anything requires linking, projects, all kinds of craziness better left for later.

  4. Arrays are pointers. This means you have to deal with pointers fairly early, when you want to be dealing with array problems.

In addition, C is an even worse language because:

strings are not first class objects. This means you need pointers just to do strings, it's an abomination.

In short, all the things that make C++ such an awesome system language for experts make it a bad choice for students. Just because a good teacher can make it work doesn't make it a good idea. For a first language, I would go with java or javascript or python.

The difference between what I'm saying and the attitudes in most colleges, implied by some of the people griping about Java, is that I'm saying it is most efficient to START with Java, but that you then want to learn how it really works and learn C++. And incidentally, far too many students never learn to use a debugger, which is one of the first tools I force them to use. The debugger gives you a window into what's really happening, though it's an imperfect window sometimes.

share|improve this answer

My first programming language was Pascal. It was the first programming course taught at the school I was attending, and their second course introduced more advanced programming, in C++. In that first course (Turbo Pascal back then, as Windows 95 had only just been released), we were taught the bare basics: variables, functions (and procedures, as Pascal makes the distinction far more verbosely), etc. I have since thought Pascal to be a very suitable language to learn these basics, due to it's fairly verbose syntax. It has its quirks and imperfections, but in the end I am glad they taught us this way. Nowadays I guess Object Pascal might be a worthy successor.

Other than that, I personally wouldn't keep C or C++ too far away from students. I really liked starting off with Pascal and moving on to C++.

share|improve this answer
Actually I started with Delphi 3 and then C/C++. I still think that today Delphi is the best very first language to start with. But C/C++ helped me much more than Delphi to learn "low level" stuff (like memory management, pointers, etc.). –  AlexV May 26 '10 at 15:26

I think the best programming language to begin learning must be general and very high level. This way it can be better learnt the essence of programming. Maybe Python is one of the best, I think.

share|improve this answer

C++ is a complex language, and as such you have to start with some subset of the functionality. The common case is starting with the C subset of the language (which is not really C, but there are very few differences). Now, some authors as Koening in Accelerated C++, consider that some of the features in the C subset are not necessarily a good start point.

In that particular book, there is not even a mention to pointers in more than half of the book. It starts with the STL, operations on strings, vectors, ... first with plain functions, then it adds classes and builds on concepts that are harder to grasp.

I don't think that approach to be any more complex than the way I learned Pascal, or how Java is presented in my University to students nowadays. Then again, I have read that book after already knowing how to program, so I might be biased and maybe it is harder than I think...

share|improve this answer

As recommended in this article by Peter Norvig which was voted as the best programming article in this thread:

Given these criteria, my recommendations for a first programming language would be Python or Scheme. But your circumstances may vary, and there are other good choices. If your age is a single-digit, you might prefer Alice or Squeak (older learners might also enjoy these). The important thing is that you choose and get started.

share|improve this answer

C++ was actually my first language when I started programming uhh...6 years ago when I was 16. I really think it's helped me get where I am today. I had an understanding of how these things worked that no one else I graduated college with could comprehend. Sure, there's a lot to jump into, but there's no reason you can't ease your way into the language. You don't need to know what a pointer is to learn an if statement or what a loop is. I personally suggest it as a first or second language, but I'm sure others here are going to disagree with me.

share|improve this answer

I attended two colleges in the course of getting my degree. One utilized Java and the other C++. While I'm not extremely fond of either language, Java was much easier to pick up than C++. The school that taught with C++ also introduced Perl to me, which was my favorite of the three.

share|improve this answer
I had the opposite experience. My first college taught C++ and I learned a lot in two classes (because they dove right in and didn't hold back to make it "easy"). The second one is so far using Java and they've tried so hard to make it easy to learn that they don't actually teach anything. Hiding things like pointers from students isn't helping them any (although the gc is useful). –  Brendan Long May 26 '10 at 15:59
@Brendan: your name seems familiar - where was your first college? –  Paul Nathan May 26 '10 at 17:40
It was just a community college in Colorado (Front Range Community College). I think it might be a community college vs normal college thing (since the community college only has 2 semesters to teach you everything, so they can't spend a couple years pretending pointers don't exist). –  Brendan Long May 26 '10 at 17:58

As jk has pointed out I also wouldn't recommend c++ as a first language, but for sure I would recommend it at some point in order to familiarize with HW architecture.

Using c++ helps to understand how program is executed and thus write more CPU/memory friendly SW or understand why some things happen.

share|improve this answer
If you want to understand HW, learn C or even assembly. C++ will just distract you with templates and inheritance and all of the other OOP concepts, which you would understand better by learning C# or Java. –  JSBձոգչ May 26 '10 at 14:29
nopers, you can't learn templates better via c# or java, generics aren't the same –  jk. May 26 '10 at 14:30

In my view starting with a high level scripting language is the best approach. When starting with lower level languages there is a tendancy to spend too much time dotting i's and crossing t's rather than a singular focus on application design. If you end up writing lousy code that can be fixed incrementally. If you end up with a lousy design its a much more difficult problem to address.

In my view problem solving and domain knowledge are the only skills that matter. Languages and their assorted decorations and features are a commodity and should be treated as such.

share|improve this answer

I also would not recommend C++.

I think Java is easy to study, rather than C++.

share|improve this answer

My assertion is that writing good code comes from good design. You can learn strong OO analysis and design principles in a language agnostic environment. If you are using Java, C++, or anything else to learn object-oriented principles, you are making a mistake. If you are using Java and C++ to apply said principles, you are well on your way.

With that being said, I recommend C to everybody that asks me. You will learn about lower level things like memory management and how/why to write efficient code, why strings are hard (since you'll be using char[] arrays) and how to write functional code while having the world of OO hidden from you. For me, C is still my base language... I think in C.

Object oriented analysis and design is largely language agnostic. You're almost better off learning about OO separately from any specific language. When you understand the concepts,the principles, and the purpose, you can then learn how to apply them in different languages, as syntax and implementation across different languages may vary. Your time with C will give you an appreciation and an understanding for what is happening under the hood.

share|improve this answer

No, because it gives the student the mistaken impression that C++ is a valid choice for something.

C should not be used for anything besides OS kernels (and perhaps not even for the entire kernel), C++ should be used for nothing.

Why? Buffer overflows.

Imagine a world where there were no buffer overflows because C had not become popular as an application language (and in it's place was a language without low level arrays). All the damage and waste that could have been averted... hackers out of 'work', mailing lists silent.

And if you need speed, Fortran is faster.

share|improve this answer
Most of the aerospace and automotive industries will disagree with your assertion "C should not be used for anything..." –  Andrew Oct 26 '12 at 5:35
Actually all companies developing commercial software and games would disagree with you about C++. –  oopscene Mar 6 at 22:47
