This content originally appeared on DEV Community and was authored by Voider
In this article I will talk about shifting from a compiled language (CPP) to an interpreted language (JS).
Introduction
I have been coding for almost 3 years now and my native language has been C++ for most of that time, but recently I have been preferring JavaScript and I will cover why in this article.
Which is better?
Answering this question depends on what do you want to achieve, for example if you want speed then you should definitely choose C++, you can look up tons of comparisons online between the two languages.
Why am I preferring JS recently.
- I am a very lazy person and I try to use my brain capacity to the very bare minimum, so using a tool that handles my frontend and backend at the same time saves me the hassle of integrating things together if they are of a different language.
- It takes a whole lot less time (and brain capacity) to learn, I didn't even realize how hard C++ was until like a year later, but this will significantly help you as a software engineer.
- You can do so much with so little code, for example let's say you have an array of animals that has a name and species:
var animals = [
{ name: 'Fluffykins', species: 'rabbit' },
{ name: 'Caro', species: 'dog' },
{ name: 'Hamilton', species: 'dog' },
{ name: 'Harold', species: 'fish' },
{ name: 'Ursula', species: 'cat' },
{ name: 'Jimmy', species: 'fish' }
]
and you want to copy the names of all the animals to another array, the normal way to do this is by:
var names = []
for (var i = 0; i < animals.length; i++) {
names.push(animals[i].name)
}
taking up 87 characters
but thanks to JavaScript's ES6 arrow functions we can do this in literally one line:
var names = animals.map((x) => x.name)
taking up 38 characters
you literally just saved up writing 49 characters for yourself, if you can't see beauty in this I don't know when will you ever do.
Last word
Again this is not a comparison at all, I am just stating my personal experience, you should use what's best for what you are working on and what you feel most comfortable with. Thanks for reading.
This content originally appeared on DEV Community and was authored by Voider
Voider | Sciencx (2021-08-02T09:17:26+00:00) Why I shifted from C++ to JavaScript.. Retrieved from https://www.scien.cx/2021/08/02/why-i-shifted-from-c-to-javascript/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.