Thursday 25 October 2018

Why node.js has to be restart for changes to be applied?

Hi, I'm a bit confusing about how node.js handle javascript.Both Chrome and Node.js use V8, in Chrome, I can open dev tool, edit the source code, save, and then continue running with all changes applied, but why in Node.js, I have to restart the server to apply changes I made to the source code? I heard V8 engine uses JIT compiler, thus, it should be able to edit the source code, the JIT compiler only reads text it needs directly from the source code to compile to machine code during runtime, right?How a Javascript source code is compiled and interpreted? For instance I have a file named index.js like this:​function a(b) { console.log(b); }; a(10): when I runnode index.js can you tell how the compile and interpret steps happen?The source code being compiled and interpreted right when in met the function a declaration or until it met the function call a(10) ? If we don't have the a(10), is there anything being compiled?

Submitted October 25, 2018 at 02:58PM by jiendang

No comments:

Post a Comment