According to language benchmarks, JavaScript V8 is faster than other programming languages at regex-dna program. So, why node.js applications (i.e. http server) isn't faster than C applications (i.e. Nginx, Lighttpd)?
Because V8 applications are javascript applications. Even if the javascript is finally compiled to machine code the runtime characteristics are different.
For example if you call a function in an object and that object does not define the function the runtime must locate the function by traversing the prototype hierarchy, this hierarchy can change at any time during the lifetime of a program. There are clever optimizations that can be done but the overhead exists nevertheless.
There is also the memory model. Javascript is garbage collected and GC takes cpu cycles.
Because serving http requests is a different problem than regex-dna.
The fact that A is faster than B at one task doesn't say anything about what to expect from some other task.
Obligatory bad car analogy: A ham sandwich is much tastier than a porsche. Why isn't it faster from 0-60?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With