You are on page 1of 3

Integrative Programming and Technologies 1

1
Compiled vs. Interpreted Languages

Module 02 Compiled vs. Interpreted Languages

Course Learning Outcomes:


1. Distinguish between families of languages
(imperative, OO, functional, declarative) and within families
(dynamically typed vs statically typed, call by name vs call by value, etc)
2. Use diverse programming language primitives for concurrency.

Background

When writing programs in a high level language, the computer will not be able to understand
it. So that it will be usable, you need to convert it into something that a computer understands. This is
where compilers and interpreters come in as they both do the same function – convert a high level
language (like C, Java) instructions into the binary form which is understandable by computer
hardware.

They are the software used to execute the high level programs and codes to perform various
tasks. Specific compilers/interpreters are designed for different high level languages. However both
compiler and interpreter have the same objective but they differ in the way they accomplish their task

Programming languages can be divided into two major categories: low level and high level.
“Assembly language” and “machine language” are called low-level languages because they more than
others “speak” the language the computer understands. On the other hand, C, C++, Pascal, Python,
Visual Basic, Java, and COBOL are high-level languages because they require more manipulation by
the computer, a process called compiling.

An interpreter:
 Reads the source code one instruction or line at a time, converts this line into machine code
and executes it. The machine code is then discarded and the next line is read. Executing each
line as it is "translated," much the way a foreign language interpreter would translate a book,
by translating one line at a time.

 The interpreter takes one statement then translates it and executes it and then takes another
statement.
 Interpreter stops translating after the first error.

Course Module
Integrative Programming and Technologies 1
2
Compiled vs. Interpreted Languages

High Level/ Low Level

A compiler can be compared to taking a foreign movie and first sub-titling it and then being able to
watch it again and again.
While an interpreter is like having a translator at the UN translate each line of a delegate’s speech in
real time.

Advantages of Compiled Languages


 Pre-Compiled binaries are inherently more difficult to reverse-engineer and are therefore
helpful to closed-source software providers wishing to keep the I.P. contained in their source
code private.
 Once a program is translated into native instructions (machine code), it can then be executed
over and over again without the overhead of this translation.
 Ability to support architectures the interpreter hasn't been compiled for (such as embedded
systems)
 Can be optimized more heavily due to larger window of code to be translated.

Course Module
Integrative Programming and Technologies 1
3
Compiled vs. Interpreted Languages

Advantages of Interpreted Languages


 Programs can immediately be executed without the requirement of compiling first.
 Potentially has lower memory footprint because no Object Code is created.
 Supports portability if interpreter is installed on different platforms.
 Starts executing immediately (no compilation phase)
 Source Code can be more easily changed between program executions because there is no
compilation step in between.

Hybrid Approach
An interpretive compiler combines fast translation with moderately fast execution, provided that:

● VM code is lower than the source language, but higher than native machine code
● VM instructions have simple formats (can be quickly analyzed by an interpreter)

Example: JDK provides an interpretive compiler for Java.

References and Supplementary Materials


Books and Journals
1. Scott, Michael L.. (2009). Programming Languages Pragmatics (2nd edition) Elsevier Inc.
2. Johnson, Richard. (2017). An Introduction to Java Programming and Object-Oriented
Application Development, 1st Edition. Cengage Learning

Online Supplementary Reading Materials


1. https://docentes.fct.unl.pt/sites/default/files/jrcs/files/ln01-overview.pdf
2. https://www.pearsonhighered.com/assets/samplechapter/0/3/2/1/0321537114.pdf

Online Instructional Videos


1. Short video: Compilation vs. Interpretation
https://www.youtube.com/watch?v=JNMy969SjyU

Course Module

You might also like