DEV Community

Discussion on: Can we say that JS can be compiled on Node.js? [Novice Quesiton]

Collapse
 
nepeckman profile image
nepeckman • Edited

What the author is trying to say is that JavaScript is a Just In Time compiled language (abbreviated JIT). JIT compiling is the process of compiling a line of code right before executing it. When Node is handed a file to execute, its still a JavaScript file. So there is no compilation step before Node runs. However, while Node is running, the JavaScript is compiled and immediately executed after the compile. Hence, Just In Time. This is true of both Node and Browser runtimes, both use JIT compilation to run JavaScript.

While this means JavaScript does undergo a compilation step, because the compiling occurs right before execution, I don't know if I'd say "JS can be compiled on node", even though that's technically true. Most people associate compiling with outputting a compiled file to be run later (Ahead of Time, or AOT), which does not happen for JavaScript.

Hope this helps, can provide more details if you need.