The Good Old C Language
Writing assembly-language programs is often difficult and time-consuming, and the programs are difficult to modify and impossible to port from one computer to another. To combat this situation, programmers created a wide variety of different programming languages with names such as COBOL and FORTRAN.
But some programmers felt that they needed a language that offers the power to access hardware (like assembly language) but is easier to read, write, and modify (like COBOL and FORTRAN). Eventually, they invented a programming language known simply as C.
Technical Stuff Programmers based the C programming language on an early programming language by the name of B (although no programming language known as A ever existed).
Programmers wanted to make programming as easy as possible for themselves, so they made the C programming language look more like actual words that people can understand, as the following example demonstrates:
main()
{
printf (”Take a nap!\n”);
}
This C program is equivalent to the assembly-language program found in the preceding section of this chapter. Both programs display “Take a nap!” on-screen. Comparing the two, you can see that the C language source code is smaller and easier to read than the equivalent assembly-language source code.
Remember To run a program written in assembly language, you need to convert the assembly-language commands into equivalent machine-language commands. Similarly, to run a program written in any other language, such as C (or BASIC, FORTRAN, Pascal, and so on), you must translate your commands into equivalent machine-language commands, which you do by using a special program called a compiler.
The programmers who created the C programming language had the following three main goals:
-
To create a language that’s easier to read and write than assembly language.
-
To offer programmers the capability to access all the parts of the computer just as they can by using assembly language.
-
To provide a small, simple language that you can easily port from one computer to another. Programs that you write in C can run on different computers without massive rewriting, which is the main drawback with assembly- and machine-language programs.
The third goal may look strange, so here’s the rationale behind it: Computers don’t understand C any better than they understand assembly language. (Computers are notorious for not understanding much of anything, which is why programming must be so precise.) If you write an entire program in C, your computer doesn’t have the slightest clue how to read your instructions.
To make a computer read and understand instructions written in C, you must convert your C program into equivalent machine-language instructions. Programmers created special programs, known as compilers, to do this conversion for them. A compiler takes your C program and converts it into machine language, which is like translating a Jules Verne novel from French into English.
As is true of translations between human languages, the simpler the programming language, the easier the translation. Translating a children’s book from French into Japanese is much easier than translating a mathematics dissertation from French into Japanese, mainly because a children’s book uses simple words, whereas a mathematics dissertation uses more complicated words. Similarly, translating C into machine-language code is more difficult than translating assembly-language code into machine-language code.
So the only way that you can run a C program on another computer is if someone has already written a C compiler for that other computer. Because C is a simple language, writing C compilers for different computers is relatively easy.
Because C compilers are fairly easy to write, you can find C compilers for almost every computer in the world. Theoretically, you can write a C program for the Macintosh, copy it to a computer running Windows, recompile it, and run the program with just minor modifications.
Remember Although, in theory, C programs can run on different computers without modification, the reality is that you almost always must modify a C program slightly or drastically to get it to run on a different computer. Modifying a C program, however, is still much easier than rewriting an entire assembly- or machine-language program to run on different computers.
Given its power and portability, C has quickly become one of the most popular programming languages in the world. The majority of all programs are written in C although most newer programs are now written in a C derivative language called C++. Some of the more famous (or infamous) programs that have been written in C or C++ include operating systems such as Microsoft Windows, UNIX, and Linux, as well as major commercial programs such as Quicken, Photoshop, and Microsoft Word.
Although C is popular, it has its share of flaws:
-
Large, slow programs: C creates larger and slower programs than equivalent assembly- or machine-language programs.
-
Danger to computer memory: The C language gives programmers access to all parts of a computer, including the capability to manipulate the computer’s memory. Unfortunately, all this power can prove as dangerous as giving a hyperactive monkey a chain saw and a hand grenade. If you don’t write your C programs carefully, they can accidentally wreck your computer’s memory, causing your program to crash your computer.
Technical Stuff In a desperate attempt to make C programming more reliable, programmers developed languages similar to C, such as C++, Java, Perl, Python, and C#. All these C-derived languages try to protect programmers from writing programs that can mess up the computer’s memory, as C programs can do, which increases the chance of writing a program that won’t crash an entire computer.
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply