Next: Style Up: C Programming Previous: C Programming

Programming languages

There are several ways in which we can classify languages. For example, Imperative: the user says how to proceed, how to calculate step by step. The user has to give a recipe. This category includes C, FORTRAN, BASIC, Pascal.

In contrast, Declarative: the user describes what it is to be a solution, what properties the solution has. For example, ML.

The first approach will often involve the user in designing and building structures, as a consequence of the recipe. In the second approach the emphasis is often on the data itself, and the manipulations performed on it are the side effect.

In this course, we are using an imperative language, C.

Another way of classifying languages is by whether they are compiled or interpreted. This is strictly an implementation issue, rather than a linguistic one. Thus BASIC and LISP can each be compiled or interpreted. An interpreter is often a good way of developing a program; a compiler produces much more efficient runnable programs, so you can use both hand-in-hand. C is a compiled language.

Finally we might classify by application area: FORTRAN is a Scientific language; COBOL is for Business applications; C is a System Programming language.

What do these high-level languages have in common? They are all intended to make it easier for the programmer to get the machine to do what you want. Certain constructs therefore occur in many languages, even though their syntax (appearance) may differ. Converting to a new, related language is thus easier than learning your first language.

If you have programmed in BASIC, moving to FORTRAN is very easy. Pascal is a better structured form of the same constructs, and pays more attention to the needs of data structures.

C also has many features in common with these languages, but where Pascal was designed as a teaching language, C is for grown-ups! You can do almost anything in C, including many things you do not want to do. This is because C is superficially a high level language, yet allows you to get close to the machine, efficiently, if you need to. For example you can manipulate addresses directly. For this reason you could think of it as middle-level.

In contrast to strongly typed languages such as ML, C takes a laid-back approach and generally will not stop you doing odd things, because it assumes you know what you are doing. ANSI C attempts to keep this flexibility while giving you warnings of apparently dubious things (adding a number to a character for example). Contrast this with Pascal which deliberately prevents you doing such things; or with FORTRAN which often lacks the concepts completely.

We will therefore assume that you know how to program but that you need to know the form of the constructs C has to offer and the special features of imperative programming.



Next: Style Up: C Programming Previous: C Programming


maspjw@
Tue Sep 27 15:29:34 BST 1994