Part 1: High Level vs. Low Level Languages
- Many programming languages you have used are high level languages. This means that their source code is made up of semantics (e.g. words and symbols) that are easy for humans to understand and learn to write.
- Computers are electronic devices that process information using binary code (aka machine code). This is an example of a low level language.
- When a program runs, the high level code must be translated into low level code in order for the computer's hardware to process it.
๐ High Level Languages
A high level language contains human readable words and is used to create source code.
e.g Python, Java, Ruby
๐ Low Level Languages
A low level language contains machine code (such as binary). Low level language is closer to a computer's instruction set.
e.g. binary code, machine code
๐จโ๐ป Easier for humans to read and understand - contains human-oriented words / words that are closer to natural language.
๐ฃ๏ธ Before execution, must be translated to low level language in order to be executed - can take up time and resources such as memory.
๐ป The same code works on different processors (any processor must translate it into machine code before processing).
๐ก One high level command can represent multiple instructions (e.g. print() or a function).
๐ฎ In-depth knowledge of the computer's architecture (how is processes and stores information) is not needed in order to program - that's the processor's job.
๐จโ๐ป Difficult for humans to read / understand as it contains binary code. A human would have to memorise these in order to write in this language.
๐ฃ๏ธ Execution is quick as translation is not necessary: low level languages are written in the same language that the processor computes / understands.
๐ป Each low level language is written specifically for a CPU's architecture and won't work on other CPU's.
๐ One command represents one instruction. ๐ฎ Programming in low level language gives the programmer access to commands that have more control over what the CPU does and how it uses memory
Part 2: Translators
- Computers are electronic devices that process information and instructions written in binary code (aka machine code). Machine code is an example of a low level language.
- Programmers program using high level language, source code that is made up of human-based semantics (e.g. words and symbols) that is easier to read and learn.
- For a computer to run high level source code, a translator translates each high level programming statement into low level instructions that the CPU can process.
A translator turns high level source code into low level machine code. There are two types:
Interpreter
A 10-course tasting menu
1๏ธโฃ Translates one line of source code at a time
โ Does not create an executable file that can run on its own
โ๏ธ Returns the first error it finds and stops interpreting further (which is useful for debugging!)
๐ Programs run more slowly as the code is being translated at the same time as it is being executed
Compiler
A takeaway McDonald's order
โพ๏ธ Translates all source code at the same time, once
โ๏ธ Creates an executable file that can be exported/imported
๐งพ Returns a list of errors for the entire program, once, when the entire program has finished compiling
๐ Compiled code runs quickly, but the compiling process might take a long time