Is there a native machine code compiler for JavaScript? [closed]

Asked
Active3 hr before
Viewed126 times

5 Answers

javascriptmachineclosednative
90%

It is theoretically possible, but there will be a lot of runtime support baggage involved (and even a full Javascript compiler or interpreter to support eval).,As far as I know, there are no static compilers for JavaScript. It is certainly theoretically possible; however, a static compilation of JavaScript would need a very heavyweight runtime to support all of its features (such as dynamic typing and eval). As a small aside, when presented with the need to statically compile Python (another dynamic language), the PyPy developers ended up creating a language which was a very restricted subset of Python (called RPython), void of some of Python's more dynamic features, that was capable of being statically compiled., There are several JavaScript-to-C compilers, but they usually work with only a statically-typed subset of JavaScript. – Anderson Green Sep 15 '20 at 20:15 ,If you're asking this for the purpose of creating a standalone executable from JavaScript code, I'm sure there must be wrappers which essentially would create an executable containing your script and an embedded JavaScript VM (sadly, I don't know any offhand).

load more v
88%

Is there a native machine code compiler for JavaScript? I'm not talking about a VM. If it doesn't exist can it be done? I am wondering if it can be compiled to binary due to the dynamic nature of the language. ,If you're asking this for the purpose of creating a standalone executable from JavaScript code, I'm sure there must be wrappers which essentially would create an executable containing your script and an embedded JavaScript VM (sadly, I don't know any offhand).,Try pulling the code from the develop branch for the form validation library and see if it takes care of the issue.,It looks like this is the commit that Phil is talking about: https://github.com/EllisLab/CodeIgniter/commit/5c561805bd9ae6a4ad5d202277c34a879617b683#system/libraries/Form_validation.php

probably not by default but you should be able to assign it there:

Settings - > Editor - > Keyboard shortcuts - > Plugins - > Source code formatter(AStyle)
72%

V8 increases performance by compiling JavaScript to native machine code before executing it, versus executing bytecode or interpreting it.,EcmaScript language geeks often use the term "ES interpreter" to refer to an implementation of EcmaScript, but the spec does not use that term. The language overview in particular describes the language in interpreter-agnostic terms:,There are no static compilers for JavaScript apparently,"EcmaScript Engine" might be a better way to express the same idea.

public final void setOptimizationLevel(int optimizationLevel)
65%

We get the most benefit from the compiler if we give it all of our source code (see Compiling Multiple Scripts), which allows us to use ADVANCED optimizations:,The Closure Compiler is a tool for making JavaScript download and run faster. It is a true compiler for JavaScript. Instead of compiling from a source language to machine code, it compiles from JavaScript to better JavaScript. It parses your JavaScript, analyzes it, removes dead code and rewrites and minimizes what's left. It also checks syntax, variable references, and types, and warns about common JavaScript pitfalls., JavaScript 33.6% ,If you have multiple scripts, you should compile them all together with one compile command.

See https: //github.com/WICG/file-handling/blob/main/explainer.md

   PiperOrigin - RevId: 399113460
load more v
75%

Q. How does Dart compare with using the Closure compiler on JavaScript?,Q. How does Dart compare with CoffeeScript?,For languages that are compiled to native code: it’s important that Dart compiles efficiently to machine code, and thus it shares a number of aspects with other compiled languages.,Compare the following Closure compiler code:

// Closure compiler code

/**
 * @param {String} name
 * @return {String}
 */
makeGreeting = function(name) {
   /** @type {String} */
   var greeting = 'Hello ' + name;
   return greeting;
}
load more v

Other "javascript-machine" queries related to "Is there a native machine code compiler for JavaScript? [closed]"