high level & low level language high level programming languages are more structured, are closer...
TRANSCRIPT
High level & Low level language
• High level programming languages are more structured, are closer to spoken language and are more intuitive than low level languages. •Higher level languages are also easier to read and can typically sometimes work on many different computer operating systems. •Some examples of higher level languages are Java, Visual Basic, COBOL, BASIC, C++, and Pascal to name only a few. •Lower level languages are typically assembly languages that are machine specific.
•Typically, in low level languages, you write 1 instruction, and it generates 1 machine instruction. low level languages are typically assembly language•High level languages, you write 1 instruction, and it generates a series of machine instructions. •In a high level language, you think about the problem, and write instructions to solve it.•In a low level language, you think of the problem, and you have to write the instructions to have the computer solve your problem.
• In general, it requires more skill to be able to do the same problem in a low level language than in a high level language. AND, if there is a problem with a program, it's usually far more easy to fix a high level language program than a low level language program.
• A processor operates using binary codes, which are difficult for programmers to use in programming. Therefore, a low level language, such as assembly, is one where the text instructions are essentially translated 1:1 into binary.
• In a high level language, like C or Pascal, each instruction represents several assembly instructions and must be translated into assembly and the assembly then is translated into binary.
COMPILER
• A compiler is a computer program (or set of programs) that transforms source code written in a programming language (the source language) into another computer language (the target language, often having a binary form known as object code). The most common reason for wanting to transform source code is to create an executable program.
CS 540 Spring 2009 GMU 6
What is a compiler?
A program that reads a program written in one language and translates it into another language.
Source language Target language
Traditionally, compilers go from high-level languages to low-level languages.
“Advanced Compiler Techniques”Fall 2009
What is a Compiler?• A program that translates a program in one language
to another language– The essential interface between applications &
architectures• Typically lowers the level of abstraction– analyzes and reasons about the program & architecture
• We expect the program to be optimized, i.e., better than the original– ideally exploiting architectural strengths and hiding
weaknesses
Interpreter
• An interpreter is program that translates the higher level language code into equivalent machine level code and the execution is done line by line.
• An interpreter translates high-level instructions into an intermediate form, which it then executes. IN Contrast a compiler translates high level instructions directly into machine language.
• Compiled program generally run fast than interpreted programs.
• The advantage of interpreter is that it does not need to go through the compilation stage during which machine instruction genrates.
“Advanced Compiler Techniques”Fall 2009
Compiler vs. Interpreter
• Compilers: Translate a source (human-writable) program to an executable (machine-readable) program
• Interpreters: Convert a source program and execute it at the same time.
“Advanced Compiler Techniques”Fall 2009
Compiler vs. Interpreter (2/5)
Ideal concept:
Compiler
Executable
Source code Executable
Input data Output data
Interpreter
Source code
Input dataOutput data
“Advanced Compiler Techniques”Fall 2009
Compiler vs. Interpreter (3/5)
• Most languages are usually thought of as using either one or the other:– Compilers: FORTRAN, COBOL, C, C++, Pascal, PL/1– Interpreters: Lisp, scheme, BASIC, APL, Perl,
Python, Smalltalk• BUT: not always implemented this way– Virtual Machines (e.g., Java)– Linking of executables at runtime– JIT (Just-in-time) compiling
“Advanced Compiler Techniques”Fall 2009
Compiler vs. Interpreter (4/5)
• Actually, no sharp boundary between them. General situation is a combo:
Translator
Virtual machine
Source code Intermed. code
Intermed. code
Input DataOutput
“Advanced Compiler Techniques”Fall 2009
Compiler vs. Interpreter (5/5)
Compiler• Pros
– Less space– Fast execution
• Cons– Slow processing
• Partly Solved(Separate compilation)
– Debugging• Improved thru IDEs
Interpreter• Pros
– Easy debugging– Fast Development
• Cons– Not for large projects
• Exceptions: Perl, Python– Requires more space– Slower execution
• Interpreter in memory all the time
Assembler
• An assembler is a program that translates symbolic code (assembly language) into executable object code.
16
Language LevelsHigh Level Language
Assembler Language
Machine Language
Micro -programming
Hardware
„Firmware“
Normally deepest free accessible Level
Chap 2
Role of Assembler
Source
Program Assembler
Object
Code
Loader
Executable Code
Linker
Characteristics of good Algorithm• An algorithm is written in simple English and is not a formal document. An
algorithm must:
- be lucid, precise and unambiguous - give the correct solution in all cases - eventually end
1) Finiteness: - an algorithm terminates after a finite numbers of steps.• 2) Definiteness: - each step in algorithm is unambiguous. This means that the
action specified by the step cannot be interpreted (explain the meaning of) in multiple ways & can be performed without any confusion.
• 3) Input:- an algorithm accepts zero or more inputs• 4) Output:- it produces at least one output.• 5) Effectiveness:- it consists of basic instructions that are realizable. This means
that the instructions can be performed by using the given inputs in a finite amount of time.