Mountain State University Systems Architecture Discussion Assignment
Discussion Compiled and Interpreted Programs
Our assignment was to compare and contrast the execution of compiled programs to interpreted programs in terms of CPU and memory utilization.
For most programming languages, there are four source code instruction types:
1. Data Declarations
Defines the name and data type of one or more program variables. When a compiler reads a data declaration, it allocates memory to store data item. The amount of memory depends on the data type and the number of bytes to represent that data type in the CPU. The compiler uses a symbol table to keep track of data names, types, and assigned memory addresses.
2. Data Operations
An instruction that updates or computes a data value. The compiler translates data operation instructions into data instructions for the CPU. The compiler refers to the symbol table to determine memory addresses for instructions.
3. Control Structure
Source code instruction that controls the execution of other source code instructions, including Goto statements, conditional branches such as if-then-else, and loops such as while-do and repeat-until. Control structures require a CPU branch instruction. Each CPU instruction is preceded by its memory address.
4. Function Calls
Programmer defines a named instruction sequence that is executed by a call instruction. The flow of control to and from functions is similar to the operating system interrupt handler.
To simplify, a compiler takes the source code and allocates different instructions into different memory addresses, and then the compiler transforms separate source code instructions into separate CPU instructions. In essence, the compiler in itself is a program running in memory that takes the source code and modifies it into CPU instructions and memory locations of such instructions.
In contrast, an interpreter source code are compiled and linked as a whole. That is to say, all source code is active in memory, line by line as it is used. This takes up a great deal more memory then that of a compiler as the instructions are only executed for a short period of time within memory.
The following table further contrasts the difference between interpretation and compilation.
|Interpreter or Compiler||Yes||no|
Source: Systems Architecture Fifth Edition Author Stephen D. Burd
Interpreted: Source Code goes directly into interpreter then outputs results.
Compiled: Source code goes to compiler and/or checker, then creates object code.
Interpreted Languages are easier to debug but do not run as fast.
Compiled languages execute much faster but are more difficult to debug. (Source: Massachusetts Institute of Technology http://www.mikestratton.net/index.php?option=com_content&view=article&id=143:intro-do-computer-science-and-programming&catid=55:mit&Itemid=130)