Programming languages, translators and IDEs
Languages and translators
- People write programs in a programming language; the CPU runs machine code.
- Languages are high-level or low-level.
- A translator converts a program to machine code — and an IDE helps you write it.
High-level vs low-level
- A high-level language (e.g. Python) reads like English — easy to write/fix and portable (runs on different computers).
- A low-level language is close to the hardware: machine code (binary, run directly by the CPU) and assembly language (mnemonics for machine code).
- Low-level code is CPU-specific — used when you need full hardware control or very fast, small code.
Practice
A high-level language (like Python):
High-level languages are easy to read/write and portable; low-level languages are CPU-specific.
Practice
Machine code is:
Machine code is binary instructions the CPU executes directly; assembly is its mnemonic form.
Compiler vs interpreter
| Compiler | Interpreter | |
|---|---|---|
| Translates | the whole program at once | one line at a time |
| Errors | all reported at the end | stops at the first error |
| Finished program | runs fast, no translator needed | slower, needs the interpreter |
- Use a compiler to share a fast finished program; an interpreter while writing and testing.
Practice
A compiler:
A compiler translates everything once into a fast stand-alone program; an interpreter goes line by line.
Practice
An advantage of an interpreter when testing is that it:
Stopping at the first error makes debugging easier — handy while writing a program.
Integrated development environment (IDE)
- An IDE puts the tools to write programs in one place:
- a code editor, a run-time environment, a translator, error diagnostics, auto-completion/correction, and prettyprinting (neat colour + indentation).
Practice
Which is a feature of an IDE?
An IDE bundles an editor, translator, run-time, diagnostics, auto-complete and prettyprinting.
You've got it
Key idea
- high-level = English-like, portable; low-level = machine code (binary) / assembly, CPU-specific
- a translator turns code into machine code; compiler (whole program at once) vs interpreter (line by line)
- compiler → fast finished program; interpreter → easy testing
- an IDE bundles editor, translator, diagnostics, auto-complete and prettyprinting