Types of Programming Languages
What we know so far:
- We use computer programs to tell computers what to do
- Computer programs are written in languages that are translated by the computer
- Every computer program deals with data and instructions performed on the data
Programs written in compiled languages tend to be very powerful and to execute quickly. The compiler effectively converts the code into machine language so the machine can execute it directly when it runs. Compiled languages are often chosen for applications where high performance is a factor.
One drawback of compiled languages is that they will only work on the computer platform they were built for. An application written in C, once compiled on Windows, will only run on Windows. To run it on a Mac, you would have to compile the program again on a Mac.
Another drawback of compiled languages is the need to compile. Every time you make a change to the program, you have to rebuild the program in order to test it. For large programs this can become somewhat tedious and time-consuming.
As an alternative, we have interpreted languages. Interpreted languages are, in many ways, the opposite of compiled languages. Interpreted languages don’t ever need to be compiled at all. Instead, a program called an interpreter will translate the program to machine language as it is running. Essentially, with an interpreted language, you tell the interpreter to run a program, and it translates that program and runs it for you. Perl, PHP, Ruby, and Python are all examples of interpreted languages used today.
Since interpreted languages don’t have to be compiled, the turnaround between editing and testing is much quicker. However, since they are translated into machine language every time they are executed, programs written in interpreted languages do not generally perform as well as a comparable program written in a compiled language. Still, they are very popular, especially for things like web applications – many web applications are written in an interpreted language.
Another advantage of interpreted languages is that they are a bit more portable that compiled languages. As long as a Python program doesn’t perform any platform-specific tasks, that program can be executed on any platform with a Python interpreter.
So, there you have it. On the one hand, you have compiled languages, and on the other, interpreted languages, opposites of each other in many ways. As I continue this tutorial, I’m planning on teaching you to program in both C and Python, so you will get a little taste of each.