New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about the compiler #227

Closed
italoacasas opened this Issue Dec 2, 2015 · 2 comments

Comments

Projects
None yet
4 participants
@italoacasas

italoacasas commented Dec 2, 2015

Hi Guys, I'know maybe this it is not the correct place tu put this question but I don't find a good place anywhere.

Why JavaScript is not a interpreter language?
Why JavaScript is a "compiler" language?

@getify

This comment has been minimized.

Show comment
Hide comment
@getify

getify Dec 2, 2015

Contributor

This is not really a support forum, but briefly...

JS has to be processed (aka "compiled") first before execution because some of the language mechanics require early errors (that is, compile-time errors) if certain conditions are found in the code, such as:

"use strict";
function foo( x, x ) { .. }  // duplicate param name not allowed in strict mode

Some syntax errors technically could be caught if the code only went through a quick tokenization scan (not full parsing/compilation), but other situations like that one above require actually understanding the structure of the program to know if something is valid or not.

Contributor

getify commented Dec 2, 2015

This is not really a support forum, but briefly...

JS has to be processed (aka "compiled") first before execution because some of the language mechanics require early errors (that is, compile-time errors) if certain conditions are found in the code, such as:

"use strict";
function foo( x, x ) { .. }  // duplicate param name not allowed in strict mode

Some syntax errors technically could be caught if the code only went through a quick tokenization scan (not full parsing/compilation), but other situations like that one above require actually understanding the structure of the program to know if something is valid or not.

@ljharb

This comment has been minimized.

Show comment
Hide comment
@ljharb

ljharb Dec 2, 2015

Member

The words "compiled" and "interpreted" technically refer to implementations, and as such, every single language could be compiled or interpreted.

However, the way they're most commonly used, I would classify JS as an interpreted language (not compiled), and C++ as a compiled language, for example.

It really just depends on how pedantic you want to be about the definitions - if you stick with the most precise definition, no language is either, only an implementation is one or the other.

Member

ljharb commented Dec 2, 2015

The words "compiled" and "interpreted" technically refer to implementations, and as such, every single language could be compiled or interpreted.

However, the way they're most commonly used, I would classify JS as an interpreted language (not compiled), and C++ as a compiled language, for example.

It really just depends on how pedantic you want to be about the definitions - if you stick with the most precise definition, no language is either, only an implementation is one or the other.

@bterlson bterlson closed this Dec 2, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment