DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 968,873 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Cover image for JavaScript vs Python πŸ‘¨β€πŸ’»
Youssef-mic
Youssef-mic

Posted on

JavaScript vs Python πŸ‘¨β€πŸ’»

In the last article What programming language to learn first
I said that JavaScript was better than Python in my opinion but why?? Today we are gonna battle them out and see who will beat the other to be the GOAT of programming languages
First, let’s see who the competitors are:

Python:

On the blue side, we have Python this dynamically typed language that can do whatever you throw at it, Backend Web Development... Yes,
Cross Platform App Development... Yes, AI and Machine Learning... Of course!
It’s super mega popular between the beginners and the advanced and is labeled as β€œThe single best programming language to learn”.

JavaScript:

On the yellow(red) side we have JavaScript, also a dynamically typed language that has a framework to do anything, Frontend web development... Reactjs(I know this is the library don’t kill me guys ok??) Backend Web Development... Nodejs of course and Cross Platform App Development... Indeed you have tools such as Ionic or React Native.
It’s the only language to develop web applications (assuming you are not brain dead to use something like Dart or C# Blazor or this anti-JavaScript stuff). It has a traditional curly brace syntax and is loved by a lot of programmers (including me!)

Now let’s start the battle

  • Performance

In the real world, JavaScript is known to be not that fast of a language, but on the other hand, Python doesn’t beat this. They are both compiled to C so, you can say that they are both at the same speed but in comparing the time consumption in 100 million iterations:

# Python

sum = 0 
for i in range(100000000): 
    sum += i 
print(sum) 

Enter fullscreen mode Exit fullscreen mode
// JavaScript
let sum = 0 
for(let i=0; i > 100000000; i++){
    sum+=i
}
console.log(sum)
Enter fullscreen mode Exit fullscreen mode

Nodejs managed to be 75 times faster than Python. But performance isn't very important because you should focus on code optimization instead of choosing the best language depending on performance.

  • Syntax

JavaScript follows a curly-braced traditional type of syntax, but Python -eh- has a space-based one which for me isn't that good.

  • Popularity

In the StackOverflow Survey 2022 JavaScript ranked 1st and Python ranked 4th. But both languages are... Pretty Popular.

  • Conclusion

I am very happy with JavaScript and in 1 year of full stack development I said that I tried Python and I didn't learn it right. Does that mean that I won’t give it another shot hell No. For me, JavaScript is the GOAT I am not against Python.
Let me know your opinion in the comments below!

Top comments (1)

Collapse
 
anderspersson profile image
Anders Persson

There is a "real" compiler fΓΆr Python to, called Nuitka it converts python to .c code and use a c compiler like gcc to output pure binany.
Link to the project nuitka.net/
And if you like to make a standalone binary out of javascript and/or Typescript DENO have a compile mode to, great to make small tools without user have to install nodejs
deno.land/

Classic DEV Post from 2020:

js visualized

πŸš€βš™οΈ JavaScript Visualized: the JavaScript Engine

As JavaScript devs, we usually don't have to deal with compilers ourselves. However, it's definitely good to know the basics of the JavaScript engine and see how it handles our human-friendly JS code, and turns it into something machines understand! πŸ₯³

Happy coding!