Machine Languages, Assembly Languages and High-Level Languages

Programmers write instructions in various programming languages, some directly understandable by computers and others requiring intermediate translation steps. Hundreds of computer languages are in use today. These may be divided into three general types:

  1. Machine languages
  2. Assembly languages
  3. High-level languages

Machine Languages

Any computer can directly understand only its own machine languagethe "natural language" of a computer that is defined by its hardware design. Machine languages generally consist of strings of numbers (ultimately reduced to 1s and 0s) that instruct computers to perform their most elementary operations one at a time. Machine languages are machine dependent (i.e., any given machine language can be used on only one type of computer). Such languages are cumbersome for humans, as illustrated by the following section of an early machine-language program that adds overtime pay to base pay and stores the result in gross pay:

+1300042774 +1400593419 +1200274027

 

Assembly Languages

Machine-language programming was simply too slow and tedious for most programmers. Instead of using the strings of numbers that computers could directly understand, programmers began using English-like abbreviations to represent the elementary machine operations. These abbreviations formed the basis of assembly languages. Translator programs called assemblers were developed to convert early assembly-language programs to machine language at computer speeds. The following section of an assembly-language program also adds overtime pay to base pay and stores the result in gross pay:

load basepay add overpay store grosspay

Although such code is clearer to humans, it is incomprehensible to computers until translated to machine language.

High-Level Languages

Computer usage increased rapidly with the advent of assembly languages, but programmers still had to use many instructions to accomplish even the simplest tasks. To speed the programming process, high-level languages were developed in which single statements could be written to accomplish substantial tasks. Translator programs called compilers convert high-level language programs into machine language. High-level languages allow programmers to write instructions that look almost like everyday English and contain commonly used mathematical notations. A payroll program written in a high-level language might contain a statement such as

grossPay = basePay + overTimePay

From the programmer's standpoint, obviously, high-level languages are preferable to machine and assembly languages. Microsoft's Visual Studio languages (e.g., Visual C#, Visual C++ and Visual Basic) and other languages such as C, C++ and Java are among the most widely used high-level programming languages. Figure 1.1 compares machine, assembly and high-level languages.

Figure 1.1. Comparing machine, assembly and high-level languages.

The process of compiling a high-level language program into machine language can take a considerable amount of computer time. Interpreter programs were developed to execute high-level language programs directly, although much more slowly. Interpreters are popular in program development environments in which new features are being added and errors corrected. Once a program is fully developed, a compiled version can be produced to run most efficiently. Interpreters are also popular with so-called scripting languages on the Web. We'll study the development of Web-based applications in Chapters 1922.

Категории