(• Reading Time: 7 minutes •)
“C++ is designed to allow you to express ideas, but if you don't have ideas or don't have any clue about how to express them, C++ doesn't offer much help.” ~ Bjarne Stroustrup (Danish computer scientist, Creator of C++)
C++ is a super complex language.
If you're completely new to programming, it'll take at least 3 months to learn C++. That's working at least 2 to 3 hours each day. However, if you've programmed before, working at least an hour a day, it'll take 1 to 3 months to grasp the basics.
And if you want to build mastery in C++, it'll take at least 2 years.
|Programming level||Time it'll take|
|Absolute beginner||At least 3 months|
|Already a programmer||1 - 3 months|
|Building mastery in C++||2 years - forever|
C++ for beginners and how to approach it
Are you an absolute beginner programmer?
If yes, it's a bad idea if you're completely new to programming and you turn to C++ as your first language.
Particularly if you're a self-taught programmer.
If you're in school and you have no choice – many schools still start students off with C++ as their first language, which drives students away – just learn as much of C++ as you can.
But don't give up if you end up not liking it.
There are many other programming languages that can keep you excited about programming in general.
If C++ doesn't do it for you, try others.
What you'll need to learn the basics of C++
Like any programming language, you need to know how to:
- declare variables
- collect user input
- store information
- repeat an action through loops
- write functions to repeat blocks of code
These are standard.
And if you already know how to code, it won't be a big deal.
Maybe a little annoyance here and there, especially arguments among C++ fans about using
; or whether it should be completely dropped.
It's a fun debate to have. But don't get too hung up on it.
Why it takes long to learn C++
The reason C++ takes a much longer time to learn is because of its quirks.
- Memory management
- Reference and Pointers
- Standard template library
- Threads and handling exceptions
These are powerful concepts to master. But they'll have you banging your head on the wall.
Over and over.
And after learning them, it doesn't mean you're done. As with any language, there's always something more to learn.
In C++, the more you learn, the more things you see that you don't know.
It makes you feel special though.
Current programmers looking to learn C++
If you're a C programmer, you'll end up loving C++.
But if you're not, C++ will likely still be a hassle. Even if you already know how to code, C++ is a beast to handle especially if you've never coded in a low level language like C or assembly.
So C++ can come off as a shock because of all the pointers and constant memory management learnings. They may seem unnecessary but you absolutely need to master them.
How long to learn C++ if already fluent in Java?
If you already how to code in Java, you can get up to speed with the basics of C++ in 3 days because both share similar syntax. However, learning memory management in C++ can take 3 weeks or more to wrap your mind around.
There are lots of differences between C++ and Java but the biggest is understanding memory management particularly how to use pointers. In Java, memory management is system controlled and automatically done for you.
But this is not the case with C++.
You have the power to manage the memory as a C++ programmer and you have to learn how to do that well.
Some similarities between Java and C++
There are lots of similarities between Java and C++ but as a Java programmer, you should know that both languages support: abstraction, encapsulation, polymorphism, static and dynamic binding.
Specifically at the syntax level, both languages:
mainfunction as their entry points
- data types are similar (e.g. int, float, bool, char, string, etc)
- using conditional statements are the same
- loops follow the same structure
- commenting out code is similar in both languages
These similarities are what make it quite easy to switch from Java to C++ in a few days.
Major differences between Java and C++
There are lots of differences between both Java and C++ but the biggest difference is you're in charge of memory management in C++ but this is automatically taken care of in Java.
Other differences are:
- multiple inheritance in C++ compared to only single inheritance in Java
- default arguments in C++ but none in Java
- constructors and destructors in C++ but Java only has constructors
- operator overloading in C++ but not in Java
- structures in C++ but not in Java
And many more. A lot of these are super cool to use in C++ but they also come with more complexities, which open the doors to insane bugs.
Mstering each takes time, which is why it takes insanely long to fully wrap your mind around C++.
So should you still learn C++?
Absolutely yes - it's always good to learn a new language no matter what level you're at.
Now, “when should you learn C++?” is the more important question.
- Are you in school learning C++ because you have no choice in which language to start with? If yes, focus and learn as much of C++ as you can. You'll have a solid appreciation for how programming works at the lower level.
- Already a programmer looking to learn more? Props to you. If you're a Java programmer, then welcome to the world of C++. If you're not, no worries but you have to brace yourself.
In the end, learn as much as you can. And after that, check out functional programming as your next stop.
C++ is a beast.
So get ready to feel like you're cutting your teeth with stone.
But it's also a cool language that every programmer should at some point play with it.
Thanks for reading
- Join Community: I help new programmers and junior devs focus on what matters instead of endless trial and error. If you're interested in boosting your confidence and skills, join the email community.
- Follow on Twitter: Have a question, I'm most active on Twitter – feel free to reach out to me. My DM is open.
Heads Up - I love research so I tend to back my advice and approach with concepts from Behavioral Psychology and Neuroscience.