Programming Language Speed Comparison

preview_player
Показать описание
In this video, I compare the speed of Swift, Java, JavaScript, Dart, Python, C/C++, and Ruby. Tl;dr: Python and Ruby are reallllllly slow. The comparisons are based on three benchmarks that I created specifically for this purpose:

If you have any suggestions, you may leave them as a YouTube comment or as a GitHub issue or pull request.
Рекомендации по теме
Комментарии
Автор

I calculated that the speed difference between java and python is roughly 15 times more extreme than the speed difference between walking and taking a plane (in the most extreme case).

eyedjellyfish
Автор

I see a lot of comments suggesting that I should use the Python "reverse()" built-in or the [::-1] syntax. People commenting that clearly didn't read the notes in the repository, which include the following:

"The true purpose of this test isn't to see how fast a language can reverse an array. The test is to see how efficient a language's array access/write times are. However, I understand that many languages include a builtin method for reversing an array. You should feel free to write two tests, one with this method and one without it. This way, you can also test your language's direct ability to reverse an array."

Yes, Python has a built-in to reverse an array. But it doesn't have a built-in for everything. The array reversal benchmark is supposed to predict how fast Python will be for related tasks that don't have built-ins.

macheads
Автор

Nice to see Java so consistent in each of the test results.

dave
Автор

Me, a Java programmer in 2020 cannot be prouder.

aseemsavio
Автор

The most impressive thing is JS imo. It's an interpreter language and it's just so fucking fast compared to python and ruby, and it's on the same or just one order of magnitude less than C. Google really did a fantastic job with V8.

nilstrieb
Автор

C is faster if you have a person who can write it faster.
If you wrote a program that is not efficient because of lack of skill, nothing will save you.

ovndfbs
Автор

I am surprise how javascript suppress ruby, python, swift ...

KhaledMohamed-crdg
Автор

Can you do that now, in 2018, with modern versions? And, if possible, use windows for testing C#.

hamzanasirr
Автор

Not surprised Java is fast in this case (in fact some more modern JVMs, such as graalvm may be even faster). The Java VM automatically recompiles, and optimises code based on how its running, rather than what is predeicted ahead of time. this gives further opportunity for further perfromance. Of course, Java has its downsides, such as slow startup (due to loading the JVM and also initial JIT compile phases) and may use more memory, again due to the size of the JVM and re-compile phases. in the long run though, it can be competitive with C the longer it runs.

Java may not be the fastest for simple command line utilities, that run for a short time, but for those big web apps that run fopr a long time, or large apps, it can be very competetive if coded well.

JanoJ
Автор

Add C# and Lua maybe?

Also yes Python is crazy slow. That's why it's essential to use libraries like Numpy because they run C under the hood (I know that it wouldn't make sense to include Python+Numpy in the benchmark just mentioning it to anyone triggered in the comments)

*Edit:* if you ever decide to build on this, I would suggest you try Cython along with Python. I mean sure you are technically getting C under the hood but I think it would serve as a good example because not many people even know about the existence of Cython let alone use it.

atrumluminarium
Автор

So basically what i got from this is that java is really damn cool

konzYTz
Автор

I would be interested to see how Lua performs in this test.

glych
Автор

What about Java's multithreading or Stream? Shouldn't it increase the speed even more?

gabriele
Автор

I'd love to see Rust results in this list too!

Автор

I like that you acknowledged the pun at 2:58

SJ-vctz
Автор

As a python buff, I'd like to see a language comparison that includes developing time :-)

jojojorisjhjosef
Автор

I don't see why some people like Python. It's slow, not backwards compatible, dynamically typed.

aryafarzan
Автор

Java can do runtime optimizations which compiled languages can't.
Java stores Variablesdifferently ue to it being interpreted. How it is that fast i'm not sure :3
Just guessing btw.

TheKivifreak
Автор

Have you tried NodeJS, I know it's JavaScript, but its way different in how it works behinds the scenes from what ive been told.

hereticstanlyhalo
Автор

Very impressive @macheads101, thanks a lot for the video, could you also add go/golang and benchmark that as well. That will be great.

AbhishekMishra