Slashdot Mirror


Review:Beginning Linux Programming

Kurt Gray sent a review of Beginning Linux Programming, by Neil Matthew & Richard Stones. Click here to learn how to contribute more code. Beginning Linux Programming author Neil Matthew & Richard Stones pages 710 publisher Wrox Press rating 8/10 reviewer Kurt Gray ISBN summary A fair time worthy of your UNIX programming virginity.

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.

Dropping the "L" Word:


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.

Perspective:


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.

What's Good:
  • 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.
Overall: It's a keeper. I think even the seasoned UNIX programmer would find it useful due to the variety of topics covered therein. Handy for answering the simple questions like "How I read/write to a DBM file again?" This copy is staying in my office bookshelf.

Pick this book up at Amazon.

Table of Contents:

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...

67 comments

  1. No mention of Perl by Anonymous Coward · · Score: 0

    You mention that the book has spent a lot of effort in teaching TCL but hardly any in perl. It could be that not everyone likes programming in Perl, some people would choose Tcl over Perl any day. If they had included Perl the book would be much bigger (and it's already HUGE). Anyway O'Reilly make some excellent Perl books and something as big as perl really does need a book to itself.

    Lindsay Marshall (charman of the UK Linux users group) - if you're reading what is so bad about Perl anyway?

    1. Re:No mention of Perl by Anonymous Coward · · Score: 0


      What's wrong with Perl?
      No type system to speak of, leading to more run-time debugging. Non-orthoganal syntax, behaviour isn't well defined, one cannot write correct programs that use stdio thanks to the lack of an _exit().

      Where should I stop?

    2. Re:No mention of Perl by Anonymous Coward · · Score: 0

      No type system to speak of

      Types are inferred from their context. treat a scalar like a number and so will perl. the 21st century is calling - time to hang up your lisp/ml puritinism - those languages were never any good for GETTING WORK DONE NOW. I emphasize that because perl lets you get things done much quicker than anything else.

      Non-orthoganal syntax

      Then by all means stick to Common Lisp. I rather like being able to "force" a language to treat things just as I need them treated, even if it ain't kosher by Dijkstra.

    3. Re:No mention of Perl by cian · · Score: 1

      >>No type system to speak of
      >
      >Types are inferred from their context. treat a scalar like a number and so will perl. the 21st
      >century is calling - time to hang up your lisp/ml puritinism - those languages were never any good
      >for GETTING WORK DONE NOW. I emphasize that because perl lets you get things done much quicker
      >than anything else.

      There was a reason for types and that was you'd rather the compiler picked up your bugs, than have to try and work out what went wrong at run time (when your code is treating your string as an integer, or vica versa).

      Perl's good for a quick hack, where you're not going to keep the code. But try and maintain it...oh boy.

      Cian

  2. I don't like this book. by Anonymous Coward · · Score: 0

    It has a lot of page all right. But it
    is not a good book.

  3. Open Source Anyone? by Anonymous Coward · · Score: 0

    What do you mean there is no open source info? I happen to have the book, and it has a full copy of the GPL in the one of the Appendices...maybe you should double check that one...

  4. Unix programming book ? by Anonymous Coward · · Score: 0

    The reviewer says it's more a unix programmiong book. Actually this is good, it assures that you're not using some kind of linux extension not found on other unixes.

  5. Not so much info on Linux because... by Anonymous Coward · · Score: 0

    The book, in the introduction, states that it is geared towards the person who is already reasonalby familiar with using Linux, but not with programming it. One can infer from that that the authors ass-u-me that you already know that the source code is there, and what the benefits of that are.

    I bought this book a few weeks ago, and it is a permanent desk item now. I HIGHLY recommend it for any person starting programming on Linux.

  6. Best Linux Book out there by Anonymous Coward · · Score: 0

    I bought this book a couple years ago and I can say its one of the best Linux books I have ever seen. It covers a lot of the basic stuff like sockets, pipes, and IPC. The extra parts on web applications are nice. And although it doesn't teach any perl, it does use some perl code as an example of a CGI program. Anyone who wants to program in Linux should read this. It may not have everything, but it sure as hell will explain enough to get you pretty far for any project you are working on.

    1. Re:Best Linux Book out there by Anonymous Coward · · Score: 0

      thanks - i already ordered my copy on amazon and can't wait to get it.

      i've been reading sams' teach yourself shell programming with great interest and this sounds like a great follow-up!

    2. Re:Best Linux Book out there by Jburkholder · · Score: 2

      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. :-)

  7. Re:C strings... by Anonymous Coward · · Score: 0

    At the very least use fgets instead of gets so you can put a limit on the number of characters to read. Also, GNU provides a special input routine for reading buffers of any length, but it's not standard and I've never used it.

  8. Re:C strings... by Anonymous Coward · · Score: 0

    i think the bad habit here relates to the potential buffer overflow problem which could produce a security risk if exploited correctly.

  9. Re:C strings... by Anonymous Coward · · Score: 0

    There's nothing inherently wrong with using fixed-size character strings. What's important is to make sure that when using them, you check every write operation for overflows. That means using fgets instead of gets, strncopy instead of strcopy, strncat instead of strcat, etc.

  10. Re:Good thought, wrong context by Anonymous Coward · · Score: 0

    I think it's important to understand that the focus of this book was not to TEACH TCL or Perl, but to give the reader a taste. Granted, I think perl needs more than 2 pages to give a reader a good taste, but I believe the idea is still appearant. 'Heres some perl, heres some TCL, heres some C and C++... if you want more, there are other books out there that teach specifically that language.'

    Don't forget. Not everyone is cut out to become an ASM coder. Everyone get's their niche.

  11. Re:Out of Stock at BookPool by Anonymous Coward · · Score: 0

    The book is cheaper at bookpool, 29.99 @ Amazon, 22.95 @ Bookpool. But the book is out of stock at bookpeople and in stock at amazon, maybe as a result of this article? Anyway I guess you could just wait, but who wants to wait?

  12. Re:What's wrong with Perl ? by Anonymous Coward · · Score: 0
    >> No type system to speak
    >Ho, ho, ho, seen Perl 5 ?
    >More of a type system than SmallTalk.

    OK, I accept that if you restrict yourself to using objects; create yourself object types for integers, object types for strings, and everything else, you could build a type system from the ground up. But why would I want to?

    So that there's probably a module that has somebody else's attempt at this. But I still don't want to have to call a method on my integer to add it to another.

    >> Non-orthoganal syntax
    >err.. ?? Designed by a linguist to have a natural
    >syntax rather then theoretically perfect but pain
    >to use languages (Pascal, Oberon, ML, etc.)
    >maybe, but that's a plus point for Perl.

    I like ML...

    I can never guess what the operator for a given task is going to be in Perl. I always need the documentation. I don't find it intuitive. I may be in a minority in that, but it's a reason I don't like Perl.

    >> one cannot write correct programs that use stdio thanks to the lack of an _exit().
    >Say what ?

    Say "correct", as in don't potentially lose data from unflushed streams.

    >A million CGI programmers have no problem with stdio.
    >And if you need _exit(), how about use POSIX "_exit";

    OK, I'm wrong. Reading the perlfunc 5.005 manpage, this is now explicitly mentioned (it wasn't in 5.004). Thank you for drawing this to my attention.

    Reason:
    _exit is neccessary for correct termination of a program. exit() doesn't fail if it can't flush a stream. Therefor if you want to guarantee that you haven't lost data, you must explicitly close all file descriptors, deal with any errors, then call _exit to ensure that the stream buffers aren't flushed again. What does exit() do to buffers if they couldn't be flushed the first time? Possibly they're flushed, possibly not, who knows?. It's still not a great feature that a command neccessary for writing programs that don't lose data is stuck in some module, and only recently documented in the main body of information on the language.

  13. APUE by Anonymous Coward · · Score: 0

    APUE IS THE BOOK YOU NEED!

    Advanced Programming in the Unix Environment, by Stevens.

    Then, get "Programming Perl".
    After that, get "Unix Network Programming".
    Maybe get the O'Reilly X11 programming books.



    ---
    Crypt.X forgot his password.

    1. Re:APUE by Waldo · · Score: 1

      Stevens is the man. If I could only read one programming book, APUE would be the one.

  14. Re:C strings...(with FREE code :)) by Anonymous Coward · · Score: 0

    What cha all think of this madly stupid piece of code?

    char c, *string, *buf;
    int i = 2;

    string = (char *)malloc( i );
    string[ 0 ] = getchar(); string[ 1 ] = 0;

    while( (c = getchar()) != '\n' ) {
    i += 1;
    buf = (char *)malloc( i );
    strcpy( buf, string );
    free( string );
    buffer[ i-2 ] = c; buffer[ i-1 ] = 0;
    string = (char *)malloc( i );
    strcpy( string, buf );
    free( buf );
    }

    excuse crappy formatting

  15. Re:Programming Book by Anonymous Coward · · Score: 0

    The book that taught me how to program C was "The 'C' Primer Plus" from Waite publishing.

    Simply the best beginner to intermediate C book I've ever read.

  16. Very good indeed. by Anonymous Coward · · Score: 0

    Frankly I was shocked to discover how useful
    this book was. As someone who has picked up
    lots of unix cr@p over the years it was nice
    to finally have a source which lined up all
    the important stuff and made sense of it all.
    Danke.

  17. Re:Use BookPool, not Amazon by jbaugher · · Score: 1

    Even better, go to AddALL, and search for lowest price. It's like PriceWatch for books.

  18. Re:What about portability? by Micah · · Score: 1

    It's been several months since I read the book, but I don't remember it making any (or much) use of linux.h at all.

    It also clearly explained the different symantics of the select() call between Linux and other UNIXes. That emphasized portability nicely IMHO.

  19. Definitely a great book. by Micah · · Score: 1

    Other comments...

    1. Some things are a bit out of place in a book like this - HTML and CGI for one thing. There are ZILLIONS of books on those, and with PHP or mod_perl, CGI is pretty much irrelevant anyway.

    2. It's good about emphasizing differences between Linux and other UNIXes. There aren't many, but it did mention some, as in the select() call. Valuable stuff.

    3. Its examples are great when you want to get some code quickly cranked out. You can cut and paste a lot of it into your own programs.

    Overall, this and _The C++ Programming Language_ are probably the two best non-O'Reilly computer books.

  20. Re:C strings... by John+Campbell · · Score: 2

    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...

  21. Re:C strings...(with FREE code :)) by John+Campbell · · Score: 2

    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. */

  22. Re: Yes, it mentions Open Source... by Kurt+Gray · · Score: 2

    ...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".

  23. I Disagree by Misfit · · Score: 1

    I've read most of this book, but gave up and decided to read "Advanced Programming in the Unix Environment".

    I didn't like "Beginning Linux Programming" for one main reason. It tries to cover way too much in too small of a space. It covers everything from shell scripting to X11 programming(but tells you it's a waste of time and you should use a toolkit) to Tcl/Tk. It covers just about everything, but covers nothing well.

    I would suggest you save up and buy a bunch of smaller books from O'Reilly than buying this one. At least you'll get some information that you can use.

    Save your money.
    Misfit

    1. Re:I Disagree by rotenberry · · Score: 1

      I didn't like "Beginning Linux Programming" for pretty much the same reasons.

      A much better book is "Linux Application Development" by M.K. Johnson and E.W. Troan.

  24. Linux Application Development by tzanger · · Score: 1

    VERY good book. It's sitting under my mouse right now at home. :-)

    Honestly, this book gives you the skinny on how to program for a unix-style environment. It does NOT cover X, Tcl/Tk, shell or perl. It covers C and how to use the library functions given in an ANSI/Unix environment to a very high level of usefullnes.. Shared memory, semaphores, devices...

    It's as good as Programming Linux Kernel Modues book, published by ORA. That one's beside my bed, although it hasn't been openned in quite some time now.

  25. Re:Programming Book by Sourdough · · Score: 1

    I haven't seen this book, but it looks like it probably doesn't do a very good job of teaching C, though it probably doesn't require any previous knowledge. I would strongly suggest that if you're going to do any C programming, get Kernighan and Ritchie's _The C Programming Language_ (Prentice Hall). It is useful both for learning the language (it's in a textbook-ish format and has problems), and is also very useful as a reference.

  26. Re:Use BookPool, not Amazon by dattaway · · Score: 2

    OrderHere is that link at bookpool.com and the price including fedex 2 day is only $30. Thanks for the link!

  27. Re:Out of Stock at BookPool by dattaway · · Score: 2

    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!

  28. Re:Programming Book by Squeamish+Ossifrage · · Score: 1

    Yep, asking too much. Or rather giving up too much. There are some absolutely wonderful C programming books, but they don't cover GTK. Uneqiuvocally, I recommend O'Reilly's "Practical C Programming" It's not platform-specific, but takes a very unixy approach. It is a potentially difficult book, tackling some algorithms and data structures, including pointers and memory management. These might be drawbacks to the neophyte programmer, but are definitely a plus if you come in with some experience.

  29. Re:What's wrong with Perl ? by MeerCat · · Score: 1

    >> No type system to speak
    Ho, ho, ho, seen Perl 5 ?
    More of a type system than SmallTalk.

    >> Non-orthoganal syntax
    err.. ?? Designed by a linguist to have a natural syntax rather then theoretically perfect but pain to use languages (Pascal, Oberon, ML, etc.) maybe, but that's a plus point for Perl.

    >> behaviour isn't well defined
    As in what behaviour ?
    Seems as well defined as any other cross platform language to me, if not better (Perl is often more portable than Java IMHO).

    >> one cannot write correct programs that use stdio thanks to the lack of an _exit().
    Say what ?
    A million CGI programmers have no problem with stdio.
    And if you need _exit(), how about
    use POSIX "_exit";

    >> Where should I stop?
    Perl has its flaws, as does every engineering compromise, but these aren't it...

    And remember, this was in comparison to TCL.

    Tim

    --
    I spent a lot of money on booze, birds and fast cars. The rest I just squandered. - George Best
  30. WROX Press by Sontas · · Score: 1

    Just about any book out of that publisher is good. Forget Sams or Que, these books are some of the best money can buy. I picked this particular title up a little over three weeks ago and have used it a few times since then. As the review above said, it does indeed cover a lot of material and does so coherently and in an easy to digest manner. Highly recommended to the beginner and the seasoned professional just looking for a good reference on most major linux programming areas. If tied together with a good programming theory book the pair would be ideal for beginning to intermediate computer science courses.

    As far as this book over looking Perl, it was probably a choice, not an oversight. There are already several books out there on Perl and many more books that touch on it in relation to other topics. There wasn't a good general "catch all" title out there though... they filled that void. Sure they could have thrown it in, but I don't think that it takes that much away from the value of the book.

  31. A better refresher than tutorial by A+nonymous+Coward · · Score: 1

    This book is like man pages; it refreshes more than teaches. I find it indispensable when I have to use, say, semaphores and shared memory, and haven't used them for a year or so. Instant memory awakener. You better know C first, and have some concept of multiple processes communicating together (race condistions, deadlocks, etc).

    I will certainly buy the next edition, but it had better continue the style and content. Add new chapters, but don't take away the old.

    --

  32. SAMS books and shell programming by Dictator+For+Life · · Score: 1
    Two totally unrelated points/opinions:

    First, I would strongly suggest you avoid SAMS books. Like the plague. Sometimes (in the past, and never to be repeated if I can help it) I would buy SAMS books on subjects about which I know a thing or two. In literally every case I've found these books to be full of gross errors. And this doesn't address the shoddy editing that fairly permeates them. Avoid SAMS. Buy O'Reilly (unabashed and uncompensated endorsement -- and no, I don't work for them)!

    Secondly, I'd say you ought to skip O'Reilly's bash book if you're learning shell programming. This one title is the most disappointing O'Reilly book I own. It was none too clear, and contained very little in the way of practical examples. It's somewhat useful as a general introduction to using bash, but I don't think it's all that hot at teaching shell programming. IMO Beginning Linux Programming is much better at introducing that -- even though it has just one chapter on the subject. Hopefully O'Reilly will improve their bash book, though.

    --

    DFL

    Never send a human to do a machine's job.

  33. Use BookPool, not Amazon by marvinx · · Score: 2

    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.

    1. Re:Use BookPool, not Amazon by andyNola · · Score: 1

      Pretty cool. I checked out 4 random books at both Amazon.com and Bookpool.com (Developing Linux Applications, Linux Application Development, Linux Device Drivers, LINUX Kernel Internals). The lot, including ground shipping, costs $133 on Amazon vs. $113 on Bookpool. Only problem I see offhand is availability--Linux Device Drivers is out of stock at Bookpool. :(

      --
      -- This .sig is not here yet!
  34. Link? by DeathB · · Score: 1

    Where's the link for "here"

    --
    Would you do it for some scoobie crack?
  35. Re:C strings... by FigWig · · Score: 1

    Use
    fgets( string, n, stdin ) for input
    Use
    snprintf( string, n, format, params ... ) for creating strings
    Use
    strncpy( str1, str2, n ) to copy
    Etc...
    These routines restrict the number of characters that they deal with to n, thus preventing buffer overflow exploits that write pernicious values to the stack and cause your functions to return from whence they did not come.

    Also a good habit to
    str = (char*)malloc( strlen( s ) + 1 );
    instead of just allocating a really big array or something.


    --
    Scuttlemonkey is a troll
  36. Re:Programming Book by FigWig · · Score: 1

    If you know ASM you shouldn't have problems with C. C is just ASM with some syntactic sugar ;)

    --
    Scuttlemonkey is a troll
  37. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  38. Programming Book by finkployd · · Score: 1

    I'm looking for some book (perhaps this is it, but I don't know) to learn to write linux programs. I have a slightly odd background, I started (like may of my misguided friends) on QuickBasic, then jumped straight into Assembly language, never really learing c that well.
    I guess my ideal book would be one that taught c programming, but also integrated it with GTK for the beginner.
    Asking too much? :)

    Finkployd

    -The true rebel will ignore the Preview button and go straight for Submit

  39. A little hard on it...? by parm · · Score: 1
    I bought this book about a year ago, and it was one of the best purchases I made. It's a great step-up to Linux type book - I could already program in C, and had a working knowledge of shell and stuff, but had never done any real *ix programming before; this book was a real boon in learning how to do it.

    Admittedly a few of the examples are a bit contrived, and some of the networking section isn't wonderfully explained, but as a quick stepup for people coming from other platforms to Unix, its great...

    --
    -- I reserve the right to be completely wrong --
  40. Re:C strings... by warmi · · Score: 1

    Switch to C++ and use String class. Problem solved

  41. What about portability? by yonderboy · · Score: 1

    The biggest problem I see with this book is that there is no mention of writing portable code. Linux programs, in particular, lack in this area. #include <linux.h> just doesn't cut it when it comes to trying to run software across multiple platforms.

    1. Re:What about portability? by vipvop · · Score: 1

      Appendix A is "Portability".Mentions different sizes of int and others on different systems, byte order, etc.

  42. But. . .but. . .the publisher!! by npavona · · Score: 1

    Wrox. Bah!

  43. Re:C strings... by WNight · · Score: 1

    How to properly allocate string space? Well, malloc() works..

    You mean though, how to allocate enough space that you don't get overflows.

    Can't be done. Any buffer you can allocate can be overflowed if someone tries hard enough.

    What you need to do is allocate a certain buffer, n bytes for instance, and read only n-1 bytes from the input. Use an fgets() call to read a certain number of bytes, or if you're reading one byte at a time, simply keep track of how many you've read and when it gets to n-1, write a zero to terminate it and exit.

    Being that ram is 'cheap', I usually allocate 4k buffers at a minimum, even for command lines and other 'small' strings. Then I use a strncpy or fgets to read data into the string. Both of these functions have the benefit of reading a certain maximum number of bytes and then terminating, regardless of hitting the end of the string.

    I can't see many reasons to make strings dynamic for the most part. Simply allocate as much space as you're going to need in the worst case. (Unless that worse case is a megabyte-long string...)

  44. the book i wish i had 2 years ago by rizzy · · Score: 1

    When i first installed linux (ah, what memories) i remember being overwhelmed (in a good way). Here I had many many packages -- most of which i did not understand and many i did not use for a year or more. The title says it all _Beginning Linux Programming_ -- if you are a newbie, this book is a great asset.

    A year ago I bought this book and within a month found it to be worth the price. I still have not found any reference that so clearly and succintly describes the curses/ncurses library. The philosophy of "a little bit of everything" is great -- if you want to learn more perl or tcl or... pick up an ORA book. but this book lets new users (and older users like me) know enough to find out more.

    yeah, the typical slashdotter learned all this stuff long ago. and if you develop under unix, this is old hat. but for the windows users who switch over to linux, this is required reading.

  45. C strings... by selectap · · Score: 1
    Sorry if this is a little off topic but here goes:

    Most of the C code examples reinforce bad habits such as feeding external data directly into fixed-length character buffers...I thinks its best to teach programmers while they're young so to save them a major rewrite later on.

    I haven't done C programming in a while so I don't remember how to do proper string manipulation. However my g/f is going to take a C class this fall so I need to get up to speed so that I can help her. What would be the correct way to allocate a string in order to allow external input, say from the keyboard? Anybody care to debate fixed size vs. dynamic size strings in C?

    1. Re:C strings... by Butch · · Score: 1

      Remember that strncpy() does NOT guarantee a null-terminated string.
      It adds the final '\0' only if the source string is shorter than the length parameter.
      strncpy(buf, input, sizeof(buf)); should always be followed by
      buf[sizeof(buf)-1] = '\0';

      Or use strlcpy() if your OS has it (OpenBSD) and you don't need ANSI conformance.

    2. Re:C strings... by HarpMan · · Score: 1

      Yes!

      You wouldn't believe how many "professional" programmers don't do this. Truncatation is OK (via strncpy) -- not great, but OK. Writing beyond the end of your allocated memory is just horrible. Where I work, we just had several nasty bugs because of things like this:

      char buf[16];
      strpcy(buf, getenv("SOME_VAR")); // aaaaaaah!

      Should be:
      char buf[16];
      strncpy(buf, gentenv("SOME_VAR"), sizeof(buf)-1);

      Of course, if you're using C++, you can avoid the whole issue by using the string class, which holds variable length strings:

      string s = getenv("SOME_VAR");


      --
      Stephen Molitor steve_molitor@yahoo.com
  46. Amazing... by DannyGene · · Score: 1

    I was just looking at Linux programming books over at Amazon and came across this. I was amazed at the reader reviews, where it received a 5 star average! Only a few 4 stars, tons of 5 stars! Then I head to Slashdot, and right at the top of the page, Beginning Linux Programming is staring at me. Is this an omen?

    --
    *Life is too serious to be taken too seriously.*
    1. Re:Amazing... by kkelly · · Score: 1

      heh only if it happened at 11:11

      --
      K
  47. Re:Best Linux Book out there... not just newbies? by Sun+Tzu · · Score: 2

    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.

  48. new edition coming by P.+Harmon+Devin · · Score: 2

    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)

  49. No Perl? Just you wait! by JATeXH · · Score: 1

    Yes, I know there's no Perl chapter in this one,
    although there will be at least one chapter on
    Perl in the next edition. I know, I've just
    finished writing it. :)

  50. I Agree to Disagree with those who Disagree by Kakurenbo+Shogun · · Score: 1

    For me, this was probably the best programming book I've ever read. But whether it's good for you or not depends largely on how you like to learn.

    >It tries to cover way too much in too small of a space.
    This is exactly why I loved it. It explained a huge number of points clearly and concisely, gave a brief code example, and then moved on without making me wade through another hundred pages on a topic I already knew all I wanted to know about. It's an ideal book for someone who likes to grab a book, read it cover to cover to cram a bumch of concepts in their head, have a reference in which it's easy to find exactly the piece of information that they're looking for, and then when they try it themself and it doesn't quite work, they're happy to bring up the man pages to get the rest of the details.

    But if you want to have all of the details in the book, if you want a comprehensive treatment of each topic, if you don't need a book to enlighten you about what's possible, but prefer a book where you can look up exactly how to do everything that's possible, then perhaps this isn't what you're looking for.

    --
    Convert RSS to HTML - integrate webfeeds into your website
  51. Does this book have any peers/competitors? by saundeam · · Score: 2

    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" -
    |
  52. Linux Not Unix by deKernel · · Score: 1

    I just bought the book, and now I plan on sending the book back. My guess was last year, the title was "Beginning Unix Programming". I was okay until there was a single paragraph on threading, and it said and I quote "At present, UNIX support for thread-based execution paradigm is limited. The POSIX.4 spec defines a thread mechanism useful for real-time applications of UNIX and implementations are finding their way into UNIX-derived systems, including Linux. (This part kills me!) Due to their relatively poor support at present, we won't cover them further here."
    First, count how many times UNIX is used, and second threading in Linux has "relatively poor support"!!!

  53. As always, check Best Book Buys by Jeff+Myers · · Score: 1

    Whenever you plan to buy a book online, it's a good choice to check on Bestbookbuys.com because they do a price compairison between 25 book sites (including shipping). The best feature I found was on the front page there's a listing of daily hot deals from the book stores. For example, here's the book being discussed and when you subtract the $10 discount on a purchase over $10 from BUY.COM, the final price (with shipping) is $21.66. Not a bad deal.

    - Jeff

    --
    -- Maybe all one can do is hope to end up with the right regrets. - Arthur Miller
  54. Revision Notification? by Wise+Dragon · · Score: 1

    It seems that only barnes and noble has a notification service for new books. I am having a problem getting the 'notify me when new books happen matching my search criteria' option to work. Can someone enlighten me on this? Or suggest another option so that I don't forget to buy the next edition of this?

  55. New Edition by goodviking · · Score: 1

    According to barnes and noble (http://bn.com), the second edition is comming out on September 20th of this year. Hopefully they will update it to include coverage of the current APIs.