Why should I learn C++

I’ve been reading that a person who wants to learn programming or coding such as JavaScript should learn C++.

First of all, JavaScript is not a programming language, but a front end coding language, is this correct?

I have read that JavaScript was built on C++. What exactly does this mean? Does it mean that the syntax and logic that goes into creating JavaScript was built upon C++? Or, rather, does it mean that the same logic and syntax principles that are implemented into JavaScript coding is derived from C++?

Did I just say the same thing? lol What I meant, was, if I am to understand JavaScript by using it to update website, learning the principles of C++ would give me a firm foundation of the coding logic.

As for the practice session I am trying to follow using Codecademy, it’s confusing. I’m wondering if there is a better way for me to learn than rather follow the practice sessions.

1 Like

Hi @anotherme

I’d disagree with that. If you want to learn JavaScript, you should learn JavaScript. C++ is a completely different beast…

Back in the 90’s, this may have been the case. Now not so much because you’ve got things like Node which let you write both your front- and back-end in JavaScript, and Electron which lets you write desktop applications (like the Atom code editor) in JavaScript.

There are some similarities between how you’d write things in C++ and how you’d write them in JavaScript, but there are a host of differences as well.

I think we’re back to my original point of

if you want to learn JavaScript, you should learn JavaScript.

The logical processes and constructs that you’ll learn in JS - like loops, functions, conditional flow etc - are really just abstract concepts, which are implemented in a certain way (i.e. you write them in a specific form) in each language*. For example, a for loop in C++ looks like this:

for (int i = 0; i < 5; i++) {
  do some code

whereas the same thing written in Python would be:

for i in range(5):
  do some code

The abstract principle - of getting the program to do the same action 5 times - is unchanged, only the format of the instruction is different. You don’t need to know C++ to understand these concepts - they’re not dependent on the language. They’re dependent on logic, and if you know what a loop is then being able to write one - whether that’s in C++, JavaScript, Python or whatever - is simply a matter of learning how to write it, rather than learning what a loop is again.

Having done the C++ course here as a refresher of the C++ I originally learnt at university, I didn’t find any of the exercises especially confusing but if you are struggling with any of the lessons on the C++ course - or any of the courses, for that matter!! - you’re welcome to ask questions about them here on the forums. :slight_smile: Just remember to post a link to the exercise you’re asking about, so we can see what you’re being asked to do. :slight_smile:

* A small caveat: some constructs may not appear in every languages. For example, Python does not (to the best of my knowledge) implement switch/case for conditional flow whereas JavaScript does.

1 Like