What Is The Different Between A Compiled And Interpreted Languages?

Compiled Code
Compiled Code.

A common question that is asked by people thinking of getting into programming is "which language should I learn?"

The answer to this question is almost impossible to answer. If you are looking to learn to program for career purposes then it is a good idea to see what everyone else is using and learn that. 

For example, in recent years a huge number of people are using either the .NET stack which involved ASP.NET, C#, JavaScript/JQuery/AngularJS.

These programming languages are all part of the Windows toolkit and whilst .NET has been made available to Linux it is not widely used.

Within the Linux world, people use Java, PHP, Python, Ruby On Rails and C. 

What Is A Compiled Language?

int main()
        printf("Hello World");

The above is a very simple example of a program written in the C programming language.

C is an example of a compiled language. In order to run the above code, I need to run it through a C compiler.

Generally, to do this I run the following command in Linux:

gcc helloworld.c -o hello

The above command turns the code from human-readable format into machine code that the computer can run natively.

"gcc" is itself a compiled program (gnu c compiler). 

A compiled program can be run simply by running the name of the program as follows:


The benefits of using a compiler to compile code is that it generally runs faster than interpreted code as it doesn't need to work it out on the fly as the application is running.


The compiled program has also been checked for errors whilst it is being compiled. If there are any commands that the compiler doesn't like then they will be reported. This will enable you to fix all coding errors before getting a fully running program.

Just because a program has compiled successfully doesn't mean that it will logically run the way you expect it to so you still need to test your application.

Rarely is anything ever perfect, however. If I have a C program compiled on my Linux computer I cannot copy that compiled program to my Windows computer and expect the executable to run.

In order to get the same C program to run on my Windows computer, I will need to compile the program again using a C compiler on a Windows computer.

What Is An Interpreted Language?

print ("hello world")

The above code is a python program which will display the words "hello world" when it is run.

To run the code I do not need to compile it first. Instead, I can simply run the following command:

python helloworld.py

The above code does not need to be compiled first but it does require that python is installed on any machine that needs to run the script.

The python interpreter takes the human readable code and turns it into something else before making it something the machine can read. All of this happens behind the scenes and as a user, all you will see are the words "hello world".

In general, it is considered that interpreted code will run more slowly than compiled code because it has to actively perform the step of turning the code into something the machine can handle on the fly as opposed to compiled code which can just run.

Whilst this might seem like a downside there are a number of reasons why interpreted languages are useful.

For one it is much easier to get a program written in python to run on Linux, Windows, and OSX. All you need to do is make sure python is installed on the computer you wish to run the script.

Another benefit is that the code is always available for reading and it can be easily changed to work the way you want it to. With compiled code, you need to find where the code is kept, change it, compile it and redeploy the program.

With interpreted code, you open the program, change it and it is ready to go.

So Which Should You Use?

I doubt your decision of programming language will be decided on whether it is a compiled language or not. 

This list might be worth looking at as it lists the 9 most popular programming languages.

Whilst some languages are clearly dying such as COBOL, Visual Basic, and ActionScript, there are others which have been on the edge of dying and have made a dramatic comeback such as JavaScript.

Generally, my advice would be that if you are using Linux you should either learn Java, Python or C and if you are using Windows learn .NET and AngularJS.

Was this page helpful?