Com 212 intro to system programming book Theory



Download 0.65 Mb.
View original pdf
Page36/72
Date13.05.2021
Size0.65 Mb.
#56617
1   ...   32   33   34   35   36   37   38   39   ...   72
com-212-introduction-to-system-programming-theory
9833 SS1 FISHERY LESSON NOTE









































Page | 40
WEEK SEVEN
Learning Outcome for this week The meaning of translation and compilation The types of compiler The stages compilation

TEACHER’S ACTIVITIES

Define interpretation, translation and compilation Differentiate between interpretation translation and compilation Describe various types of compilers Describe types of tables generated in the process of compilation Explain code generation and optimization Describe error handling
THE INTERPRETER
In computer science, an interpreter normally means a computer program that executes, i.e.
performs, instructions written in a programming language. While interpretation and compilation are the two principal means by which programming languages are implemented, these are not fully distinct categories, one of the reasons being that most interpreting systems also perform some translation work, just like compilers.
An interpreter maybe a program that either Executes the source code directly Translates source code into some efficient intermediate representation (code) and immediately executes this Explicitly executes stored precompiled code made by a compiler which is part of the interpreter system Perl, Python, MATLAB, and Ruby are examples of type 2, while UCSD, Pascal and Java are type 3: Source programs are compiled ahead of time and stored as machine independent code, which is then linked at run-time and executed by an interpreter and/or compiler (for JIT systems. Some systems, such as Smalltalk, and others, may also combine 2 and 3. The terms interpreted language or compiled language merely mean that the canonical implementation of that language is an interpreter or a compiler a high level language is basically an abstraction which is (ideally) independent of particular implementations.

Page | 41 EFFICIENCY, ADVANTAGES AND DISADVANTAGES
The main disadvantage of interpreters is that when a program is interpreted, it typically runs slower than if it had been compiled. The difference in speeds could be tiny or great often an order of magnitude and sometimes more. It generally takes longer to run a program under an interpreter than to run the compiled code but it can take less time to interpret it than the total time required to compile and run it. This is especially important when prototyping and testing code when an edit-interpret-debug cycle can often be much shorter than an edit-compile-run-debug cycle. Interpreting code is slower than running the compiled code because the interpreter must analyze each statement in the program each time it is executed and then perform the desired action, whereas the compiled code just performs the action within a fixed context determined by the compilation. This run-time analysis is known as "interpretive overhead. Access to variables is also slower in an interpreter because the mapping of identifiers to storage locations must be done repeatedly at run-time rather than at compile time. There are various compromises between the development speed when using an interpreter and the execution speed when using a compiler. Some systems (e.g., some LISPs) allow interpreted and compiled code to call each other and to share variables. This means that once a routine has been tested and debugged under the interpreter it can be compiled and thus benefit from faster execution while other routines are being developed. Many interpreters do not execute the source code as it stands but convert it into some more compact internal form. For example, some BASIC interpreters replace keywords with single byte tokens which can be used to find the instruction in a jump table. An interpreter might well use the same lexical analyzer and parser as the compiler and then interpret the resulting abstract syntax tree.

Download 0.65 Mb.

Share with your friends:
1   ...   32   33   34   35   36   37   38   39   ...   72




The database is protected by copyright ©ininet.org 2024
send message

    Main page