Lab 1.1 The Nature of a Computer Program and Programming Languages
Machine LanguagesMachine language is the native language of a particular computer because it is defined by the hardware of the computer. Each instruction or command is a collection of zeros and ones. As a result, machine language is the hardest language for a person to understand, but it is the only language understood by the computer. All other programming languages must be translated into machine language. Consider the following example of the commands issued in the machine language. 0000 0011 0000 0110 0000 0001 0000 0000 1010 0011 1110 0110 0000 0001 Assembly LanguagesAssembly language uses English-like abbreviations to represent operations performed on the data. A computer cannot understand assembly language directly. A program written in assembly language must be translated into machine language with the help of the special program called an assembler . Consider the following example of the commands issued in assembly language. ADD AX, 0001 MOV [01E6], AX High-Level LanguagesA high-level language uses English-like instructions and common mathematical notations. High-level languages allow programmers to perform complicated calculations with a single instruction. However, it is easier to read and understand than machine and assembly languages, and it is not as time-consuming to create a program in high-level language as it is in machine or assembly language. This example shows the simple mathematical operation of addition. This instruction can be easily understood by anyone without programming experience and with basic mathematical knowledge. Differences Between Interpreted and Compiled LanguagesHigh-level languages can be divided into two groups: interpreted and compiled. Interpreted languages are translated into machine language with the help of another program called an interpreter. The interpreter translates each statement in the program into machine language and executes it immediately before the next statement is examined.A compiled language is translated into machine language with the help of the program called a compiler. Compilers translate English-like statements into machine language. However, all of the statements must be translated before a program can be executed. The compiled version of the program is sometimes referred to as an executable. An interpreted program must be translated into machine language every time it is run. A compiled program is translated into machine language only once when it is compiled. The compiled version of the program can then be executed as many times as needed. |