Next Up Previous Contents
Next: 2.4.4 C++ and object orientation
Up: 2.4 Programming languages
Previous: 2.4.2 Fortran 90/95
[ID index][Keyword index]

2.4.3 C

There are hundreds of books on C, but the only essential one is the Kernighan and Ritchie book [kr] (also known as just `K&R'). This is a very short book, by the authors of the language, which combines a tutorial introduction with a detailed reference to the language and its standard libraries. I believe it's the only C book you'll ever need.

The book's compression makes it possible, and even advisable, to read it from beginning to end. It avoids the bloat found in many other C books by not teaching you how to program, by never saying anything twice, and by never attempting the empty reassurance that `it's all easy, really'; its examples often illustrate more than one point at a time, and culminate in a sample implementation of the library function malloc. Science textbooks don't talk down to you; I don't see why computer texts should be excused for doing so.

It follows from this that K&R is not necessarily the ideal recommendation for someone new to programming, who might need something a little more comprehensive. My recommendation in that case is to find an introductory C (or even general programming) book which covers what you want without irritating you, and use that up to the point where you feel comfortable with K&R.

C allows the programmer a considerable degree of freedom in how an algorithm is expressed. The fact that this freedom is easily abused makes style guides more common for C than for other languages. Starlink has adopted The Elements of C Programming Style by Jay Renade and Alan Nash as its principal C programming standard, as well as producing a compact collection of programming style suggestions in SGP/4.

One way of making your life easier in this respect is to be consistent about using current standard ANSI-C. See Section 2.5.5.

The C language as originally designed by Kernighan and Ritchie was standardised as ANSI-C in 1990 (K&R 2nd edition describes the latter). This standard is currently being revised by an ISO working group with the memorable name ISO/IEC JTC1/SC22/WG14 -- C. One of the motivations to the work is to provide better support for floating point calculations in C, such as defining a standard interface to the IEEE floating point exceptions.

The excellent C FAQ contains substantially more than you realised you wanted to know about C. It contains detailed discussions of both common and arcane problems.


Next Up Previous Contents
Next: 2.4.4 C++ and object orientation
Up: 2.4 Programming languages
Previous: 2.4.2 Fortran 90/95
[ID index][Keyword index]
Theory and Modelling Resources Cookbook
Starlink Cookbook 13
Norman Gray
2 December 2001. Release 2-5. Last updated 10 March 2003