javascriptcompilation

Compile Javascript


Can a compiler be written that took javascript and compiled it into a fluent program, making it more efficient?

I know of just-in-time compilation, but what I'm talking about is taking the javascript and compiling it similar to the way an OS application is compiled.

Just a question for an experiment.


Solution

  • This question has been previously discussed here and here (and presumably in many other places).

    The gist of it is this:

    The answer to your question is yes and no, depending on the specific platform you want to target:

    Having said that, the issue of "compiled" v.s. "interpreted" languages often seems very much overstated. It is important to realize that there are only gradual differences on how a "binary" as a result of compilation differs from its corresponding "source code". At the end, source and binary are the same thing in different forms, or to paraphrase: it's symbols all the way down.

    *) Wikipedia has this definition of a compiler:

    A compiler is a computer program (or set of programs) that transforms source code written in a programming language (the source language) into another computer language (the target language, often having a binary form known as object code).