Python vs JavaScript - side by side comparison

preview_player
Показать описание
Python vs JavaScript test of the relative performance.
As an example I took basic prime-finding algorithm with N² complexity.

All found primes are stored in a list/array and as the result scripts print the length of the list/array.
I tested a relative speed of code writing, including typos.
And the Python and JavaScript performance.

Python vs JavaScript - side by side comparison

FOLLOW ME:

MY COURSES:
or

#python #javascript #redeyedcoderclub
Рекомендации по теме
Комментарии
Автор

Came for the information, stayed for the background noise.

jamesprice
Автор

I intentionally didn't use special Python algorithms for primes. I compared language "efficiency" using dumb algorithm implementation for both languages and equal language "tools"

Follow me @:

RedEyedCoderClub
Автор

This is just because Python integers are boundless integers (like BigInteger in Java), while JavaScript numbers are fixed-size floating point numbers. This is the same reason Python 3 is usually slower than Python 2 (which used fixed-size integers when possible).

gianluke
Автор

I think node.js is better. We can already make code writing shorter in node.js.

ahmet-akin
Автор

For a experienced devolper, Js is easily readable too

SnehilKankran-qesi
Автор

Yeap, CPython have no JIT (in this version), so... But if you compare Py and JS in more real world scenario with db and async network things - you can't see much difference. Mostly JS faster. But sometimes Py can be faster bc of the best integration with C.
Btw, if you need speed - you use Numpy or PyPy/numba/pypyc or Cython. Or even Java, Go, Rust, C, Fortran, etc 😀

Alexey-gpvc
Автор

Its just python with C implementation under the hood :) Just use pypy in order to achieve best performance in CPU bound operations.

TdadadT
Автор

Hi. Very dumb programming question probably but how does the function deal with the different return values of the different blocks inside of it (for and if blocks)? If if the if block returns “false”, the for block returns “true” anyway or did I misunderstood something? Thanks.

soufianta
Автор

instead of return put yield in python and see the power of python

francko.j
Автор

Any one help me to choose my next course about programming, My goal is data analyst and I have knowledge about SQL and now I would like to learn programming language but I am not belong from engineer background so which one is better for me either python or java?

manoharrajput
Автор

I have been studying for cloud computing.
I want to know if I should consider JavaScript or Python?
Please advise.

JohnJohnson-chxq
Автор

ok but what if you use tuples or numpy or numba?

loftyTHEOWNER
Автор

If you think 9.4sec is fast
Use bun js to see the ultimate speed of JavaScript

SnehilKankran-qesi
Автор

I think that this is not a good python code, when do in python range(2, 250001) it will create a list with each element from 2 to 250001 before do the "for". this create a horrible performace code.

thiagom
Автор

If you like dot notation for attributes access (javascript style) and you want to use it in Python you should check libraries like Jsify

zbigniewrajewski
Автор

Не сходится.
Питон быстрее.
Что за версия у вас?
Проверяли в 3 человека на разных компах.

im_vanich
Автор

Python 3.11 is 25% faster, python 3.13 will be 5 times faster.. soon we will beat JS 😜

nagamanickam
Автор

Javascript comes from the island of Java.

alienhz
Автор

The code formatting on the JavaScript side hurt me. No spaces in the for loop variable declaration check and increment, no space between the closing parenthesis and the opening curly brace. Ouch

NewLondonMarshall
Автор

To me Javascript is the best programming language. It runs in the browser, you can build everything from desktop apps to web and mobile apps with it and it is also pretty fast.

igweogba