Review:Beginning Linux Programming
Hark Ye Newbies, the Clue Phone Ringeth!
The trees felled to print this book died for a worthy cause: to
entice more programmers to hang out at Camp Linux, especially newbie programmers.
Our two friendly co-authors, their three editors, and a small army of technical
reviewers and other hangers-on, will gently take your quivering little
hand and whisk you away into the enchanted forests of shell programming,
curses, terminals, file I/O, pipes, sockets, shared memory, DBM files,
Tcl, Tk, HTML, CGI, gdb debugging, and some other crazy places that would
scare your Mom if she ever found out. The descriptions of each topic are
clear and almost every page includes a tasty morsel of sample code, constantly
assuring that reader that even drooling idiots like you can write real-world
UNIX applications in short time.
Fortunately the content is not biased toward any particular distribution
of Linux, but in fact it's not particularly biased toward Linux either.
I am hard-pressed to find any part of the book that can not be applied
to UNIX in general, so I think a more appropriate title for this book would
be "Beginning UNIX Programming", but I suppose the drawbacks of
doing so would mean 1) whining tech journalists would complain of the lack
of Linux programming books because they didn't bother searching under "UNIX
programming", and 2) Linux is a flavor of UNIX anyway so you may well teach
newbie programmers the UNIX way of doing things.
What I'm reading here is the actually the third printing of this
book, circa 1997, (first printing in 1996) and many things have happened
in Linux development since then so unfortunately there's no mention of
GIMP, GNOME, Gtk, KDE, Qt, MySQL, Mesa, WindowMaker, and other areas that
currently hold the interest of so many Linux hackers. And true, perhaps
these topics too advanced for a book called "Beginning Linux Programming"
but the book does attempt to touch upon all aspects of Linux programming
so why not say a little bit about the APIs that are hosting the coolest
parties.
- Very comprehensive. It would be hard to read this book and still be confused about UNIX architecture.
- Clear examples. Unlike so many programming books where the example code spools on and on for pages, the examples in this book are divided into easily digestible bite sized code snippets, separated by block of text to explain what's going on every step of the way.
- Quick guides to common tools: This book explains the simple yet non obvious commands every UNIX programmer has become familiar with: gcc, make (and Makefiles), gdb, patch, diff, tar, cflow, cxref, indent, lclint, etc. It takes care of most of the questions you'll find posted in comp.os.unix.programming newsgroups.
- Bonuses: It seems to me the authors did not have to discuss topics such as using DBM databases, HTML authoring, and CGI programming in this book, but they do so anyway which makes it all the more harder to keep this book out of arm's reach.
What's Bad:
- PERL, anyone? There's a whole chapter devoted to Tcl and yet only 2 pages devoted to a little something, maybe you've heard of this thing, called "perl"?!
- Open Source, anyone? Fails to reiterate the most valuable asset of Linux which pertains to programmers: it's (almost) entirely Open Source. The code is all there right under your nose! Feel free to browse through it and tell the developers what you think. And sure you could spend many weeks writing your own special application but chances are someone out there has already started an Open Source project to develop exactly what you need. That's what set's Linux apart from so many other flavors of UNIX is the prevailing code license: "GNU's not UNIX!".
- A little bit dated: Since its current printing is from 1997, there's no mention of the newer APIs common in Linux these days (GNOME, KDE, etc. etc.).
- Guilty of declaring fixed-size string buffers: Most of the C code examples reinforce bad habits such as feeding external data directly into fixed-length character buffers. Some examples should have titled "How to Make A Core Dump File". I don't think you can say enough to persuade C programmers to consider the stability and security of their applications. You may accuse me of nit-picking here, but I thinks its best to teach programmers while they're young so to save them a major rewrite later on.
Pick this book up at Amazon.
Chapter 1: Getting Started
What is UNIX? What is Linux? GNU, Free Software Foundation, The C Compiler,
C header files and libraries, UNIX philosophy
Chapter 2: Shell Programming
What is a shell? Pipes and redirection, shell as a programming language,
shell syntax, example app: audio CD collection cataloger
Chapter 3: Working with Files
UNIX file structure, System Calls and Device Drivers, Library Functions,
Low-level file access, Standard I/O library (in C), File and Directory
Maintenance, Scanning Directories, Errors, Advanced Topics (file descriptors
and memory mapped I/O)
Chapter 4: The UNIX Environment
Program arguments, Environment variables, Time and Date, Temp files,
Host information, Logging, Resources and Limits
Chapter 5: Terminals
Reading and writing to the terminal, the terminal driver and interface,
the termios structure, terminal output, identifying the terminal type,
detecting keystrokes
Chapter 6: Curses
Compiling with curses, Basic curses features, keyboard input, multiple
curses windows, subwindows, the keypad, color, example app: The CD audio
collection using a curses interface
Chapter 7: Data Management
Managing memory, memory allocation, the NULL pointer, lock files, deadlocks,
databases (dbm), Example app: The audio CD catalog using dbm
Chapter 8: Development Tools
The make command and Makefiles, Source code control (RCS, SCSS), writing
man pages, making patches and tar files
Chapter 9: Debugging (C code)
Types of errors, code inspection, using gdb, more debugging tools (ctags,
cxref, cflow, prof, gprof, lint) Assertions, Memory Debugging (ElectricFence,
purify, Checker)
Chapter 10: Processes and Signals
Process structure, viewing processes, system processes, process scheduling,
waiting for a process, input and output redirection, threads, signals,
signal sets.
Chapter 11: Interprocess Communication: Pipes
Process types, Sending output to popen, the pipe call, parent and child
processes, reading closed pipes, pipes used as standard input and output,
named pipes: FIFOs, Example: the CD catalog as a client/server application
Chapter 12: Semaphores, Message Queues, and Shared Memory
Semaphores, UNIX semaphore facilities, shared memory, message queues,
queue efficiency, IPC status commands
Chapter 13: Sockets
Socket connections, socket addresses, host and network byte ordering,
Network information, the Internet daemon, socket options, Multiple clients,
the select() function
Chapter 14: Tcl: Tool Command Language
"Hello World" in Tcl, Tcl commands, calculations, substitutions, error
handling, arrays, lists, procedures, Input/Output, Tcl extensions, expect,
[incr Tcl], TclX, networking, graphics, Tk, tgdb
Chapter 15: Programing for X
X server, X protocol, Xlib, X clients, X toolkits, X Window Manager,
the X programming model, the Tk Toolkit, windows programming, configuration
files, Tk widgets, geometry management, inter-application communication,
Example app: a bitmap display program in Tk, Java, X programming with Java
Chapter 16: Programming for the Internet: HTML
What is the World Wide Web, writing HTML, HTML tags, HTML tables, HTML
hyperlinks, serving HTML pages (Apache), Server-side Includes
Chapter 17: Internet Programming 2: CGI
the FORM tag, the INPUT tag, WWW encoding, Writing a server-side CGIprogram,
decoding form data, using perl as a back end to the CGI, returning HTML
to the client, Tips and Tricks, Example app: the CD catalog online
written as a CGIapp in C
Appendix A: Portability
Language portability, reserved names, hardware portability, sizes, byte
order, char, union packing, structure alignment, pointer sizes, moving
to C++
Appendix B: FSF and the GNUProject
The GNUproject and GNUPublic License
Appendix C: Internet Resources
Newsgroups, WWW locations, FTP archives, CD vendors, Linux specific
Appendix D: Bibliography
Standards, other documentation, other cool books not related to computers.
Index
Picture of Tux
Survey Card
Back Cover
Top Surface of My Desk
My Feet
The Carpet
Foundation of this Building
Gravel
Bedrock
Hell
Bedrock
Australia
Space...
One of the first things I did after I got comfortable with C programming was to write a set of functions that would malloc() space for strings on the fly... I still use those functions in almost everything I write; they're probably the oldest code of mine that's still in use...
int ci_getstr(char **buffer)
{
int length = 0;
char ch;
if (*buffer)
{
free (*buffer);
(*buffer) = (char *) malloc (1);
}
else
{
(*buffer) = (char *) malloc (1);
}
do
{
ch = getchar();
if ( ch != '\n')
{
if (ch == '\b')
{
if (length)
{
printf ("\b \b");
length--;
if ( ( *buffer = (char *) realloc (*buffer, length) ) || (!length) );
else
{
return 0;
}
}
else
{
printf ("\a");
}
}
else
{
if (*buffer = (char *) realloc (*buffer, length+1) )
{
(*buffer) [length] = ch;
length++;
printf ("%c", ch);
}
else
{
return 0;
}
}
}
} while (ch != '\n');
if (*buffer = (char *) realloc (*buffer, length+1) )
{
(*buffer) [length] = '\0';
}
else
{
return 0;
}
return 1;
}
/* This one is designed to work with the tty echo turned off... if you have echo turned on, take out the printf()s. For reading passwords and stuff, take out the printf()s _and_ turn off tty echo. */
...and has a copy of the license (for what seems
to be legal reasons) but throughout the book
there's no words to encourage readers to get into
Open Source projects and how they can contribute
and reap benefits of Open Source. The Acknowledgements
includes thanks to FSF and GNU but in a sort of
tone as thanking Santa Claus for all the free
stuff -- we don't want new Linux programmers
thinking that GNU developers live in some far off
monastery where they write tools all day for to
atone for their sins in past lives -- GNU is not
just about generousity, it's really about "We're
building Linux because we want it and need it so
if you like it too then why not contribute some
of your code too".
OrderHere is that link at bookpool.com and the price including fedex 2 day is only $30. Thanks for the link!
I ordered a from bookpool half an hour before you posted and got a confirmation its in the mail. Woohoo! It must be too late now as either bookpool has been slashdotted or doesn't have the stock like amazon!
Not that I have anything against Amazon, but I would recommend using BookPool.com. They are only a technical book reseller, and they have better prices than amazon. As far as I can tell, bookpool.com has the best prices for its books on the web. Just a suggestion.
Excellent. I had a Barnes and Noble web coupon for $10 off any purchase over $25 one day last week, I happened to see this and ordered it. It came yesterday, haven't cracked it open yet. Glad to hear this was a good choice. I think it cost me like $19 total. :-)
I'm not exactly a "beginning" Linux programmer -- I've been writing C code and scripts under Linux for 4 years now. However, this sounds like a book I need anyway. There are numerous topics I have not yet delved into where I would like a quick introduction instead of a dedicated (expensive) topic-specific reference. I think I'll buy it... thanks for the comment.
Geeky modern art T-shirts
Beginning Linux Programming
by Neil Matthew, Richard Stones
List Price: $39.99
Our Price: $31.99
You Save: $8.00 (20%)
Paperback - 1000 pages 2 edition (September 1999)
Wrox Press; ISBN: 1861002971
This item will be published in September 1999. You may order it now and we will ship it to you when it arrives.
(from Amazon.com)
I haven't seen any books similar to this. I only see UNIX/Linux "user" books (installation process, basic utilities, etc) and advanced programming tomes (A-W's excellent "Programming in the UNIX Environment").
I think that this may be the only good "beginning" UNIX programming book out there... if there are others, please tell me what they are!
BTW, I agree with the "this is not a Linux book" comments -- it really is a general UNIX book relabeled to sell better. Which is good, since I'm rather partial to FreeBSD myself :}
|
- "The Dude abides" -
|