Slashdot Mirror


Linux Programming by Example

Simon P. Chappell writes "Linux programming is the C Programming Language. Elaborating a little, Linux programming is C, with the GLIBC library and the POSIX standard API. Even a language as powerful as C needs libraries and to get the Holy Grail of cross-platform portability, it's necessary to have them standardised. The POSIX API is that standardisation and Linux adheres to it very well (opinions from those litigious folks in Utah aside). For those of us who already know C, Linux Programming by Example sets out to teach you the rest in a step by step, helpful, relaxed and incremental manner." Linux Programming by Example author Arnold Robbins pages 687 (21 page index) publisher Prentice Hall rating 10 reviewer Simon P. Chappell ISBN 0131429647 summary An exellent tutorial for real-world Linux software development

What's To Like There are many things to like about this book (over and above the fact that page 118 has my all-time favourite UserFriendly cartoon on it :-). Linux Programming by Example (LinuxPbE hereafter) takes a steady, incremental path through the concepts required to write software that can effectively interact with the Linux environment.

It is a truism many of us have proven multiple times in our lives that one of the finest learning tools available to programmers is to read and grok good, working code, written in the language that we are learning. LinuxPbE takes this philosophy and walks you through actual example code from various Unixes and Linux. The first part of the book, specifically chapters one through six, covers all of the aspects of Linux programming necessary to understand the Unix V7 ls program in its full glory in chapter seven. I feel that this approach works very well.

Part two dives into processes, walking us through creating them, managing them, communicating with them by using pipes and sending them signals. A few other general topics are included for completeness. Part three then covers the art and tools of debugging in fairly substantial detail.

All the code in the book is very well laid out, with line numbers provided to the left, and comments (in a small sans-serif font) on the right-hand side of the code. This is a very readable combination that is enhanced further by the fact that at each logical division, an explanation is given of the design and implementation used by that section.

I can't resist admiring the addition of the essay "Teach Yourself Programming in Ten Years" by Peter Norvig. This is a classic exploration of the effort needed to attain mastery of any skill, concluding that the minimum length of time required is ten years. The inclusion of this article, to me, speaks well of the author and his understanding of the learning process. One can only hope that those learning from this book will come to the same understanding and realise that the book is the start of their journey to mastering Linux programming.

What's To Consider

Nothing notable.

Summary If you want to learn how to do this stuff for real, then this book will get you started. As "Teach Yourself Programming in Ten Years" explains, no book is going to cause you to become an expert in 24 hours, 24 days or even, perhaps, 24 months. That said, this book will be useful for many of those ten years, so run or surf to your favourite bookstore and purchase it now.

You can purchase Linux Programming by Example from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

