Andrey (azangru) wrote,

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.

  • (no subject)

    This is one other lesson that I haven't learnt in time, and that I am afraid might bite me, hard. We are using Jest, mocking module dependencies left…

  • (no subject)

    Is concurrent mode a failed promise already?

  • (no subject)

    I've never watched a long conversation with Jay Bhattacharya before — only his occasional quick appearances on mainstream news. This conversation…

  • Post a new comment


    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.