Tuesday, September 21, 2010

C Is a Middle-Level Language

C is often called a middle-level computer language. This does not mean that C is less
powerful, harder to use, or less developed than a high-level language such as BASIC
or Pascal, nor does it imply that C has the cumbersome nature of assembly language
(and its associated troubles). Rather, C is thought of as a middle-level language because
it combines the best elements of high-level languages with the control and flexibilityof
assembly language. Table 1-1 shows how C fits into the spectrum of computer
languages.
As a middle-level language, C allows the manipulation of bits, bytes, and
addresses—the basic elements with which the computer functions. Despite this fact
C code is also very portable. Portability means that it is easy to adapt software written
for one type of computer or operating system to another. For example, if you can easily
convert a program written for DOS so that it runs under Windows, that program is
portable.

Highest level

Ada
Modula-2
Pascal
COBOL
FORTRAN
BASIC

Middle level

Java
C++
C
FORTH

Lowest level

Macro-assembler
Assembler

All high-level programming languages support the concept of data types. A data
type defines a set of values that a variable can store along with a set of operations that
can be performed on that variable. Common data types are integer, character, and real.
Although C has five basic built-in data types, it is not a strongly typed language, as are
Pascal and Ada. C permits almost all type conversions. For example, you may freely
intermix character and integer types in an expression.
Unlike a high-level language, C performs almost no run-time error checking. For
example, no check is performed to ensure that array boundaries are not overrun. These
types of checks are the responsibility of the programmer.
In the same vein, C does not demand strict type compatibility between a parameter
and an argument. As you may know from your other programming experience, a
high-level computer language will typically require that the type of an argument be
(more or less) exactly the same type as the parameter that will receive the argument.
However, such is not the case for C. Instead, C allows an argument to be of any type
as long as it can be reasonably converted into the type of the parameter. Further, C
provides all of the automatic conversions to accomplish this.C is special in that it allows the direct manipulation of bits, bytes, words, and
pointers. This makes it well suited for system-level programming, where these
operations are common.
Another important aspect of C is that it has only 32 keywords (27 from the
Kernighan and Ritchie de facto standard, and five added by the ANSI standardization
committee), which are the commands that make up the C language. High-level
languages typically have several times more keywords. As a comparison, consider
that most versions of BASIC have well over 100 keywords!

No comments:

Post a Comment