26 of 119 comments (clear)

  1. I do most of my coding by example by Anonymous Coward · · Score: 3, Funny

    Cutting and pasting makes things really easy.

    1. Re:I do most of my coding by example by Anonymous Coward · · Score: 5, Funny

      That's what Linus taught me when we met. He had that huge CD library from SCO Developer Network and he showed me how easy it was to copy-paste.

    2. Re:I do most of my coding by example by Fearless+Freep · · Score: 2, Insightful

      Sheesh, with X you can cut and paste between machines

  2. Finally. by KimiDalamori · · Score: 5, Funny

    Now all we need is a "Linux Documentation Writing by Example" Then we could tell people WTFM instead of RTFM. =)

    --
    Lagito ergo expectabo
  3. Bookpool! by jargoone · · Score: 4, Informative

    This particular book is currently out of stock there, but I just thought I'd mention one of my favorite sites, bookpool.com. This particular book costs 15% of the list ($6) less than Barnes and Noble. They have great service and fast shipping (often free if you purchase enough).

    No affiliation whatsoever, just thought I'd share.

    1. Re:Bookpool! by fingusernames · · Score: 3, Informative

      Yeah, I started using Bookpool when I was in college, around 92 I believe. Whenever it was, it was before it was a web site or had a domain or was even a company. "It" was just a mailing list, you'd say what book you wanted, and when enough wanted it, they'd go for a group deal from the publisher. It has always had the best prices. For technical books, there is simply no need to look anywhere else.

      Larry

  4. automake, autoconf, .src.rpm, ... by Speare · · Score: 5, Interesting

    The common meta build tools can be a nightmare to learn all at once.

    • autoconf
    • automake
    • patch files
    • .spec and .src.rpm
    • .deb
    • -devel packages vs user packages

    While these are not essential to the beginning developer, having a chapter which covers the background, the problem, the solution and the practice of each of these "meta" tools would be really useful to get new developers going. They don't have to be covered in detail, but really honestly understanding WHY a project might be using a given meta build tool can help more people get involved.

    --
    [ .sig file not found ]
    1. Re:automake, autoconf, .src.rpm, ... by ron_ivi · · Score: 5, Interesting
      Indeed. Did you guys ever check out the GNU/HelloWorld program?

      It's A 380K Tar file! with over 2000 lines of C code.

      The first time I thought it was a parody, but it's really an insightful look at Internationalization, cross-platform build environments, and other things important to free software. I didn't RTFB that was reviewed, but I hope it goes into these important topics as well. I think this emphasis on coding standards that value the less visible aspects of software such as build environments, internationalization, etc is one of the big advantages of open source.

    2. Re:automake, autoconf, .src.rpm, ... by TomorrowPlusX · · Score: 3, Funny

      Notice however, that in the grand style of old: it even includes a mail reader.

      --

      lorem ipsum, dolor sit amet
    3. Re:automake, autoconf, .src.rpm, ... by tcopeland · · Score: 4, Informative

      There's a good book on the auto[blah] part of that - it's GNU Autoconf, Automake, and LibTool.

      It gives a good overview, as well as some extras - i.e., chapter 21 - "Writing Portable Bourne Shell".

  5. Re:What Linux needs is VB by slash-tard · · Score: 4, Funny

    I agree. I tried to import the 2.6 kernel into a VB project and couldnt get it to compile despites hours of trying to tweak the code.

    I did manage to get it to compile with C# but I got some weird errors when running it with the .NET runtime.

  6. Litigious folks? by Fjord · · Score: 3, Funny

    I thought the appropriate google bomb was litigious bastards.

    --
    -no broken link
  7. IP violation by Anonymous Coward · · Score: 4, Funny

    This is Darth McBide here - I don't often make it a habit of stopping by Slashdot and I have promised myself to take a shower wafter posting this message.

    To the point, I would like to bring it to your attention that any "Linux Programming by Example" would unavoidably be a violation of our broad reaching IP. For reasons that are quite beyond anyone here we cannot tell you the exact contents of our IP so how the heck are you going to know when your examples are going to tread on our property? So please take my advice and refrain from publishing anything that could trigger another lawsuit...

  8. The Power of C? by Animats · · Score: 2, Funny
    even a language as powerful as C.

    Can we mod the original article as +1, Funny?

    1. Re:The Power of C? by Angst+Badger · · Score: 2, Insightful

      I think you are confusing "powerful" with "high level". C is an extremely powerful language, second only to assembly, in that you can write programs in C to do anything within the capabilities of the underlying hardware. The tradeoff you make when using a relatively low-level language is that many common tasks are a pain in the ass, memory management being one of the obvious examples. But the other side of that tradeoff is that higher level languages make common tasks trivial at the expense of rendering certain less-common tasks difficult or even impossible. The designers of high-level languages are quite conscious of this as is demonstrated by the near-universal provision for interfacing with code written in C.

      Power and ease-of-use are not the same thing. Many people use different text editors for programming (vi, emacs) than they do for editing email (pico, joe). Languages are no different.

      --
      Proud member of the Weirdo-American community.
    2. Re:The Power of C? by prockcore · · Score: 2, Funny


      double the_power_of_C = pow(x,299792458);

  9. example code by gandalf013 · · Score: 2, Funny
    I haven't seen the book, but I checked some examples from the book.

    I can see the following "problems" with some of them (if I am wrong, someone please correct me):

    ch02-printenv.c:

    #include <stdio.h>

    extern char **environ;

    Shouldn't there be a #include <unistd.h> after the #include <stdio.h>? The extern variable environ is available only if unistd.h has been included. While I am talking about this example, it could have used int main(void) instead of ...(int argc, char **argv) (like he does in ch03-getline.c).

    ch03-getline.c:

    printf("(%lu) %s", size, line);

    size is declared size_t, so it should be printed with %z (C99 only, IIRC), or it sould be cast (unsigned long) size.

    ch03-memaddr.c:

    uses global variables, when simply adding two parameters to afunc will do the job. I know it's a trivial example, but global variables are bad in general, and certainly avoidable in this case.

    casts the result of alloca when there is no need for it. In fact, the cast will remove the warning the compiler might give if someone forgot to #include <alloca.h>.

    I haven't checked other examples.

    1. Re:example code by aridhol · · Score: 2, Informative

      Read that site again. You'll find that int main(void) is legit, it's void main(void) that they don't like. And, according to the C standard, it's one of the two legal signatures for main (the other is int main(int argc, char **argv)).

      --
      I can't say that I don't give a fuck. I've just run out of fuck to give.
  10. Umm, whats with that user friendly comic. by Ziviyr · · Score: 2, Funny

    DOS-heads gloating to each other in front of an Amiga calendar.

    I find that so incredibly weird, my head might implode...

    --

    Someone set us up the bomb, so shine we are!
    1. Re:Umm, whats with that user friendly comic. by Spoing · · Score: 2, Informative

      DOS didn't have inodes. The comic is multi-platform. :)

      --
      A firewall can not protect you from yourself. Turn off what you do not need. Do not use the firewall to do your work.
  11. re "Teach Yourself Programming in Ten Years" by kclittle · · Score: 3, Informative
    I've been programming for 30 years. I recently discovered Python. I'm ass-deep in the uglyness of XML. I'm getting comfortable with Linux, beginning to understand where it's like *nix and where it's not. I'm reading up on .NET; some of it's new, some of it's borrowed, some of it's ugly, some of it's pretty neat. I'd like to get a chance to play with Erlang or ML.

    In short, I am *still* learning, and there are areas I've not even scratched. And I'm having a ball! Ten years? Heck, it may take me fifty!

    --
    Generally, bash is superior to python in those environments where python is not installed.
  12. What *I* would like to see... by dmomo · · Score: 3, Insightful
    Is a 'real world' book on programming for Linux for people who already know how to program. I would buy this book in a heart beat. Let me explain. I know how to program already, and for the most part, what I would be follow ANSI specifications, and should compile uder LINUX. What I would like to see is a book that would explain how to properly write a program for the linux desktop.


    It would explain how to work nicely with KDE and GNOME and what the differences would be. Also, how to make a robust applicaiton that is easily integrated into both environments. It would explain QT v. GDK. It would explain what I, as a programmer should do to make my application work well with others. It would explain how to make a nice installer. How to detect required packages, What command-line options are standard, what API and hook functions should be available.


    Instead of "Learning to Program using LINUX", it would be "Learning to Program FOR LINUX". I would like to know what conventions exist so I would not try to reinvent the wheel.


    Most of this is freely available information that is easy enough to find already. But, I would be willing to pay for a one stop shop that would get me started in the right direction.


    I have yet to see a book that would be a good getting started guide, and then, a good reference. For now, most projects I start by tinkering and prodding, (which is good too), but I would love to create more powerful applications.

    1. Re:What *I* would like to see... by Spoing · · Score: 2, Insightful
      1. Is a 'real world' book on programming for Linux for people who already know how to program. I would buy this book in a heart beat. Let me explain. I know how to program already, and for the most part, what I would be follow ANSI specifications, and should compile uder LINUX. What I would like to see is a book that would explain how to properly write a program for the linux desktop.

      It looks like you're interested in about a dozen books. There's a lot of variety out there!

      --
      A firewall can not protect you from yourself. Turn off what you do not need. Do not use the firewall to do your work.
  13. Linuxosity by Brandybuck · · Score: 4, Insightful

    Go grab a "Linux" program at random. Any "Linux" program. Cervisia, GIMP, Emacs, bash, Xmms, etc. Funny thing, they all build and run flawlessly on Solaris, FreeBSD, IRIX, etc. Why? Because they're NOT "Linux" programs!

    Unless you're writing stuff that depends upon a Linux kernel, you're not doing Linux programming, you're doing standard Unix programming. glibc is nothing more than GNU's libc. And libc is pretty damned standard.

    --
    Don't blame me, I didn't vote for either of them!
  14. Re:re "Teach Yourself Programming in Ten Years" by adamofgreyskull · · Score: 2, Interesting

    Do you think this is linked to the state of the industry? I mean, does anyone have enough time to truly *master* a language anymore? Using the analogue of a master craftsman e.g. a cabinet maker, they would spend all their life working with tools which only very very very rarely change.

    In the 4 years I've been programming *properly, I've used Delphi, Java, C, C++ , Qt and SQL. I am nowhere near knowing all there is to know about any of them. I'm sort of worried that I'll never really be able to _master_ a language...

    *at university,on placement and varying from trivial to decidedly non-trivial...

  15. Re:re "Teach Yourself Programming in Ten Years" by bani · · Score: 3, Insightful

    Nobody masters a language anymore. You master _techniques_. Languages are just syntaxes to implement those techniques.

    To put your analogy to use, there's really only so many ways (techniques) to build a cabinet. The different programming languages would be the different tools you use to apply those techniques to build a cabinet.

    The nice thing about learning different languages is it often reveals to you new ways of doing things, which you can then apply to languages you already know.

    You'd do well to learn Perl or PHP, btw.