Compiled Language vs Scripting Language

时间:2021-04-28 04:01:31

Referrence: Blog

Compiled Languages

Example: C, C++, Java

Source code needs to be compiled into bits and bytes that can be executed by computers.

Java: source code is compiled into byte code, and run on JVM (needs "Java" operation to interprete byte code)

C/C++: source code is compiled into machine code, which is a lot more complex than byte code. Once the machine code is generated, we can execute it by "./", without any other interpreters or executables.

Scripting Languages

Example: Python, Perl, PHP, Ruby

Scripting languages do not need compilation. They rely on source code all the time.

They use interpreters to translate source code to machine executable code on the fly.

Compiled Languages vs Scripting Languages

1. Scripting language is easy to debug

For scripting language, when you finds a bug during running, you just fix the bug and reload application - there is no need to restart or recompile.

2. Performance problem

Translating on the fly can affect the application’s performance. Typically, the pre-compiled code is faster than on the fly translating.

But, good news is, there are ways to speed up scripted languages, including techniques such as code caching and persistent interpreters.