Node.js (JavaScript) is a very convenient programming language but it has a drawback: It's a non-typed language.
Google V8 is a JIT (Just-in-Time) compiler that compiles JS code to native code. However, JS is non-typed language so for primitive variables, the compiled code has to look-up for variables all the times as primitive variables are stored as pointers instead of direct values.
How to solve the primitive pointer problem?
Google V8 should compile to typed binary code by automatically assign the types for variables when their values first set.
Automatic type assignment will lead to run-time error (not compile-time error) when changing the variable value to another type, but for good practice in programming, a variable should keep its type through out the programme.
With automatic type assignment, the compiled Node.js/Cython code will be as fast as C/C++. Oh mum, why hasn't Google done this?
No comments:
Post a Comment