170 likes | 386 Views
10 -6. Software Language Levels. Machine Language (Binary) Assembly Language Assembler converts Assembly into machine High Level Languages (C, Perl, Shell) Compiled : C Interpreted : Perl, Shell. Compilation Convert Source to Object . SUM = A + B Compiles to Machine language of:
E N D
Software Language Levels • Machine Language (Binary) • Assembly Language • Assembler converts Assembly into machine • High Level Languages (C, Perl, Shell) • Compiled : C • Interpreted : Perl, Shell
CompilationConvert Source to Object • SUM = A + B • Compiles to Machine language of: LDR R1, A LDR R2, B ADD R1, R1, R2 STR R1, C
Some Terms • Source • The language program was written in • Object • The machine language equivalent of the program after compilation • Compiler • A software program that translates the source code into object code • Assembler is a special case of compiler where the source was written in Assembly language
Programming Stepsfor Compilation • Create/Edit source • Compile source • Link object modules together • Test executable • If errors, Start over • Stop
Example: Good Morning • Use text editor to create source file print.c: #include<stdio.h> int main() { printf(‘’Good Morning\n’’); return 0; }
Compilation process: • Invoke compiler on source program to generate machine language equivalent • Compiler translates source to object • Saves object output as disk file[s] • Large Systems may have many source programs • Each has to be compiled
Link object modules together • Combine them together to form executable • Take multiple object modules • LINKER then takes object module(s) and creates executables for you • Linker resolves references to other object modules • Handles calls to external libraries • Creates an executable
Interpretation • No linking • No object code generated • Source statements executed line by line
Steps in interpretation • Read a source line • Parse line • Do what the line says • Allocate space for variables • Execute arithmetic opts etc.. • Go to back to step 1 • Similar to instruction cycle
Example: Good Morning • Perl script: print.pl print ‘’Good Morning\n’’; • Shell script print.sh echo ‘Good Morning\n’;
Compilation Advantages • Faster Execution • Single file to execute • Compiler can do better diagnosis of syntax and semantic errors, since it has more info than an interpreter (Interpreter only sees one line at a time) • Compiler can optimize code
Compilation Disadvantages • Harder to debug • Takes longer to change source code, recompile and relink
Interpreter Advantages • Easier to debug • Faster development time
Interpreter disadvantages • Slower execution times • No optimization • Need all of source code available • Source code larger than executable for large systems
Some Interpretive Systems • Languages • BASIC, Perl, Lisp • OS Interfaces • C Shell, Bourne Shell • WINEXEC
Conclusion • Many different ways of developing systems • There is always a tradeoff between system development time, testing, debugging and performance, support etc.