Computer Language - What's the difference between compiled and interpreted language?
Tags: computerscience, interpretedlanguage, compiledlanguage
Published: 2023-08-26 17:10:00

Both types are widely used today, in different scenarios and on different environments and on sectors. But leaving this aside what's the difference between interpreted and compiled language? Both words say it for themselves, let's start with compiler.

## Compiled Computer Language

The language that read your files, compute your code and generate new files (machine level) is a compiler. 

It's done in this way so the execution of the program related to that gets much faster since it's on machine level. 

The machine is really hard for human read, so you use a high level language to generate the behaviors that you expect a program to execute and let the compiler create low level ones. 


In java for example it creates byte codes, which the Java Virtual Machine reads and executes it. 

The C++ compiles it's source into machine language code and it runs through linkers to attach the right libraries needed so you can run that executable using the loaders.

Pros:

- It rewrites your code in a lower level making it faster to run due to less operations needed, better performance overall.

- It can simplify your code to make it perform better before transforming into a lower level language.

Cons:

- Compiled code is really hard to read, so making changes on the fly straight on the file is not doable.

- If a compiled code is corrupted you will need to regenerate again.

- Debugging can be a mess if the reference points are not aligned correctly or if the source code doesn't exactly match the compiled one.

- It takes more time to deploy changes since it has to recompile changes applied, some projects require the whole system to be updated which could be a pain.

## Interpreted Computer Language

Differently from the compiler one, the interpreter is a much more straightforward approach, it reads what's on the code blocks and calls related methods that access the lower levels and execute it on the machine. 

The downside of it is that there is more operations happening, while on the compiler the behavior is already on machine level, which makes it perform less than the compiled ones.

On the bright side is much easier to make changes on the fly since is more flexible and adaptable, but this can be dangerous, would for a good and a bad scenario, so be careful with it.

Also its easier to learn using an interpreted computer language since it fails fast and allows you see the issues caused straight away.

Pros:

- Flexible and adaptable the interpreted language allows changes on the fly and quick fixes.

- Easier to learn than a compiled language since interprets right away the changes and execute it fast, making a fail fast scenario.

- Debugging is less complex than compiled ones, since what's running is what's on the code so you wouldn't see no expected behavior as happens on compiled ones when they lose reference of the code or use source code that doesn't match the compiled for example.

- Faster to deploy, there is no need to re-compile changes.

Cons:

- Slower than compiled languages since it doesn't work on lower level, causing more operations to be run when a required behavior is asked to a machine.

---

That's it! If there is anything thing else to discuss feel free to drop a comment, if I missed anything let me know so I can update accordingly. 
Until next post! :)