Subtopic Notes
5.2 Language Translators
5. System Software
High Level Languages
- Advantages
- Close to English/native/human language
- Easier/faster to correct errors/read/write
- Much easier to debug
- Debug at the development stage
- Portable: Works on many different machines/operating systems (not machine-specific, portable)
- Disadvantages
- Programs can be larger
- Program can take longer to execute
- Program may not make use of special hardware
- Example: C, Python, Java, Pascal etc.
Low Level Languages
- Relate to the specific architecture and hardware of a particular type of computer.
- Can refer to machine code, the binary instructions that a computer understands, or an assembly language that needs to be translated into machine code.
- Benefits:
- Work directly on registers/CPU/ can address memory addresses directly
- More control over what happens in computer
- Can use machine specific functions
- Code requires less storage/RAM
- Runs faster.
- Disadvantage:
- Takes longer to write or debug
- Difficult to understand
- Not Portable
Assembly Languages
- Low-level programming language that is closely related to machine code but is more human-readable.
- Uses mnemonic codes and symbols instead of binary instructions
- Advantages:
- Can make use of special hardware
- Use special machine-dependent instructions
- Doesn’t take up much space in primary memory
- Code performs task relatively quickly
Translators
| Compiler | Interpreter | Assembler |
|---|---|---|
| Translates a high-level language to machine code | Executes a high-level language one statement at a time | Translates low-level assembly language into machine code. |
| An executable file produced | No executable file produced | An executable file produced. |
| A single high-level language statement may correspond to multiple machine code instructions. | Each statement in assembly language is translated into one machine code instruction. | |
| Compiler not required to run compiled programs | Interpreted programs cannot be run without the interpreter | Assembler not required to run assembled program |
| Usually used while distributing program | Used during production stage | Assembled programs are released for general use |
Compiler
| Advantages | Disadvantages |
|---|---|
| Creates an executable file so the code can be tested multiple times without having to recompile so repeated testing takes less time | Larger amounts of source code take time to compile |
| Compiled programs are run without the compiler | Slower to produce the object code than an interpreter |
| Optimize code for better performance and efficiency | Code cannot be changed without recompilation |
| No Dependency on Source Code | The program will not run if there are any errors |
| More secured as codebase not available for users | Errors cannot be corrected in real-time; Harder to test and debug |
| One error may result in other false errors being reported |
Interpreter
| Advantages | Disadvantages |
|---|---|
| Easier to debug the program because it translates line-by-line and stops when an error is found | Stops execution at first error, which can slow down debugging for large programs. |
| Allows error to be fixed in real time | Program can’t run without interpreter |
| Program can restart at same point when error occurs and refixed | The source code must be available for execution, making it less secured |
| Effect of changing code seen immediately | |
| A partially completed program can be translated / tested on its own |
Two-step translation
- Some high-level programming languages, such as Java, require a two-step translation process, involving both compilation and interpretation.
- Partially compiled programs can be used on different platforms as they are interpreted when run.
- Code is optimized for the CPU as machine code is generated at run time
- Two-step translation in Java
- Compilation: Java source code is first converted into an intermediate form called bytecode by the Java compiler.
- Interpretation: The Java Virtual Machine (JVM) then interprets the bytecode, translating it into machine code for execution on the target system.
IDE (Integrated development environments)
- Software application that helps programmers develop software code efficiently.
- Features
- Code editors
- Run-time Environment
- Translator
- Auto completion
- Context-Sensitive Prompts: Displays relevant options, such as available functions and variables
- Auto correct
- Presentation
- Prettyprint: Enhances readability by applying automatic indentation and syntax highlighting.
- Expand and Collapse code blocks: Allows sections of code to be minimized, making navigation easier and reducing excessive scrolling.
- Error diagnostics
- Debugging Tools:
- Single stepping: Executes code one line at a time to observe its impact on variables
- Breakpoints: Halts execution at a specific line to check the program's behavior up to that point
- Variables/expressions Report Window: Displays and tracks variable values for comparison.
- Initial Error Detection
- Dynamic syntax checks: Highlights syntax errors immediately as they are typed.
- Type checking & parameter checking
