4 ms·
The difference is that JavaScript is an interpreted language, rather than a compiled language. Interpreted languages are distributed as source code, and an in
by evan_ 5y ago
The difference is that JavaScript is an interpreted language, rather than a compiled language.
Interpreted languages are distributed as source code, and an interpreter evaluates each line of code to transform it into machine language for execution on the CPU. This allows the same code to run on any CPU for which an interpreter is available.
Compiled language source is transformed into machine language once, at compile time, using a compiler that understands how to turn the source code into machine language for a given environment. Once it's been compiled it generally will only work on the CPU/OS for which it was compiled. If you're going to distribute the work, you will have to compile many different versions.
There are volumes written on the differences and advantages of each method. JavaScript was created as an interpreted language so that developers could write code which can be executed on any browser with a JavaScript interpreter- important for a language that is used on web pages which can be viewed on a very wide variety of devices and machine architectures.
https://en.wikipedia.org/wiki/Interpreter_(computing) https://en.wikipedia.org/wiki/Interpreter_(computing)
- heavyset_go 5y agoInterpreted languages don't necessarily have to be distributed as source code, as a few of them support being compiled into byte code, which can then be distributed and interpreted.
- stewbrew 5y agoThere is no such thing like an interpreted/compiled language - even with some kind of eval functionality. It's implementations that work as interpreters or compilers. Also, a compiler doesn't necessarily emit machine code. It could also emit byte code that is later on intepreted or compiled to something else.
- encryptluks2 5y agoSo computer science is wrong and you are right?
- chrisseaton 5y agoNo they're right - languages can be implemented with an interpreter or with a compiler or with something in between. Some require at least something in between as they have dynamic code execution. Saying 'interpreted language' is just short for 'a language that is usually interpreted'.
- encryptluks2 5y agoBut the difference between compiled vs interpreted languages is correct as stated.
- chrisseaton 5y agoThe point is no language is inherently compiled - people just choose to compile it. Any language that can be compiled can also be interpreted.
- stewbrew 5y agoNo. The language per se is neither interpreted nor compiled.
- stewbrew 5y agoIt's a shortcut that often isn't really useful. Also the statement about compiled languages is wrong the way it's written. The OP states: 1. Interpreted language (whatever that is) are necessarily distributed as source code and an interpreter evaluates the source code line by line. 2. Compiled languages (whatever that is) are not distributed as source code and they are necessarily transformed to machine code. Both statements are wrong as they are.