Sitemap
Press enter or click to view image in full size

Compiled vs. Interpreted

--

What is the difference between compilation and interpretation with regard to programming languages. Compilation and interpretation are carried by software programs known as compilers and interpreters.

What does a compiler do ?

A compiler converts source code into executable machine code. The executable depends on the OS because each OS has a specific binary format it understands how to load and run. Therefore each operating system (+ CPU architecture) should have its own executable.

What does a interpreter do ?

An interpreter executes the source code as part of its process. Therefore wherever you want to run the code, the interpreter must be present.

The difference in simple terms…

The end result of compilation is an executable file which is the binary version of your source code. What interpretation does is, the interpreter starts running and it takes the source code as an argument and executes it.

Basically, if you are a piece of source code, a compiler would be a swimming instructor who teaches you how to swim. After teaching (compiling), you can swim by yourself.

On the other hand an interpreter would be an instructor who physically moves you and carries you around in water (interpreting). Without that instructor you would not be able to swim.

The above analogy might make it sound like interpreted languages are weaker, which is not necessarily true. Both types have their own pros and cons,

Get Kenula Nimhan’s stories in your inbox

Join Medium for free to get updates from this writer.

Pros of compilation

  • Ready to run
  • Often faster execution
  • Source code is private

Cons of compilation

  • Requires re-compilation for each platform
  • Less flexibility at runtime
  • Additional build setup

Pros of interpretation

  • Source code is portable across platforms with an interpreter
  • Faster development and testing
  • Easier debugging and introspection

Cons of interpretation

  • Interpreter must be installed
  • Performance can be slower (though jit reduces this gap)
  • Source code is often distributed with the program

Conclusion

As you can see both of these technologies exist in order to execute the code written using high-level programming languages, and both have its own advantages and disadvantages.

In todays world it is difficult to categorize programming languages on whether they are compiled or interpreted because most languages have evolved to use a hybrid approach, which strives to combine the pros of both technologies.

References

Video By Coding Mentors:

A more advance explanation by Core Dumped:
https://www.youtube.com/watch?v=RnBOOF502p0&t=1097s

IBM Article,

https://www.ibm.com/think/topics/compiler

--

--

Kenula Nimhan
Kenula Nimhan

Written by Kenula Nimhan

0 followers

Software Engineering Undergraduate from Sri Lanka. Portfolio: kenula.dev