Types of Programming Languages, Translators and Integrated Development Environments (IDEs) (Copy)
1. High-Level Languages vs Low-Level Languages
High-Level Languages (HLL)
- Definition:
- Programming languages that are closer to human language and further from machine code.
- Examples: Python, Java, C++, JavaScript.
- Features:
- Written using English-like keywords and syntax.
- Must be translated into machine code for execution.
- Advantages:
- Easier to read, write, and understand for humans.
- Easier to debug and maintain.
- Portable across different computer systems (machine-independent).
- Large standard libraries and built-in functions.
- Disadvantages:
- Requires a translator (compiler or interpreter) to run.
- May be slower in execution compared to low-level code due to abstraction.
- Less control over hardware resources compared to low-level languages.
Low-Level Languages (LLL)
- Definition:
- Programming languages closer to machine code, with little or no abstraction from the hardware.
- Types:
- Machine code – Binary instructions (0s and 1s) executed directly by the CPU.
- Assembly language – Uses mnemonics to represent machine code.
- Features:
- Specific to a particular CPU architecture (machine-dependent).
- Assembly uses symbolic names for instructions and memory locations.
- Advantages:
- Faster execution as it is closer to machine instructions.
- Allows direct manipulation of hardware components.
- Efficient in terms of memory usage.
- Disadvantages:
- Difficult to read, write, and debug.
- Not portable; must be rewritten for different hardware.
- Requires detailed hardware knowledge.
2. Assembly Language and Mnemonics
- Assembly Language:
- A low-level language that uses mnemonics (short, human-readable codes) instead of binary.
- Each mnemonic corresponds to one machine code instruction.
- Example:
MOV AX, 5(Move value 5 into register AX)- Equivalent machine code:
10111000 00000101
- Mnemonics:
- Abbreviated forms of instructions such as
ADD,SUB,MOV,JMP.
- Abbreviated forms of instructions such as
- Assembler:
- A program that translates assembly language into machine code.
- Can be:
- Single-pass assembler – Translates code in one pass, faster but less error-checking.
- Two-pass assembler – Reads the code twice, once to check labels/symbols, once to generate code.
3. Translators: Compilers and Interpreters
Compiler
- Definition: Translates the entire high-level program into machine code before execution.
- Operation:
- Reads and analyses the whole program.
- Produces an executable file (.exe).
- Reports all syntax and semantic errors together after compilation.
- Advantages:
- The compiled program runs faster because it’s already in machine code.
- Once compiled, the program can be run multiple times without recompiling.
- The source code can be kept private by distributing only the executable file.
- Disadvantages:
- Compilation can be slow for large programs.
- All errors must be fixed before the program can run.
- Requires re-compilation after every code change.
- When used:
- For final program deployment.
- When performance is critical.
Interpreter
- Definition: Translates and executes high-level code line-by-line.
- Operation:
- Reads one line of code, translates it to machine code, executes it, then moves to the next line.
- Stops immediately if it finds an error.
- Advantages:
- Easier for debugging since errors are found and fixed immediately.
- No need for compilation before running – quick testing.
- Disadvantages:
- Slower execution since translation happens during runtime.
- The source code must be available on the machine to run the program.
- When used:
- During program development and testing.
4. Advantages and Disadvantages of Compiler vs Interpreter
| Feature | Compiler | Interpreter |
|---|---|---|
| Execution speed | Faster (compiled to machine code) | Slower (translates while running) |
| Error reporting | All errors shown after compilation | Stops immediately at first error |
| Portability | Executable runs without source code | Source code required on target machine |
| Debugging | Harder to debug (errors shown together) | Easier to debug (errors shown immediately) |
| Usage | Final product delivery | Development and testing |
5. Integrated Development Environment (IDE)
Definition
- A software application that provides all necessary tools for programming in one place.
- Used to write, test, debug, and manage programs.
Common Functions of an IDE
- Code Editor:
- Allows programmers to write and edit source code.
- Features like syntax highlighting, line numbering, and auto-indentation.
- Run-time Environment:
- Allows programs to be run directly from the IDE for testing.
- Translator Integration:
- Includes a compiler or interpreter for code translation.
- Error Diagnostics:
- Highlights syntax errors, warnings, and sometimes logical errors.
- May suggest fixes.
- Auto-completion:
- Suggests variable names, functions, and syntax while typing.
- Auto-correction:
- Automatically fixes minor syntax mistakes (e.g., missing semicolons).
- Prettyprint:
- Formats code neatly for readability.
- Debugging Tools:
- Breakpoints to pause execution.
- Step-by-step execution to track variables.
- Project Management Tools:
- Manage multiple files and folders in a single project.
- Version Control Integration:
- Allows integration with Git and other tools for code version tracking.
6. Usage Scenarios
- During Development:
- Interpreters preferred for testing and debugging.
- IDEs used for efficient coding with all tools in one place.
- During Deployment:
- Compilers preferred for creating fast, standalone executable programs.
