Sign up ×

I've been self-learning C++ for about 4 months now. I'm enjoying it, and I think I'm doing quite well. However, an answer to a question of mine got me thinking that I might be setting myself up for a fall.

So, what do people here think about C++ as a first language to learn? And is it worth me just carrying on now that I've made a good start?

share|improve this question

closed as not constructive by Eitan T, casperOne Aug 1 '12 at 14:01


33 Answers 33

up vote 66 down vote accepted

I don't understand why people still confuse "language" with "library". (Referring to the linked answer.) So what if C++ doesn't have a "native" concept of audio? There are lots of libraries out there, which you can readily use with C++, and which are probably better suited to your specific needs than any "catch-all" "standard-library" audio processing API could be.


C++ is a difficult language. There are others that are easier to learn. I would never argue about that.

But C++ is easily one of the most powerful languages around. It can be highly efficient, and highly elegant, at once. Of course, nothing keeps you from making a fine big mess of everything, either.

If I recommend C++ as a first programming language? Actually, I don't know any better. Others might protect you from making mistakes, and make initial success (e.g. your first GUI application) easier. But if you build on a foundation of C++, you will always be on a secure footing. You might never have to chose another language at all, actually. But if you want / have to, you will find it ridiculously easy.

An experienced C++ coder can do e.g. Java at full speed in a matter of weeks. The other way round? Much, much more difficult.

Many years later, I felt like I should amend this answer. Since my kids asked me to teach them programming, I started to do so. I found myself actually not starting with C++... because I showed them BF first. In absolutely no time at all, they understood about memory and pointers. Then I went on with C++, and we're enjoying ourselves immensely so far.

