DEV Community

Discussion on: Getting started with JavaScript : The Definitive Guide

Collapse
 
shaijut profile image
Shaiju T • Edited

Nice, 😄, So Javascript and Pyhton being a interpreted language is slow compared to compiled languages like C, C++, C# and Java ?

Then how come Node.Js is fast, its also Javascript right ?

Collapse
 
gnogara profile image
Guilherme Nogara

Take a look here:

Why is this NodeJS 2x faster than native C?

12

For the sake of a presentation at work, I wanted to compare the performance of NodeJS to C. Here is what I wrote:

Node.js (for.js):

var d = 0.0,
start = new Date().getTime();

for (var i = 0; i < 100000000; i++)
{
d += i >> 1;
}

var

…






As you can find there, compiled languages can get optimized really well as they are getting compiled. The question shows that without any optimization, they have similar results in execution time, with JS/Node getting ahead even!

But the C optimized by the compiler can shave off half it's run time, leaving JavaScript and Node in the dust.

This optimization in compile time is impossible for languages that are compiled just in time (JIT) like JavaScript/Node

So, while JS/Node are not slow per se, they can't ever be as fast as compiled languages.