Is it possible to compile a JavaScript program into machine code (java bytecode is not appropriate)?

    3 answers 3

    Statically no. JavaScript is too flexible language. Dynamically - any modern interpreter does just that. The first to go on this road was V8 (the engine used in Chrome and node.js).

    • 2
      Add asm.js and especially WebAssembly . - user207618
    • @Other asm.js and WebAssembly is about something else. - Pavel Mayorov
    • For? What then? - user207618
    • @Aid they are used to run programs written in other languages ​​in the browser, and not to compile js into a binary. - Pavel Mayorov
    • There is such a thing. But closer to the compilation. - user207618

    Found such a thing http://enclosejs.com ... Allows you to compile JS into an executable file. The only output is a very large file. Hello, World! weighs 22Mb.

    • one
      Vanguyu - shoved interpreter (V8?) With scripts in one basket. - user207618

    Microsoft JScript Compiler - jsc.exe is included in FrameWork.Net (It lies in c: \ Windows \ Microsoft.Net \ FrameWork \ (your version) \ jsc.exe

    Detailed Description of jsc.exe /?

    It compiles to ".exe"

    It should be noted that the DOM is missing for obvious reasons, but you have a full set of tools to work with the disk, registry and other things ...

    • There's a very old version of the language - Pavel Mayorov
    • To be precise, this is not about JavaScript, but about the JScript.NET language, Microsoft's scripting programming language, which is an implementation of the ECMAScript standard. Focused on work within the framework of the Microsoft .NET platform. Despite the similar syntax, this is a completely different language. It is more strictly typed, and compiled, rather than interpreted. With its tasks (namely, automating the administration of Microsoft Windows systems; creating ASP pages), it does a good job. (Last updated 2010) - Andrey Oleynik
    • Moreover, since it is a completely different language. - Pavel Mayorov