4.2 High- and low-level languages and their translators

4.2 High - and low-level languages and their translators

Learning Objectives

  • High-Level Language vs. Low-Level Language

    • Understand definitions, advantages, and disadvantages of each.

    • High-Level Languages:

      • Closer to human languages.

    • Low-Level Languages:

      • Closer to machine code.

  • Assembly Language as Low-Level Language:

    • Uses mnemonics.

    • Requires an assembler to translate assembly to machine code.

  • Translation of High-Level Language:

    • Compiler and Interpreter Operations:

      • Explain how high-level languages are translated.

      • Discuss error reporting mechanisms.

  • Compiler vs. Interpreter:

    • Compare advantages and disadvantages of each.

  • Role of IDEs:

    • Define how IDEs help in programming.

    • Identify common functions provided by IDEs.

High and Low Level Programming Languages

  • High-Level Programming Languages:

    • Closer to human understanding; easier to read and write.

  • Low-Level Programming Languages:

    • Provides minimal abstraction from hardware; closely related to machine code.

Low Level Programming Languages

  • Low-level programming languages include mainly:

    • Machine Code:

      • Directly corresponds to processor instructions.

    • Assembly Language:

      • More human-readable and uses mnemonics.

Machine Code

  • Definition:

    • Binary instructions that constitute a program.

  • Components of Machine Code:

    • Each instruction consists of:

      • Opcode: Operation to be performed.

      • Operand: Data to be processed; can be literals or memory addresses.

Assembly Language

  • Characteristics:

    • Utilizes mnemonics for easier programming.

    • Direct one-to-one translation to machine code.

Basic Assembly Language Instructions

  • Key Instructions:

    • ADD: Adds operand to current value in the accumulator (ACC).

    • LOAD: Loads data from memory location pointed to by operand.

    • STORE: Saves data currently in the ACC to the specified memory location.

Machine Code and Logic Circuits

  • Each instruction in machine code corresponds to hardware logic circuits that perform the defined operations.

What does an assembler do?

  • Assembler Functionality:

    • Translates assembly language code into binary machine code.

High Level Languages

  • Definition:

    • Strongly abstracted from computer details; easier and simpler for development.

  • Examples of High-Level Languages:

    • Python, Java, C#, Pascal, etc.

What does a compiler do?

  • Compiler Functionality:

    • Translates high-level code into machine code all at once, generating an executable file.

What does an interpreter do?

  • Interpreter Functionality:

    • Reads and executes high-level code one line at a time.

Interpreter Vs Compiler

  • Aspect

    Interpreter

    Compiler

    Translation Method

    Translates one statement at a time.

    Scans entire program and translates as a whole.

    Execution Time

    Overall execution is slower but quick to analyze

    Overall execution is faster but takes longer to analyze.

    Error Reporting

    Stops at the first error, easier debugging.

    Reports errors only after full analysis, harder debugging.

What is an Integrated Development Environment (IDE)?

  • IDE Definition:

    • A software application designed to make programming easier and more efficient.

  • Common Features:

    • Code Editors: For writing code.

    • Run-time Environment: Provides necessary libraries.

    • Translators: For assembling, compiling or interpreting code.

    • Error Diagnostics: Identifies and displays errors.

    • Auto-completion and Correction: Assists with writing and correcting code.

    • Prettyprint: Displays code with syntax highlighting for improved readability.