Introduction to Elements of Programming
Introduction to Elements of Programming
Programming
Godfred Kusi Fosu
What is a Computer?
Compiler works on the complete program at once. It takes the entire Interpreter program works line-by-line. It takes one statement at a time as
program as input input
When an error is found, the whole program has to be re-compiled If an error is deducted there is no need to retranslate the whole program
Object code is executable without the presence of the compiler Interpreter must be present before program can run
Compiler creates an object file (code) An interpreter does not create any object file (code)
It’s difficult to correct errors in compiled programs Easy to correct errors in an interpreted programs
Compiled programs take more memory because the entire object code has Interpreter does not generate intermediate object code. As a result,
to reside in memory interpreted programs are more memory efficient.
Compiler does not allow a program to run until it is completely error-free Interpreter runs the program from first line and stops execution only if it
encounters an error.
Compiled Languages Verses Interpreted Languages
• Compiled languages are programming languages whose translation (from
high level to machine code) is typically by compilers.
• Examples are, Ada, BASIC, C, C++, COBOL, Java, Lisp, etc.
• Whereas Interpreted languages are those programming languages that
typically rely on Interpreters to translate and run directly without compiling
to machine code.
• Examples are; JavaScript, PHP, VB, Perl, Python, etc.
• Chapter Exercises
1. What is a low level programming language?
2. Outline 5 differences between compiled and interpreted languages
3. Explain translators and give three examples
4. Examine the advantages and disadvantages of both compilers and
interpreters