Re:Hard-won lessons: Five years with Node.js
by lostboys67 on Thursday April 20, 2017 @08:41AM
(#14156095)
"but a compiler does not by definition have to compile your code before deployment" Huh?
Not sure many experienced developers would agree with you a JIT Compiler is quite different to a real compiled language C Fortran Etc
Re:Hard-won lessons: Five years with Node.js
by beaconstudios on Thursday April 20, 2017 @09:27AM
(#14156392)
a compiled language, yes. But the function of a compiler, between a compiled language and an interpreted language, remains the same. It translates code from one representation to another.
Re:Hard-won lessons: Five years with Node.js
by josteink on Thursday April 20, 2017 @10:26AM
(#14156901)
This is really simple. Do you use V8 to compile your code or to run it?
Just because V8 has a compiler, doesn't make it a compiler. Do you see the difference?
Re:Hard-won lessons: Five years with Node.js
by beaconstudios on Thursday April 20, 2017 @10:48AM
(#14157125)
V8 compiles code into bytecode and runs that. This is really simple.
V8 is a JIT compiler. It both compiles code and runs it. For your original complaint about not being able to compile JS up front, you're talking about Ahead-Of-Time (AOT) compilation. You don't seem very familiar with the relevant terminology.
In fact, I just looked it up and apparently V8 compiles JS directly to machine code rather than bytecode: https://en.wikipedia.org/wiki/Chrome_V8.
No, what I meant is that the concept of a JIT compiler incorporates both a runtime and a compiler.
> Seriously though: Can I tell V8 to compile my JS and tell me any errors found before I deploy it to production and runtime? Yes or no?
That's not the job of a compiler. It's a feature of compilation, but a compiler does not by definition have to compile your code before deployment. What would you be compiling the JS to? If you're wanting to check your syntax, your IDE should be able to do that, or you can use a compile-to-JS language like TypeScript. Yes, it's dumb I know - that's one of the many reasons I use TypeScript.
> Just because V8 internally JIT-compiles the JS-code to something eventually executable which the machine can run doesn't change the fact that it's interpreter and execution-engine (also known as a "runtime") for Javascript code.
You seem to be hung up on the idea of a compiler as something that checks your code is correct. It isn't - that functionality is incidental to the compiler's job, because it can't translate invalid syntax into whatever destination language it compiles to.
> Just like Python and all those other platforms you listed as not being "compilers" (in which case you're absolutely right).
I did no such thing. That was someone else. Any language which internally uses a bytecode representation is a JIT compiler, including Python, Java, and PHP. You could argue I'm being nitpicky, given that pretty much all performant interpreted languages use a bytecode representation - it's true in a sense, but I'm just trying to highlight that you seem to have a misunderstanding of what a compiler's job is.