DEV Community

Discussion on: Is Javascript a compiled language?

Collapse
 
deanchalk profile image
Dean Chalk

Javascript is not a compiled language - period.
A Compiled language is one that when compiled it converts language code into either machine code (to run on the metal - eg c++), or bytecode (to run in a VM - eg Java / C#), and this is done 'Ahead of Time' (AOT), and you deploy the compiled code.
An interpreted language is one where the language code is compiled to machine code or bytecode at the moment of use. the language code is deployed 'as-is' and the interpreter will do the work when the app is running.

When Javascript developers talk about compiling they are really talking about something else - usually tree-shaking and minifying etc. The output of the javascript 'compile' phase is just an optimised string of Javascript code

Collapse
 
genta profile image
Fabio Russo

Thanks for replying mate.

What about that javascript "compile" phase? Just an optimised string?
Can you explain the optimization steps for me?

Collapse
 
sauloxd profile image
Saulo Furuta

I guess the optimization he is mentioning is the minify/uglify of code to reduce the user network cost to "execute"/"run" our client-side web application. In the network point of view, they are just it, a string of chars that will be evaluated in the browser JS engine.

Although I don't actually agree in the usage of "compilation" in this minify/uglify/transpile scenario, because compilation heavily implies in optimization code changes to improve the program runtime, and the steps mentioned only optimizes the network cost/developer UX.