Review: Programming With Curses


Curses is a C library for handling cursors. It's used for moving the cursor around to where you want it on a text-only screen.

Some younger readers (particularly those on Mac and Windows) may have never encountered one of these text-only screens except for brief moments when they're forced into their computer's BIOS menus.

Even modern Linux and FreeBSD users will rarely face a native text-only console. They will usually see text-only screen apps when logged in remotely over a terminal emulator; Xterm, Terminal, Gterm, etc.

Programming With Curses

"Programming With Curses" by John Strang is one of O'Reilly's earliest Nutshell books, and boy does it show. Layout, font selection, and even organisation of the book are very different to what we expect from an O'Reilly "animal book." Slim table of contents, no index per se just a four page "quick reference" at the back.

The elephant in the room: this is an extremely slim reference. Of the 76 pages, only 66 have actual content. The physical dimensions of the page are also a fair bit smaller

If you were hoping it might be useful for your console application written in another language, and not C, this isn't the book for you. If you're a C programmer on a modern Unix based on System V (like Linux), you're also a bit out of luck. This only covers the original BSD.

To be fair, what it does, it does comprehensively. It covers terminal independence through Termcap and Terminfo (now largely irrelevant given we're all using terminal emulators now; true dumb terminals are as dead as the proverbial Dodo), how to include the library in your C code, and descriptions of what each of the functions do. These function descriptions can feel a bit laboured, given their names often essentially say it all. For a thin book, the descriptions feel padded, even telling us which other functions these functions use in passing.

Script examples make the mistake of being longer than needed and trying to do too much. "This part of the sample program demonstrates the input functions," says one, leading to a full page of script with minimal comments. That's really the opposite of how you want an example demonstrated. You just want that thing, nothing extra to confuse you.

There's a distinct lack of polish, overall, and it feels like it was rushed out the door: Screenshots that are not genuine screenshots, that are just content printed in the fixed-width font and have a vaguely "screen-shaped" border drawn around it. A paragraph spent on explaining what a "window" is. Yet so many topics unaddressed, that would have been interesting and useful for people developing Curses applications. Nothing on why you'd use Curses over its alternatives. Nothing on best practice for Curses user interfaces.

In Sum

Publisher: O'Reilly Media
Edition: 1st edition (January 11, 1986)
Series: Nutshell Handbooks
Paperback: 76 pages
Language: English
ISBN-10: 0937175021
ISBN-13: 978-0937175026
Product Dimensions: 5.5 x 0.2 x 8.5 inches

Rating: 3/10. Audience: Expert C programmers.

With a very limited target audience (expert C programmers on a classic BSD system), it's hard to recommend this book to modern console app developers. You may be better off with Programmer's Guide to NCurses by Dan Gookin (covers ncurses, the modern variant, on most systems including Linux) or Using C With Curses, Lex, and Yacc: Building a Window Shell for Unix System V by Axel-Tobias Schreiner. If you want more info on Termcap and Terminfo, you'd be better off looking at Termcap & Terminfo (3rd Edition), a more comprehensive 264 page book by Linda Mui, Tim O'Reilly, and John Strang.

If you're using a scripting language that has Tk, you might instead consider skipping Curses entirely and using that Tk as a guide to wrap an excellent package, Ck by Christian Werner. Ck implements the Tk toolkit on the console.

Peter Caffin is a systems administrator and software developer from Perth, Western Australia. His contributions to Tcl/Tk include TclMacBag (various Mac UI controls to all platforms in a platform appropriate way) and TclTalkback (automated error reporting to developers). Product links point to Localhost, where Peter Caffin is an affiliate.

(Reviewed: August 2015.)