Programming Languages: The Early Years
- Programming Languages: The Early Years
- Binary Arithmetic
- The First Programs
- Enter the Keyboard
- Getting Closer to English
- The FORTRAN Language
- The Business of COBOL
- Other Languages Through the Years
- Summary
Programming Languages: The Early Years
With this chapter, you can step into the ranks of the few, the proud, the people of tomorrow, by developing an understanding of several programming languages. This chapter focuses on the earlier programming languages, some of which are still in use today. You will learn how programming languages began and how they have evolved over the years.
The highlights of this chapter include the following:
As you type keys on your keyboard, your computer accepts binary values that represent data.
The ASCII code defines the binary patterns for each character the computer represents.
The earliest computers were programmed using wires.
FORTRAN and COBOL were the languages of choice for science and business for many years.
ADA was the government's language of choice for many years.
Storage of Programs and Data
While typing at your keyboard, what do you think happens when you press the keys? Does a letter A go somewhere inside the computer's memory when you press the A key? It must, or else the computer could never remember your program's contents. The computer does store the A, but not in the format you might expect. The computer stores only a representation of the letter A. For all intents, the A is in memory, but it does not look like you think it should.
Remember that your computer is nothing more than thousands of switches turning electricity on and off. Each character in your computer is represented by a combination of on and off switches. Programmers generally refer to an on switch as a 1 (one) and an off switch as a 0 (zero). Since these switches have only two values, programmers call the 0s and 1s binary digits, or bits for short. There is a total of eight bits for every character in your computer, and eight bits is known as a byte. Therefore, every character of storage takes eight bits to represent (eight on and off switches), and therefore, a character is a byte.
TIP
The reason it takes eight switches is that if there were fewer, there wouldn't be enough combinations of on and off states to represent all the characters possible (uppercase, lowercase, digits, and special characters such as %, ^, and *).
Years ago, somebody wrote the various combinations of eight 1s and 0s from 00000000 to 11111111 and assigned a unique character to each one. The table of characters was standardized and is known today as the ASCII table (pronounced ask-ee, so if you don't know-ee, you can ASCII). Table 3.1 shows a partial listing of the ASCII table. ASCII stands for American Standard Code for Information Interchange.
Table 3.1 ASCII Values Represent Characters
Character |
ASCII Code |
Decimal Equivalent |
Space |
00100000 |
32 |
0 |
00110000 |
48 |
1 |
00110001 |
49 |
2 |
00110010 |
50 |
3 |
00110011 |
51 |
9 |
00111001 |
57 |
? |
00111111 |
63 |
A |
01000001 |
65 |
B |
01000010 |
66 |
C |
01000011 |
67 |
a |
01100001 |
97 |
Space |
00100000 |
32 |
0 |
00110000 |
48 |
1 |
00110001 |
49 |
2 |
00110010 |
50 |
3 |
00110011 |
51 |
9 |
00111001 |
57 |
? |
00111111 |
63 |
A |
01000001 |
65 |
B |
01000010 |
66 |
C |
01000011 |
67 |
a |
01100001 |
97 |
b |
01100010 |
98 |
Each of the ASCII values has a corresponding decimal number associated with it. These values are shown at the right of the eight-bit values in Table 3.1. Therefore, even though the computer represents the character ? as 00111111 (two off switches with six on switches), you can refer, through programming, to that ASCII value as 63 and your computer will know you mean 00111111. One of the advantages of high-level programming languages is that they often let you use the easier (for people) decimal values, and the programming language converts the value to the eight-bit binary value used inside the computer.
NOTE
As you can tell from the ASCII values in Table 3.1, every character in the computer, both uppercase and lowercase letters, and even the space, has its own unique ASCII value. The unique ASCII code is the only way the computer has to differentiate characters. Some mainframes use a similar system called the EBCDIC table, pronounced eb-se-dik.
Think back to the internal storage of single characters described earlier in this section. When you press the letter A, that A is not stored in your computer; rather, the ASCII value of the A is stored. As you can see from the ASCII values in the previous table, the letter A is represented as 01000001 (all of the eight switches except two are off in every byte of memory that holds a letter A).
TIP
The ASCII table is not very different from another type of coded table you may have heard of. Morse Code is a table of representations for letters of the alphabet. Instead of 1s and 0s, the code uses combinations of dashes and dots to represent characters. The dashes and dots represent the length of radio signals people send or receive. The letters SOS are represented by DOT-DOT-DOT DASH-DASH-DASH DOT-DOT-DOT.
As Figure 3.1 shows, when you press the letter A on your keyboard, the A does not go into memory, but the ASCII value of 01000001 does. The computer keeps that pattern of on and off switches in that memory location as long as the A is to remain there. As far as you are concerned, the A is in memory as the letter A, but now you know exactly what happens. If you print the program you just typed, and the computer is ready to print the character stored in that memory location, the computer's CPU sends the ASCII code for the A to the printer. Just before printing, the printer knows that it must make its output readable to people, so it looks up 01000001 in its own ASCII table and prints the A to paper. From the time the A left the keyboard until right before it printed, it was not an A at all, but just a combination of eight 1s and 0s that represents an A.
Figure 3.1 The A is not an A once it leaves the keyboard.