Does Node.js compile the Javascript that runs on the server?

Asked

Viewed 1,557 times

7

According to V8 documentation, it compiles Javascript for machine code, as an optimization strategy.

Thus, the Javascript that runs on the server via Node.js is compiled or interpreted?

2 answers

2

2


Because Nodejs uses the Javascript V8 engine, its code is compiled on time to bytecode V8 virtual machine. Before this compilation, it solves the imports of modules and optimizes code logic.

You can compare Nodejs to a PHP, Python, Java, or ASP.NET server: The code is optimized and compiled for an intermediate assembly language (called bytecode -- similar to the Assembly).

Remember that even if Nodejs and the other languages have access to some functions of the machine or operating system, whoever executes this compiled code is the virtual machine/interpreter of the language. That is: by default Java uses the JVM (Java Virtual Machine), PHP uses the PHP interpreter based on the Zend Engine, Python uses the Python interpreter of its distribution (Jython, Ironpython, Cpython, Pypy) and ASP.NET uses the CLR of . NET Framework.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.