DEV Community

Cover image for What makes languages "fast" or "slow"?

What makes languages "fast" or "slow"?

vibalijoshi on October 09, 2021

In his article Naser Tamimi compares C++ and Python and this is what he observed: As you can see Python is much slower than C++, but in reality ...
Collapse
 
eljayadobe profile image
Eljay-Adobe

Scripting style languages — like Python, Ruby, Lua, JavaScript — are fast to modify-and-run. They don't have the disadvantage of compile and link steps. (The engine will usually on-the-fly tokenize or bytecode the program, and then run that in the scripting engine.)

Compiled style languages — like C++, C, D, Rust — are fast to run because they are compiled to native code. But have a slower turn-the-crank because of the compile and link steps, and arguably are fussier languages which makes them slower to develop in as well.

Java and C# hit the sweet spot of combining all the disadvantages of a scripting style language, with all the disadvantages of a compiled style language. (Kidding! Poking the bear. I like both Java and JVM, and C# and .NET.)

Collapse
 
ancienthello profile image
AncientHello

This is why I use Go.

It compiles lightning fast. It runs lightning fast.

I've never had fuss around to get someones project to compile. It just works. And it is quick.

The best of both worlds.

Collapse
 
vibalijoshi profile image
vibalijoshi

I need to try out Go soon 🔥🔥

Collapse
 
vibalijoshi profile image
vibalijoshi

Ahh I love the style of your writing! Very well explained in brief words ( better than I could tbh!)

Collapse
 
markclewis profile image
Mark Lewis

In general I appreciate this article for trying to explain something complex in simple terms, though there are many aspects I think it over-simplifies. One of the big ones is that a lot of the performance on modern computers depends on memory access and this article doesn't mention that at all.

The reason I'm commenting though is because of the following quote. "You don't have to wait for the compiler to finish before testing your code modifications because there isn't a separate compilation process. This makes the debugging process much faster and easier." In my experience, this is outright false. The lack of a compiler might let you start debugging faster, but it doesn't make finding and fixing bugs faster. Indeed, I would argue that it normally makes debugging much slower. An example that I saw from one of my students last year was that in JavaScript he had typed gc.fillstyle=... instead of gc.fillStyle=.... He spent hours looking for this error and didn't find it before he came to me for help. In a statically typed language that typo would have been found in seconds with a modern IDE or at worst minutes by the compiler. Thanks to the joys of dynamically typed languages though he spent hours on it. This isn't just an issue for students. My own experience as a professional developer has led me to hate dynamic languages for anything more than a few lines of code because of these issues. Typos that should be found by tools immediately become serious debugging sessions in JavaScript, Python, or other dynamically typed languages.

Collapse
 
vibalijoshi profile image
vibalijoshi • Edited

Thank you so much Mark for putting this forward! There is just so much going behind the scenes for every language that it made it difficult for me to pin down on a common conclusion.

I totally agree with your point that this article does not cover every aspect. When I was researching about this, there was no place where I could practically understand it. So I just took and initiative to make it simple so that beginners like me would get an idea.

Thanks to experienced people like you who can provide us with knowledge that even the internet can't. I'll research on the memory aspect and improve my article. Thank you so much once again 🙌🏻

Collapse
 
thomasjunkos profile image
Thomas Junkツ • Edited

This kind of discussion is very academic. When choosing a language other metrics are more important than how fast the language is. E.g. the first questions should be: How many programmers are out there using the language? How fast are the developers producing results in the chosen language? Is my application that time critical? What about: How is your data organized? How is the ecosystem of the product: Databases, caches etc. (which would compensate most of the "slowness" of the language?

These are the questions focusing on your product.

Whether a language is fast or not is from my POV a nice question for sitting in a pub with a nice drink at hand and having nerd conversations :]

Collapse
 
xumaquer profile image
Xumaquer

Agreed, there's a lot of stuff to care about when choosing a language

  • How many programmers are using this language ? Companies should care about this because it's easier to find programmers to hire in a popular language it's also more likely to find a answer to a question you may have in stackoverflow or any other place, because the language gets used a lot more so there's a bigger chance someone had the same problem as you

  • How fast are developers getting results on this language ? I think libraries,frameworks and tools are more important here than the language itself, the whole idea of "getting results" for me at least is more linked to a combination of what tools,frameworks and libraries you're using, you're likely to struggle if you choose the "wrong tool" for the job

  • Is my application "that" time critical ? this is a good thing to ask yourself but i think that some companies start with small apps that get bigger over time, sometimes the choice of a algorithm or way to do something is more important than the speed itself, for example a CPU renderer in C could be slower than GPU renderer using python or javascript
    sometimes even "higher level languages" implement libraries as just a wrapper over lower level languages (as it happens a lot in python for example) so it may be wise to use a high level language and write some specific time critical pieces of your code in a shared library in a lower level language if you don't find a good library for the job

Collapse
 
vibalijoshi profile image
vibalijoshi

Let's have that nerd conversation sometime 😎

Collapse
 
andrewpierno profile image
Andrew Pierno

You made it seem so easy. I like the illustrations, too!
Would you be willing to write some tutorials for our us? Happy to pay.
You can either DM me on twitter at twitter.com/AndrewPierno or fill out this little airtable form airtable.com/shrN6S3NMZ7oxRXTt.

Collapse
 
aboss123 profile image
Ashish Bailkeri

Loved the diagrams. Nice job explaining!

Collapse
 
vibalijoshi profile image
vibalijoshi

Thank you so much for your appreciation 🦋

Collapse
 
balighmehrez profile image
Info Comment hidden by post author - thread only accessible via permalink
BalighMehrez

Excuse me
Double check your factorial code
It will always returns zero 😊

Collapse
 
vibalijoshi profile image
vibalijoshi • Edited

Ohh yes! Thank you so much for pointing out 🙌🏻

Some comments have been hidden by the post's author - find out more