Book Review: "C Programmer's Library"
John Crane
crane at fortune.UUCP
Tue Apr 24 05:36:48 AEST 1984
This is a review of the book "C Programmer's Library" by Jack J. Pudrum
(author of "C Programming Guide"), Timothy C. Leslie (Dir. SWD @
Ecosoft), and Alan L. Stegemoller (coauthor of Ecosoft's Eco-C C
compiler), published by Que Corporation, Indianapolis, 1984.
The book is intended to be an advanced guide to C programming with emphasis
on applications. Through extensive and useful code samples the authors
illustrate ways to attack problems which C programmers encounter in actual
practice. The coding examples are not contrived or artificial, as you find
in the elementary C programming texts, but are actual working pieces of
code which you could incorporate directly into your personal library of
functions. Indeed, the main emphasis of the book is on building
generalized functions to solve whole sets of problems, not just the
immediate problem at hand.
Here is a listing of the Table of Contents interspersed with my comments:
0. Laying the Groundwork
This chapter introduces the philosophy of the book and presents a
methodology for developing generalized C functions.
This chapter comes down heavy on people who, having been given the
basic requirements for a program, immediately rush off to their
terminals and start entering source code. The authors say: "These
students are not programming; they are BUGGING. They will spend
ten minutes bugging and another DEBUGGING (that is, correcting) the
mess they will make in the first ten minutes." What you should do,
they say, is to spend 10-15 minutes anayyzing the problem (the
problem, by the way, is to write a program to sort 100 ZIP codes),
then spend another 15 minutes coding and testing the program."
(I agree with the above. I am not totally familiar with the term
"hacking", but to me hacking is analogous with "bugging". Somebody
correct me if I'm wrong. In my opinion, both are to be avoided in
favor of a planned, deliberate approach to solving a problem.)
1. Understanding C Data Types
The key to writing generalized functions is writing functions which
operate independent of data types. The key to doing this, the
authors contend, is possessing a thorough knowledge of the various
C data types. This is probably true, but the authors introduce a
lot of unnecessary formality in describing the data types. Instead
of simplifying the problem, they unnecessarily complicate it. They
spend too much time dealing with int, float, and double and not
enough time on strings, structures, pointers, and arrays.
2. Sorting
Shown here are examples of bubble, Shell, and Quick sorts. This
chapter introduces recursive function calls early on and gives the
criteria for determining when to use a loop and when to use
recursive functions. The factorial example shown in most texts is
a poor candidate; the Quick sort is an ideal candidate. Their
bubble sort is quite inefficient. There is a very simple thing
they could do to make it run faster. Challenge: when you find it,
post it to the network.
3. The General Terminal Library
This chapter can be ignored in the UNIX environment since we
generally use either termcap or terminfo. However, you could use
the code here to build your own termcap file for the PC DOS or some
other non-UNIX OS.
4. Code Fragments
Here is discussed, disgrammed, and programmed how to maintain
singly-linked lists, doubly-linked lists, stacks queues, and binary
trees. This is essestially Knuth, Chapter 2 boiled down and
presented in a modern programming language. Very useful! Why
reinvent the wheel when you can buy this book for $20 and use
pre-tested, working code.
5. ISAM
This chapter presents all the functions necessary to build and
maintain an ISAM file system. It builds on all the concepts in the
book up to this point. Hey guys! Even IBM doesn't support ISAM
any more! Why didn't you do B-trees instead?
6. A Book Catalog Program
This is an application using all the concepts of the book. I
haven't read too much of this chapter yet, but I think their choice
of examples does point out that C can be used for more things than
operating systems, device drivers, and compilers (BORING!) (Sorry,
just revealing my prejudices. I would rather write a spreadsheet
or database program any day.) I believe that C is an excellent
choice for all three: heavy systems work, tools and utilities, and
business applications. It just needs to be approached right,
marketed right, taught right, and coded right.
Appendices
A - "man pages" for the ISAM functions
B - "man pages" for the terminal library
C - description of the book catalog program
D - linking order for the various libraries and programs in the book
E - using the code in the UNIX environment
F - using the code in the CP/M (arrrgh!) and PC DOC environments
The code in the book was tested on a number of compilers with varying
results. The authors point out that the "standard" C functions are not all
that standard. They attempt to point out how to change the programs to run
under various OS's and compilers. Come to think of it, if you are
concerned with portability outside the UNIX environment, this book might
serve as a guide, if nothing else.
Another good use for this book. I'm a great borrower of ideas and code.
Why build it yourself from the ground up when you can borrow from somebody
else? (I expect a lot of flames on this about copyright infringement, etc.
Save your breath and fingers and consider me duly flamed.) This book is
full of juicy code examples that you can lift and then modify to suit
your own needs.
More information about the Comp.lang.c
mailing list