share|improve this answer
Very much agree. Once you know C++, all other languages are easy by comparison. At least until you venture into other paradigms like Lisp, Haskell, or Prolog. – Kibbee Apr 3 '09 at 12:39
+1. I agree with many points apart from where you say it's the best first programming language. I think making quick progress (e.g. that first GUI app) is important for students, and they can decide if they like programming without being overwhelmed by language details. – CiscoIPPhone Apr 3 '09 at 12:47
Personally, I think no-one should code a GUI app before he understands the concept of action handlers. And that one is difficult to do without a secure knowledge of OOP, and impossible to do well without lots of experience. Why toss people into deep water before they can swim? – DevSolar Apr 3 '09 at 15:42
When I hear "power" I think of what it can do, and seeing as anything that can be done in C# can be done in C++, but not the other way around, I'd say C++ is the more powerful language. That said I still enjoy C#. – GManNickG Apr 8 '09 at 5:02
While the distinction between language and library is important, a language with easily accessible 3rd party libraries (Perl/CPAN, Python/PyPI) or large standard library (Java, C#) does have benefits, and C++ is lacking coherency in 3rd party libraries since they are almost all developed out-of-sync with each other. This is why you see huge wheel-reinventing frameworks in languages like C++. (And this is coming from someone that prefers C++ over many other languages, but I also love Python.) – Roger Pate Jan 6 '10 at 18:14

Let me put it this way:

I took and passed with a 94%, the Sun Java Certification without ever having compiled a line of Java (that was nine years ago). I was able to do this, because I knew C++ very well.

On my first professional job, I was hired as a tester. On my second day, I was told I could program instead of test, if I learned enough PowerBuilder to be useful -- in two weeks. Because I knew C++ so well, PowerBuilder was easy.

C++ is hard, but if you learn it well -- read Stroustrup's The C++ Programming Language, do the exercises too, read his Design and Evolution of C++, read the C++ Faq and the Meyers books and Herb Sutter's books, read comp.lang.c++.moderated, read Coplien's Advanced C++ Programming Styles and Idioms no matter what OO language you want to code in -- if you learn it well, every other OO language is easy.

Learning C++ is excellent preparation for learning to code. (And you'll become a fair C programmer too, but read K&R to get to be a good C programmer.)

Oh. And C++ is really fun to program in, much less verbose than Java, and much more flexible. You're really in charge, not the IDE or the language. You can shoot off your own foot, but you'll be in charge of doing it. And read Alexandrescu's book once you know templates, it'll amaze and dumbfound and delight you.

C++ is fun. Read the "Curiously Recurring Template Pattern": it looks like this

template< class  T> struct base {};

struct derived: base< derived > {};

Yeah, you got that right: it's a class that derives from a base that's templated on the deriving class. Now that sounds just obscure and silly, but there are many good uses for it, and just the other day I was beating my head because you can't do this in Java (because Java uses type erase, not templates, for generics), but if I could have used it, I could have saved lots and lots of code repeated in lots of classes.

There's so much more in C++, and if you limit yourself to Java or .Net, you'll never discover it.

share|improve this answer
"if you learn it well, every other OO language is easy." I beg to differ. What you mean is "every other C++-style OO language is easy". – Svante Apr 3 '09 at 21:21
+1 for fun and templates! – ilya n. Jun 20 '09 at 0:29

C++ isn't an easy language to learn as noted by everyone else, but there are a few reasons that it makes a decent place to start:

  • it doesn't tie you to a specific programming paradigm (e.g., Java and OOP) so you can experiment with different techniques easily
  • C++ doesn't have the bells and whistles so you can concentrate on making the building blocks if you want to know how they are built
  • since it is a language and not a platform, you can choose the library or libraries that best fit the task at hand or your chosen programming style (e.g., choosing something like Poco for a Javaesque feel, ACE for the gritty early style OO, etc.)
  • it is a general purpose programming language, not a platform (had to say that twice)

The trick is learning it carefully and correctly the first time. I know that I, like many others, have struggled with it by learning it as "C + objects" before really understanding it. It is a hard language to learn. I would recommend looking for an experienced C++ mentor to attach yourself to as well as reading a lot of the "highly recommended" books on how to and how not to write C++. Avoid learning bad habits up front.

For a starting reading list in no particular order:

  • "Accelerated C++" by Koenig and Moo
  • "Effective C++/STL" by Scott Meyers
  • "Object-Oriented Software Construction" by Bertrand Meyer
  • "Expert C Programming" by Peter van der Linden
  • "STL Tutorial and Reference Guide" by Musser, Derge, and Saini
  • "The C++ Standard Library" by Josuttis
share|improve this answer

C++ will be (much?) more approachable if you learn "modern C++" rather than "C plus some new stuff". For example, use std::wstring and std::vector<> instead C-style strings and arrays.

The already mentioned Accelerated C++ by Koenig and Moo is one book that does exactly this.

share|improve this answer

Lots of support for c++ here, but I have to disagree. Every language has it's plusses and minuses (some achieve a better balance than others, of course).

That being said, for a first language, I'm convinced most people will learn how to program more effectively with a language that a) doesn't have an edit-compile-run cycle (which is inherently slower for you as the programmer b) has garbage collection c) has good runtime introspection. Best of if there is an interactive evaluator as well, to mess about with.

Development (if not runtime) is almost invariably faster in such languages, there are fewer things to trip you up, and there are better tools to help figure what went wrong when it did.

Which isn't to say learning the vagaries of memory management in a language like c++ isn't something worth doing, etc., etc., it just isn't the place you really want to start.

Another issue with c++ is that for all its practicality the sheer size of it added to the fact it has incompatible parts that can lead to subtle issues best avoided as a beginner.

edited: John D brings up the point in a comment that some people who learn first on a GC'd language (which is by no means limited to "scripting" languages) never learn pointers later. This is a red herring, though. Some people fail to learn all sorts of things, for all sorts of reasons. I maintain that worrying about pointers is a distraction when you're learning the basics. At some point you may well need to learn about manual memory management, but it's not fundamentally important to do this at first. Or more accurately, the gains made by avoiding this are more important than the costs.

Let me be clear though, I'm not saying that c++ is an inferior choice for a first language because it lacks garbage collection. That's just one of many issues that get in the way of learning the fundamentals of programming well. The real problem is that it is a large complicated language, with quirks all over the place and even internal inconsistencies (e.g. pointers and exceptions don't play well together). Of course all of this can be managed properly and you can learn good practice to keep from getting in trouble.

However, none of this will make much sense to a real neophyte at first. So some of learning it will end up being "do it this way, not that way". "why?" "because I said so --- you won't understand the details yet". Hardly an auspicious start.

The bigges gains for learning a first language though are probably in avoiding a edit-compile-run cycle (of any kind) and having good introspection.

share|improve this answer
I started to agree, but you lost me with the bit about garbage collection. For a beginner, heap allocation should never come up in the first place. If it does, I'd far rather it be as explicit as possible, so they start out having to think about it when they do it. – T.E.D. Apr 3 '09 at 15:45

C++ as a first language can be OK if you have a good teacher. But it's a pretty high wall to scale for the first time, but once you scale that wall, other similar languages come very easy.

So yes, carry on.

share|improve this answer

any language is a good first language (within reason, not something like lolcode)

once you get the hang of how it works, it becomes easier to branch out to other languages.

share|improve this answer
+1 even though I disagree with one part. lolcode rocks! – Robin Day Apr 3 '09 at 12:55

I think that C++ might not be the most user-friendly language to develop in for a first timer, but it is also not going to hold your hand and necessarily lead you towards too many bad habits (I didn't say any, just not too many).

C++ was the introductory language that my university's programming courses were based in and that's where we learned all the basics and about data structures and algorithms before branching out into the languages of our choice.

share|improve this answer

For me learning C++ is mostly about learning how NOT to shoot yourself in the foot. It can be a painful exercise as with C++ there is always another edge case that will make the gun go off as it's pointing at your hoof.

The up shot is, if you manage to finish the exercise, you'll be a better developer for it, and you will be able to spot future foot shooting opportunities before they happen, in what ever languages you end up using.

Also, when some third part library shoots it's self in the foot, you'll be better positioned to grok what went wrong than others that haven't repeatedly shot their feet for months on end.

I'd say stick with C++, it's not a waste of time, even if you never write a single line of production C++ code.

Hope this helps :)


share|improve this answer

Carry on. C++ is still widely used and THE language for certain kind of work. So it depends on what you want to do - systems programming is done in C++ or C, business and web apps tend to be done in other things.

I do strongly recommend that you explore other languages as well. Python is my second language, for example; it may give you new insights about object-oriented and functional programming and make you a better C++ programmer (and a better programmer overall).

I believe being exposed to as many languages (and, more importantly, to many different programming paradigms) will make you a better programmer overall. Take a look at Haskell, Prolog, Lisp, and an Assembler variant, at least.

share|improve this answer

Personally, I think everybody should start with BASIC. No, really I do. At least first the first 2 weeks to 1 month. It's great for high school courses. It's simple enough that you can focus on very simple things like using variables, looping structures, conditionals, and calling subroutines without having to worry about frameworks, objects, and pointers. However, if you've already gotten past all that simple stuff, there's no reason you can't just keep on going with C++. It's a great language. And very useful. I think that people who have never programmed in C/C++ are really missing out on some fundamental things you should know about how things work on a lower level.

share|improve this answer

If you were just about to start out I wouldn't recommend C++ as a first language, because the first thing you need to understand as a programmer are the programming concepts, and in C++ you'll spend a lot of time wrangling with the syntax.

But since you're four months in and enjoying it then it sounds like you are doing okay, so I'd say carry on. But round it out with some more general reading. Something like Structure and Intepretation of Computer Programs. It will teach you things that just ploughing throw in C++ won't occur. Things that will make your C++ programs better (and make you better in other languages as well).

share|improve this answer

C++ was the first proper language I learnt, and it set me in good stead for learning other languages (C# mainly).

Among other things, it gave me a good grounding in object orientation, which really, really helped, when working with Siebel and with C#.


share|improve this answer

C++ is good choice for a first language. Particularly if you're four months and making good progress I would urge you to not change now. C++ is hard, but it's a good language to learn because it doesn't hide anything from you and because so many other languages use a similar syntax. Make sure you give yourself plenty of time to understand that syntax so you can easily spot the differences (which can be quite subtle) when you start learning other languages.

Finally, I would caution you to make sure you're concentrating more on programming concepts than on language concepts. With every new C++ syntax feature you learn, ask yourself "What problem does this solve?" It's those solutions to problems that are far more important than the particular implementation in C++ or any other language.

share|improve this answer

Ignore the haters. C++ can be a first language. My first language was assembler on the TRS-80 Model 1.

share|improve this answer

I think if you are sharp and are having a good time with it, then C++ is an OK beginner language for you.

If you asked me the same question without having actually picked one to try yet, I'd suggest starting with Ada instead. It is just as powerful as C++, but far less cryptic.

Also its syntax was designed to be less error-prone, and it does far more compile-time and runtime checking, so you'll spend much less frustrating time debugging your programs. What really turns off a lot of a lot of would-be programmers is when they get nasty bugs they just can't find.

The main thing now that you are using C++ is that, once you get comfortable with it, you go out and try another language. Too many people get so used to one native lanugage that they can't see outside its borders. I can't count the number of people I've seen who hate all languages but their first, simply because they do things differently. But even if you were to stick with C++ as your main language for life, I guarantee you that learning Lisp will make you a better C++ programmer.

share|improve this answer

For me C++ was my first language too and I guess it was a good choice. You learn all the basic principles of OOP and will understand the logic structure of programming. But of course it depends on what you wanna do with it.

But I'm pretty sure if you switch to rails to do all the fancy web-apps you'll become a much better developper than anyone who started with PHP or - worst case scenario - Rails.

So go for it!

share|improve this answer

There are two types of languages. The 'kitchen sink' and the 'minimalist'. The kitchen sink language gives you everything under the sun they can think of that might be useful. The minimalist gives you only what you need to develop anything you might ever conceive of. C++ is minimalist. You can certainly write things and share them with others but by default it comes with nothing.

C++ is also (one of) the hardest language for programmers. Managed/interpreted languages do a lot of things for the programmer. C++ does nothing but it also doesn't get in your way or make you pay the overhead of management.

Are you aiming to be an expert with MAD SKILLZ or just playing around?

share|improve this answer

Is C++ a good first language?

It's certainly usable as one, as you've found out. I wouldn't specifically recommend it for an introduction to programming in general (I'd prefer Python or Scheme), but it depends on your goals and learning style. I've taught programming in C successfully, and when approached properly C++ is no more difficult.

If your goal is simply to learn C++ for some particular purpose, I really don't know a better method than going ahead and learning C++.

If you like challenges, you might want to jump into C++. The learning curve is fairly nasty, but once through it you'll know a lot of stuff. (People still do learn how to use the vi editor, after all.)

I would recommend learning the higher-level stuff first. Learn vectors rather than arrays, use smart rather than ordinary pointers, that sort of thing. Partly because you should wind up programming like that (for most purposes), and partly because there's less stuff to remember at first. You will need to learn the lower-level stuff eventually, just like you'll need to learn the bit-twiddling stuff eventually.

share|improve this answer

While I'm sure C++ is a great tool to have inside one's box, i would carefully advise against learning it as a first language.

C++ is a powerful tool for professionals. You can do horrible things with it ( Sometimes you will have a very hard time trying to understand the errormessages. It has features like manual memory management and pointer arithmetic which clearly have they're place in systems programming and software with very high performance requirements (games...) needs them, but they are are hard to get inside ones head and are not very useful outside those niches. When I switched from c++ to java I really learned a lot faster, but that may be just a personal thing.

share|improve this answer

C++ is a very useful tool and I do often consider mastery of C++ a mark of distinction just because it is such a crazy language.

My advice is learn another language too like python or scheme at the same time. I programmed C++ for quite a long time but when I started learning scheme python and subsequently haskell a whole new world of thinking opened up to me. It is easy to get into the mind set that C++ can do everything and do it faster so therefore there is no point in learning another language.

Basically the faster you can load the more concepts and methods of programming into your head the more awesome you will be at raw problem solving.

One of the funnest quarters I had in college was a class that studied discrete math and functional programming with scheme which was immediately followed by a class that studied computer hardware architecture and used assembly.

share|improve this answer

I think C++ is a good overall first language to learn because it has a little bit of everything. It's not like high level scripting languages where you never really have to deal with types, memory, or pointers and it's not direct-hardware access like assembly. It's somewhere in the middle. If you learn C++ you'll basically have a skill set that will translate easily to other languages.

share|improve this answer

C++ is a tough first language to learn, but it's not impossible, and you will learn alot from it. The key to it, like anything else, is to not give up if you don't understand something. Ask questions, and read if something isn't working. Eventually you'll find an answer. I think the best quote I can give you about your task comes from Randy Pausch:

“Brick walls are there for a reason. The brick walls are not there to keep us out. The brick walls are there to show you how badly we want something. Because the brick walls are there to stop the people who don’t want something bad enough. They are there to keep out the other people.”

share|improve this answer

You will make mistakes in any language that you begin to learn. Some languages may have less pitfalls to watch out for, some may have quite a few. Whatever be the language, you are sure to invent your own pitfalls. Now that you have spent about 4 months, I'd suggest you carry on. A switch now may make things more difficult given the fact now you have two things to accomplish:

  • Unlearn C++
  • Learn language X from scratch
share|improve this answer

Go, go, go! Everybody is gonna love you for reiterating their early-on efforts and see themselves in you etc. All the sentimentals aside, yes personally i think you should. You will have much better credibility and hence self-esteem.

share|improve this answer

C++ is probably not the best language to start with, and there are much worse choices.

As other have already said, the trick is to learn it correctly, I mean the modern C++ where you'd be able to concentrate (/focus?) on algorithms and the problems to solve, not the C with classes where you'd have to understand memory management while in the early chapters.

AC++ is indeed a very good book to learn modern C++. However without any experience in programming, Francis Glassborrow's You can do it may be a better choice to start with.

share|improve this answer

C++ was the first language I ever did much with. I played with BASIC a bit in middle school, but never really did anything more substantial than a "I'm thinking of a number between 1 and 100" game. I didn't have a whole lot of trouble with C++, but I wasn't self-teaching. In High School, an AP Computer Science class was offered, and we used C++ at the time (College Board was doing the exam in C++; they have since switched to Java, I think). I think it's fine as a first language (or nearly first, in my case), as long as you have a good teacher.

If you're self-teaching, I think you would get more out of Python. You can play with stuff right in a REPL, so there is a lot more instant gratification. The language itself is also a lot more strict in its enforcement of language idioms, which will help you learn the "right" way to do things. C++ won't get in your way if you try to do something the wrong way, and, especially if you don't have a teacher to tell you what you're doing wrong and how to fix it, you will tend to develop some bad habits.

share|improve this answer

You have a lot of good answers here, but I would add:

Never give up on anything! If you don't have time or something doesn't interest you then you should QUIT, but never GIVE UP!

I don't care how hard it is, carry on. Carry on slowly if you must.

share|improve this answer

Where I went to school they taught most classes in C++ (actually it was more of a hybrid C/C++: think C++ but using only C-style strings and no stl), and I think it makes a great first language. It's just the right mix of close-to-the-hardware low-level grunt work to help you learn what's really going on with memory, pointers, and streams on one end combined with object design using high-level constructs like stl collections and garbage collection (boost shared pointers, etc) on the other.

That said, I've moved on to VB.Net and C# now. I still really appreciate my C++ background, and I think it's made me a better programmer having used it first. But I wouldn't want to go back.

share|improve this answer

If you're four months in and doing fine, stay the course. However, I wouldn't recommend C++ as a first language in general.

In grad school, I was a teaching assistant for a first year computer course that all engineering students had to take. The course used C++ as the teaching language and I think now that this was a very poor choice. About 10-20% of the students 'got it' right away and breezed through the course (as a SO user, you're probably in this catagory), the middle 70-90% worked hard and did OK, and the bottom 10-20% were still having trouble telling the difference between a variable declaration and a function declaration half way through the course.

Too many students were bogged down in the syntax of C++ as opposed to using computers to solve problems, which is what a general first-year computer course should have really been about.

share|improve this answer
