?

Log in

No account? Create an account
This guy (an associate professor at the University of British… - Andrey [entries|archive|friends|userinfo]
Andrey

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

[Jan. 13th, 2018|03:34 am]
Andrey
This guy (an associate professor at the University of British Columbia) is classifying JavaScript as a compiled language:



The reason? He is arguing that an interpreted language will execute the code line by line, and if at the current line of execution a variable is used in an expression but nothing has been assigned to it (e.g. a function is called but the function assignment statement happens in the line below), the interpreter will throw an error. In contrast, in JavaScript, functions can be declared in the source code after the lines where they are called (as in the image below). He explains this by the fact that the code gets compiled before execution:



Here is what he is saying: "Now, while JavaScript was initially a strictly interpreted language, it no longer is today, because this code [points at the sample inside the frame] actually works, even though m1 has not been declared at the beginning of this program. The way this works in reality is every browser is using JIT compilation to compile JavaScript code into byte code that can then be executed by the browser's JavaScript engine."

Now, either this guy has not heard of hoisting — the rules for treatment of var and function statements in JavaScript by the runtime — or hoisting of functions and vars became possible only after the introduction on JavaScript JIT compilers. I am not sure which, but very strongly suspect that it's not the latter. In which case his argument completely falls apart.
linkReply