1.4 Machine Languages, Assembly Languages and High-Level Languages

  • Programmers write instructions in various programming languages
    • Some directly understandable by computers
    • Others require intermediate translation steps
  • Three general types
    1. Machine languages
    2. Assembly languages
    3. High-level languages

Machine Languages

  • Any computer understands only its own machine language, defined by its hardware design
  • Generally consist of strings of numbers (ultimately 1s and 0s) that instruct computers to perform their most elementary operations
  • Cumbersome for humans
  • Section of an early machine-language payroll program that adds overtime pay to base pay and stores the result in gross pay
    +1300042774
    +1400593419
    +1200274027

Assembly Languages and Assemblers

  • English-like abbreviations to represent elementary operations
  • Formed the basis of assembly languages
  • Assemblers were developed to convert assembly-language programs to machine language at computer speeds
  • Section of an assembly-language payroll program that adds overtime pay to base pay and stores the result in gross pay
    load    basepay
    add     overpay
    store   grosspay

High-Level Languages and Compilers

  • With the advent of assembly languages, computer usage increased rapidly
  • Programmers still needed numerous instructions to accomplish even simple tasks
  • High-level languages enable single statements to accomplish substantial tasks
  • A typical high-level-language program contains many statements, known as the program’s source code

High-Level Languages and Compilers (cont.)

  • Compilers convert high-level-language source code into machine language
  • High-level languages look almost like everyday English and contain commonly used mathematical notations
  • Payroll program written in a high-level language might contain a statement such as
    grossPay = basePay + overTimePay
  • Python is among the world’s most widely used high-level programming languages

Interpreters

  • Interpreter programs execute high-level language programs directly and avoid the delay of compilation
  • Interpreted programs run slower than compiled programs
  • Most widely used Python implementation—CPython—uses a clever mixture of compilation and interpretation to run programs

©1992–2020 by Pearson Education, Inc. All Rights Reserved. This content is based on Chapter 1 of the book Intro to Python for Computer Science and Data Science: Learning to Program with AI, Big Data and the Cloud.

DISCLAIMER: The authors and publisher of this book have used their best efforts in preparing the book. These efforts include the development, research, and testing of the theories and programs to determine their effectiveness. The authors and publisher make no warranty of any kind, expressed or implied, with regard to these programs or to the documentation contained in these books. The authors and publisher shall not be liable in any event for incidental or consequential damages in connection with, or arising out of, the furnishing, performance, or use of these programs.