Interpreted vs. Compiled

The process of creating a compiled program in a language such as C++ requires the developer to write the source code, determine the run-time environment for the application, compile the source code specific to that run-time application environment to create an object file but continue to resolve any compile errors (statements that do not conform to the programming rules), and link the object file with other programs or libraries needed to complete the program functionality. This creates the executable program.

Figure 1.1: Process of Compiling

However, there are some disadvantages of using a compiled language. For one, if the statements have errors, then the compiler will be prevented from creating the executable code and will require the developer to correct those errors. You might think, “Duh? That is not a disadvantage!” That is absolutely a correct assumption. However, it would be more helpful if the programming language environment assisted in correcting errors while you are testing the programming. That way you can watch what is happening while the program executes. This is all part of debugging a program.

The debugging process is when a programmer is trying to determine if the application’s execution is valid and meets all programming and logical requirements. When a developer writes programming statements, those statements have to adhere to a strict set of rules defined by the language. In a compiled environment, if you do not follow the rules then the system simply tells you that you did not follow the rules. In an interpreted environment, the system allows you to run the program and then visually inspect the erroneous statement before it is executed and dies a horrible death.

Another disadvantage of a compiled language is that often you must specify the platform or run-time environment of the compiled executable. In other words, you need to know what type of computer system will execute the application.

If the compiled language (i.e., C++, C#, etc.) is faster and, notwithstanding, if you fix all the statement errors, then why wouldn’t you want to use that type of language? Usually, an interpreted language (i.e., Python) is easier to learn and implement. You can save a lot of time on development, which in turn means you can save a lot of money because it is easier to create your application. An interpreted language like Python does not compile the statements into machine code during the application development process. Instead, the interpreter (more overhead because it is essentially another program) converts each statement line by line and executes the command created. It used to be that interpreted languages were a lot slower than compiled languages, which was a disadvantage. However, with the development of Just-In-Time (JIT) compilation, the speed gap is shrinking. Be aware, though, that the speed of an interpreted language all depends on the language selected.

The process of creating an interpreted program in a language such as Python requires the developer to write the source code, debug the program by running it and watching for any statement errors or logical flow errors, and fix those statements. Then the program is created, but it needs the Python interpreter in order to execute on any computer platform.

As you can see, an advantage of developing the application, as stated above, is that the developer can run the program and watch it execute to determine where the errors might exist. As you type in programming statements, the programming language environment will indicate which statements do not conform to the rules. Thus, you do not have to compile the program to see those mistakes. You see them immediately and can change them without having to add an extra step of compiling. This decreases development time so you can hopefully deliver the application sooner to the client, and it saves money.

Another advantage, as stated above, is that an interpreted language is very flexible in where it can be executed. You do not need to specify the environment beforehand. The interpreter that goes along with your application will handle those details, making the distribution of the application platform independent.

Figure 1.2: Process of Interpreter