The Polyglot’s Dilemma
At this juncture in my career, I decided in the new year that I want to pick up another programming language — unfortunately there are hundreds of languages to choose from. Even from the popular ones in use today there are still several dozen options; there is no right or wrong answer. Instead, to paraphrase from a popular adage: Use the right tool for the right job. So to help narrow down our options, lets break down the two different kinds of programming languages and their advantages/disadvantages.
One of our two main camps is the Compiled language. In this form, a compiler converts our human-readable source code into binary machine code. Distributing this code to run on other systems means we compile our code and then send out the binary executable machine code for another system to run. During this process, it is important to note that the entire program’s source code is converted first and executed together when received and thus the only way to execute/test our code is to compile it.
- Compiling a program is always going to be faster than interpreted.
- Your source code is private — unlike with interpreted and distributed code where anyone can view the source code and see what goes on under the hood.
- You would have to recompile programs for different platforms (i.e. Windows, Mac, Linux). In short, compiled languages are not cross-platform compatible and thus rather inflexible.
- Every time you want to run a program to debug it, assess runtime attributes, etc., you need to compile it. This can be tedious and time-consuming for larger programs. Thus while it absolutely will execute faster than interpreted code, it may take longer to develop.
Common Compiled Languages: C, C++, Objective-C
On the other hand, we have our Interpreted languages. In an Interpreted coding language, we actually distribute our source code itself and an interpreter program is used with the receiving system to run the source code on that specific system. It is an important distinction to make that when an interpreted program is received, each line converted to machine code and executed one line at a time by the interpreter. Remember that with Compiled code our process went from source code → compiler → machine code → execute; with Interpreted code our process is now source code → interpreter → output. Because of this staggered evaluation and execution, our Interpreted code is always slower to execute.
- As stated before, it is slower in comparison to compiled code due to this extra step of having an interpreter run line by line.
- Also stated before, our distributed source code is public and readable to humans.
- Interpreted programs are cross-platform, meaning we only need to write and one version of our code and let the machine receiving it with an interpreter do the rest.
- We also do not have the extra step of compiling during development — meaning that developing and debugging our programs are not as tedious or time-consuming.
Some interpreted languages, such as Java and C#, use what’s known as an intermediate language (IL) or bytecode and a Just-in-Time Compiler (JiT). This means that a developer converts their source code into bytecode and distributes the bytecode to the consumer. This means we do not publicly reveal our source code. Additionally, bytecode is optimized for conversion into machine code by the JiT compiler and be optimized even further, thus decreasing the time it takes to convert and execute.