Computers only understand binary, streams of 1's and 0's.
Just about impossible for us humans to work in machine code.
Adding two numbers together in machine code, might be:
49 00 FE 49 00 FF 91 00 22 F1 00 FA D1 00 FE 91 00 22 71 00 FA A1 00 20 F1 00 1F 51 00 1F 00
To make things easier for programmers assembly language was created.
Assembly language uses basic abbreviations to hide some of the machine code.
Machine code and assembly language are the only low-level languages.
In computing we use the word abstraction to mean hide complex or unnecessary information.
All other languages than machine code and assembly language are high-level languages.
High level languages all have the following characteristics:
All languages, other than machine code and assembly language, are high-level languages.
Assembly Code
Machine Code
High Level Languages
Machine Code
Assembler
Compiler or Interpreter
An assembler converts assembly language into machine code.
Typically, each different type of processor uses a different assembly language and a different assembler.
A compiler translates a program written in a high-level language into machine code.
A program written and compiled on one type of computer would have to be compiled again to run on a computer with a different type of processor.
Code written by the programmer is called source code.
Machine code produced by the compiler is called object code.
An interpreter is also used to translate high-level language source code into machine code.
The interpreter translates each line of code, line by line into machine code.
Long, complex programs can be slow to execute (run) using a interpreter.
Some systems have a half-way stage (bytecode) to reduce the execute time.
The interpreter must be on the computer that is running the code.
Compiler | Interpreter |
---|---|
Translates the whole program to produce the executable object code. | Translates and executes one line at a time. |
Complied program executes faster as it is already in machine code. | Interpreted programs take more time to execute because each instruction is translated before it is executed. |
Customers do not need to have the compiler installed on their computer to run the software. | Customers must have the interpreter installed on their computer and they can see the source code. |
Customers cannot see the actual source code when you distribute the program. | Customers can see the source code and could copy it. |
Used for software that will be run frequently or copyright software sold to a third party. | Used for program development and when programs must run on multiple hardware platforms. |
High level language is hardware independent
Machine code is binary code
The compiler/interpreter converts the source code into binary, object code.
Compiler