High-Level Language: A high-level language is a programming language that allows developers to write powerful and complex programs using code that is easy for humans to read and write.
- Key Characteristics of High-Level Languages
-
- Easier to Use and Understand: Uses English-like words and logical structures (e.g., if, while, print)
- Abstracts Away Hardware Details: You don’t need to know how the CPU or memory works
- Fewer Instructions Needed: A single line of high-level code can represent dozens or hundreds of machine instructions
1.9.1. Compilers and Interpreters
- To run a high-level program, it must be translated into machine language using a compiler or interpreter
1.9.2. Compiler: Translation Before Execution
- A compiler is a special program that translates an entire high-level program into machine language before the program is run.
- The result is a separate machine language file (called an executable), which can then be run any time without needing the original source code or the compiler.
- Key Features:
- Fast execution after compilation, Error checking happens before running, Produces a standalone file
- Example: Languages that use a compiler
- C, C++, Java (compiled to bytecode), etc.
1.9.3. Interpreter: Translation During Execution
- An interpreter translates and runs the high-level program one instruction at a time.
- It does not produce a separate machine language file.
- Every time you run the program, the interpreter must reprocess the source code.
- Key Features:
- Easier to test and debug during development
- Slower execution compared to compiled programs
- No need for a separate compilation step
- Example: Languages that use an interpreter
- Python, JavaScript, Ruby, etc.
1.9.3. Compling vs. Interpreting
- Once program is compiled, it can be executed over and over without the source code or compiler.
- If it is interpreted, the source code and interpreter are needed each time the program runs