Computing Reviews
Today's Issue Hot Topics Search Browse Recommended My Account Log In
Review Help
Search
Obfuscated C and other mysteries
Libes D., John Wiley & Sons, Inc., New York, NY, 1993. Type: Book (9780471578055)
Date Reviewed: Aug 1 1993

Two types of material are combined in this peculiar book. First, it offers 32 short essays, mostly reprints of the author’s magazine articles. The topics are unrelated, except that they “describe how to make and build things--real things--with C.” Interspersed with these essays are the winning programs from the Obfuscated C Code Contest, 1984–1991, each year in its own chapter, with explanations by the author or others. Both the essays and the programs--which are unconnected--appear “in increasing order of complexity.” A disk (expanding to 2.5 megabytes) containing most of the source code and some additional material is packaged with the book.

At first, I was put off by this gallimaufry. When I actually read the essays, however, I was impressed by the author’s insights and the obvious usefulness of much of his material for the working programmer. In general, the essays focus on the knottier aspects of some feature of C syntax or some typical task, pinpointing areas where the unwary programmer is likely to get into trouble and suggesting how trouble might be avoided. The subjects of the essays are implementing variable-size arrays, writing a filter for WordStar documents, implementing sets with bit operations, macros, parsing command-line arguments, casts, reading the standard input, malloc, linked lists, setting the computer’s clock to Naval Observatory time, byte ordering in the storing of ints and chars, floating-point, passing varying numbers and types of arguments, longjmp and setjmp, writing a dump routine, pointers to functions, conditional preprocessor directives, a miscellany of tips, speeding up strcpy, register, portability, threads, dynamic memory allocation, environment variables, static, using yacc or lex twice in one program, Tcl (Tool Command Language), implementing software timers, Expect (a tool built using Tcl), implementing a trap-like command, and the heap.

Except for its brevity and simplicity, the following tip (drawn from the chapter on miscellaneous tips) typifies the kind of practical information provided in the essays:

Roger Hayes, Department of Computer Science at the University of Arizona, makes the following suggestion. Write conditional expressions with the constant first--as in

if (10==j)

rather than

if (j==10)

if you ever miscode == as =, the compiler will complain about the first form but not the second. (p. 177)

By contrast, the contest material offers mostly amusement. Although Libes marvels at the clever algorithms and makes a case for the educational value of deciphering the obfuscated C entries, I remain unconvinced. Consider the “Best Small Program” in the 1985 contest (p. 47):

main(v,c)char**c;{for(v[c++]=“Hello, world!\n)”; (!!c)[*c]&&(v- -||- -c&&execlp(*c,*c,c[!!c]+!!c,!\ c));**c=!c)write(!!*c,*c!!**c);}

Studying programs like the above to improve one’s algorithmic knowledge is perhaps comparable to doing crosswords and acrostics as a means of increasing one’s vocabulary. In both cases, more efficient methods are available. Of course, reading Libes’s lucid analysis of the programs is less time-consuming and more enjoyable than slogging through them oneself.

This book makes one thing clear: Libes is one of the fortunate few of this world who truly enjoy their work. If you work in C (especially under UNIX) and share his affection for the language, you might want to ante up $40 for this oddity.

Reviewer:  A. Blackman Review #: CR116968
Bookmark and Share
 
Coding Tools and Techniques (D.2.3 )
 
 
C (D.3.2 ... )
 
Would you recommend this review?
yes
no
Other reviews under "Coding Tools and Techniques": Date
Typographic style is more than cosmetic
Oman P., Cook C. Communications of the ACM 33(5): 506-520, 1990. Type: Article
Mar 1 1991
Writing solid code
Maguire S., Microsoft Press, Redmond, WA, 1993. Type: Book (9781556155512)
Feb 1 1994
Zen of code optimization
Abrash M., Coriolis Group Books, Scottsdale, AZ, 1994. Type: Book (9781883577032)
May 1 1995
more...

E-Mail This Printer-Friendly
Send Your Comments
Contact Us
Reproduction in whole or in part without permission is prohibited.   Copyright 1999-2024 ThinkLoud®
Terms of Use
| Privacy Policy