You have probably heard the terms “JavaScript engine” and “JavaScript runtime” used interchangeably to mean “a program that runs JavaScript.

What's the difference between JavaScript engines and JavaScript runtimes? - Human Who Codes

submited by
Style Pass
2024-04-19 03:00:03

You have probably heard the terms “JavaScript engine” and “JavaScript runtime” used interchangeably to mean “a program that runs JavaScript.” These are often intermixed by referencing V8, Node.js, or some other combination of related programs. However, there is a significant difference between a JavaScript engine and a JavaScript runtime in terms of scope and functionality. Understanding this difference is key to a good understanding of the JavaScript language as a whole.

Before discussing what an engine is vs. a runtime, though, it helps to define a couple of terms that are often used in conjunction with both engine and runtime: ECMAScript and JavaScript.

In 1996, Netscape and Sun Microsystems approached Ecma International, a nonprofit standards organization, about standardizing JavaScript. The result of that effort, released in 1997, was ECMA-262, the specification that defines how a JavaScript implementation should work. With Sun unwilling to donate the JavaScript trademark,1 the specification had to have a different name, and so ECMA-262 was titled, “ECMAScript Language Specification.” ECMAScript, therefore, is the name of the language specified in ECMA-262.

ECMAScript defines the core functionality of JavaScript that must be implemented by conforming implementations regardless of where they are embedded (a program that embeds an implementation is called a host). Even at this early stage, Netscape intended to use JavaScript not just in the browser, but also on the server, and ECMAScript was to serve as the core for both implementations. As such, ECMAScript does not contain any web-related functionality nor any way to input or output data (such functionality must be provided by the host). That means ECMAScript contains, for example, standard global classes such as Object, Array, and Promise, but does not contain HTMLElement, setTimeout, or fetch().

Leave a Comment