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.

119 comments

  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 Anonymous Coward · · Score: 0

      It does unless you are using X-windows and you can't cut and paste between different windows.

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

    4. Re:I do most of my coding by example by Anonymous Coward · · Score: 0

      Never used it, have you?

    5. Re:I do most of my coding by example by October_30th · · Score: 1
      Uh. No.

      If I run xwin on cygwin on my Windows computer, I cannot copy-paste from Windows to a window in X. Just doesn't work.

      --
      The owls are not what they seem
    6. Re:I do most of my coding by example by garaged · · Score: 0

      Sorry for you

      --
      I'm positive, don't belive me look at my karma
    7. Re:I do most of my coding by example by Harry8 · · Score: 1

      Erm,
      Works good here.
      just selected your comment in win Mozilla.
      Middle clicked in an xterm logged into a remote machine running vi.
      started X with /usr/X11R6/bin/startxwin.sh (rootless xterm) in a cygwin terminal.
      Update your cygwin?
      Or select & copy in win (Ctrl+c)
      left click the top left corner of a regular cytwin terminal. Select Edit-Paste from the drop down menu.
      Cygwin, don't leave $HOME without it!
      Best of luck.

      (recent install of Cygwin running on XP)

  2. Linux routines by Anonymous Coward · · Score: 0

    while bankvault >= $0
    ..DarlsWallet == DarlsWallet + ($699 x StationCount)
    repeat until bankvault = empty

    1. Re:Linux routines by boisepunk · · Score: 1, Funny

      no, it's like this:

      #!/usr/bin/python
      while DarlsWallet:
      DarlsWallet -= 699
      Lawyer += 699
      raise SystemExit, "we're out of money!"

      --
      main(0)
    2. Re:Linux routines by Anonymous Coward · · Score: 0

      Smoke bagging cock tea'ers

  3. 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
    1. Re:Finally. by Anonymous Coward · · Score: 0

      Want an example of good documentation writing? Try FreeBSD!

    2. Re:Finally. by Anonymous Coward · · Score: 0, Funny

      what good is excellent documentation for a deceased OS?

    3. Re:Finally. by Fearless+Freep · · Score: 1

      Well...it stays current... :)

  4. 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 stoolpigeon · · Score: 1

      When I was in school - I would do a lot of comparison shopping for books- but bookpool had the lowest price so frequently that I quit looking around and just went straight there.

      I saved tons of money over buying them from the school book store.

      --
      It's hard to believe that's how Micronians are made. Why don't we see it right now by having you both kiss one another?
    2. 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

    3. Re:Bookpool! by 2names · · Score: 1
      Oh yeah, well I started using bookpool when the list was maintained by carrier pidgeon, and you didn't get a book at all, you had to watch the western sky for smoke signals. You could only get about one page per day, though.

      --
      "I'm just here to regulate funkiness."
    4. Re:Bookpool! by fingusernames · · Score: 1

      Cool. When was that?

      Larry

    5. Re:Bookpool! by 2names · · Score: 1
      It was...well...um...well it was a _long_ time ago, I'll tell you that. So long that we didn't even have calendars, so I can't really tell...

      aw crap. I'll stop now.

      --
      "I'm just here to regulate funkiness."
  5. What Linux needs is VB by Anonymous Coward · · Score: 0, Funny

    Hi, I'm a VB programmer, and the problem I'd have with writing software for Linux is that there's no version of Microsoft Visual Studio for Linux.

    If Linus Torvaldes had written Linux in VB I think that there would be more commercial applications for Linux today. We don't need more books on C/C++; we need more tools to get modern languages like VB to work on Linux.

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

    2. Re:What Linux needs is VB by Anonymous Coward · · Score: 0

      I agree, sort of. But first I have to get some zealotry off my chest, sorry.

      I think anyone who only wants to use VB for Linux application development deserves to be dissapointed, its a horrible language, what benefit is there to facilitate such an awful language for Linux development?
      Similarly I think anyone who only wants to use C/C++/Java for Linux application development deserves the pain and suffering they bring upon themselves, and should be shot for bringing it upon others who inherit/work with their projects.

      But i'm a zeolot, so what does it matter what I think :)

      But I would be a fool to forget the benefits of using tools such as Visual Studio for people exploring, and exploring is a fine thing to promote. I'm not saying I would use such an environment myself, but the Visual environment is a great tool for people to learn, play, and explore or just make simple things really really quickly, which is good.

      The "Linus Torvaldes had written Linux in VB" comment shows a gross misunderstanding about a lot of things, which isn't a problem, but its probably why you got modded as a troll. Lets just say that you can't write an operating system in VB, and Linus' Linux project hasn't got anything to do with system programming or C.

      Unix probably would benefit from a really good Visual Studio type environment, but please not Visual Basic, anything but Visual Basic. At the very least Visual Python or Visual Ruby, i'm sure most Basic programmers would never look back given such lovely languages as these in a near identical environment.

    3. Re:What Linux needs is VB by Anonymous Coward · · Score: 0


      Hi, I'm a VB programmer, and the problem I'd have with writing software for Linux is that there's no version of Microsoft Visual Studio for Linux.

      If Linus Torvaldes had written Linux in VB I think that there would be more commercial applications for Linux today. We don't need more books on C/C++; we need more tools to get modern languages like VB to work on Linux.


      Well, you are in luck. We have been working on Project Goliath. Project Goliath will implement the entire LES (Linux Execution System) including the kernel and X-Windows in Visual Basic.

      Our design has already been validated by MIT and CalTech as a sound design. We are even 10% completed with the design and implementation, see:

      Private Sub Form_Load()
      Debug.Print "Uncompressing Linux..."
      ' TODO: Do something
      Sleep 2000
      Debug.Print "Now booting the kernel"
      ' TODO: X11 Form
      ' frmX11.Show 1
      End Sub

    4. Re:What Linux needs is VB by gujo-odori · · Score: 1

      Am I the only one who got this joke? You really should have posted it logged-in, it's pretty funny. If I'd had points I'd give you one, except my normal policy is to only mod things up if they were posted by logged-in users.

      For everyone who didn't get it, look for the Project David story that was on /. yesterday, and if you don't mind modding up ACs, throw some mod points his/her way.

    5. Re:What Linux needs is VB by varag · · Score: 1

      That is a definitely a good joke.

    6. Re:What Linux needs is VB by Anonymous Coward · · Score: 0

      YHBT YHL HAND.

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

    4. Re:automake, autoconf, .src.rpm, ... by ron_ivi · · Score: 1
      Sorry, that "Internationalization" link was broken (both on their site and my posting).

      The correct link for GNU internationalization coding standards is here.

    5. Re:automake, autoconf, .src.rpm, ... by Anonymous Coward · · Score: 0

      You can get books on autoconf and automake from the GNU press

    6. Re:automake, autoconf, .src.rpm, ... by Anonymous Coward · · Score: 1, Interesting
      The common meta build tools can be a nightmare to learn all at once.

      This is exactly why my philosophy is that if you cannot simply type "make" and have the damned thing build on all systems you are interested in supporting, you are just a lazy bastard.

      The need for a configuration script should be giving you a hint that you've done something wrong. The packages that actually require this level of complexity are extremely few and far between. Most configure scripts I've seen are completely superfluous, and I laugh at the poor schmuck who wasted hours or days of his time getting the stupid thing working when all he really had to tell the user was "Just type 'make'".

      My girlfriend did some grading of undergrad projects last term. One guy submitted his project, which amounted to somewhere under 1000 lines of C code, with over 10000 lines of configuration retardedness surrounding it. On top of that, the damned configuration script didn't even work.

      Without a working Makefile (autoconf based packages generate it on the fly, except this one was broken) the project couldn't be compiled and the student received a very well-deserved 'F' for his moronic attempt at impressing her with his super-leet GNU autoconf skills. What a buffoon.

      (No, it is not the grader's responsibility to fix your stupid syntax errors and Makefile flaws. If it doesn't compile, you fail. How hard is it to test your fucking build system?)

    7. Re:automake, autoconf, .src.rpm, ... by alexandre · · Score: 1

      Actually i started reading until chapter 8 and i must say that it's kind of confusing for someone new to all these tools...(and i agree with some of the negative comments made by people on amazon about it..)
      It'll probably be worth a read later, but for now i need some practical examples.

    8. Re:automake, autoconf, .src.rpm, ... by Anonymous Coward · · Score: 0
      ...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


      Well if it's not a parody, it ought to be.


    9. Re:automake, autoconf, .src.rpm, ... by JInterest · · Score: 1

      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.

      This is why you see so much interest in moving to higher level languages for application development, ones with large standard APIs that include easy internationalization support, among other things. The Java and Mono/Pnetlib/.NET platforms make it easier to accomplish this with much, much less code, and without having to worry about providing extensive building infrastructure for multiple platforms. Simply compile to bytecode and distribute. Install the current Sun JRE or JDK on a RPM-based system and it even installs Java WebStart and adds executable JAR-file support to GNOME for you.

    10. Re:automake, autoconf, .src.rpm, ... by sadangel · · Score: 1

      Now come on. This is easy to criticize without further investigation, but there is some sense to it.
      First off, it's not intended as a real program but as a sample template from which to build other applications off of in the way that complies with all the standards.
      Second, there is a certain amount of overhead for any well-documented project that accounts for multiple runtime environments. In this case, the overhead greatly outweighs the content because the content is intentionally insignificant. For any real project of a decent size, this amount of documentation and build tools is trivial.
      I, for one, greatly appreciate the GNU auto tools. They may be an excessively large hammer for certain jobs, but they can be very helpful in automating the compilation of applications that would be unwieldy and frustrating otherwise.
      Further, I'm sure the international community appreciates applications that take different locales into account and shun the ethnocentricity that pervades certain continents on our shared planet.

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

    I thought the appropriate google bomb was litigious bastards.

    --
    -no broken link
    1. Re:Litigious folks? by Anonymous Coward · · Score: 0

      Did you ever try Overture and see how many people actually search for that? Hate to disappoint you but 5-6 searches a month amount to Google-bombers themselves patting their teammates on the back.

      Why don't you try Google-bombing for moron with too much time on his hands and see what happens?

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

    1. Re:IP violation by Anonymous Coward · · Score: 0

      you fucking suck darl

  9. Linux question by Anonymous Coward · · Score: 0
  10. 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 Anonymous Coward · · Score: 0

      C needs libraries? Wow, he's right, I never would have thought that someone might need more than some low-level I/O and memory-managing functions to write an application!

    2. 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.
    3. Re:The Power of C? by Euphonious+Coward · · Score: 1
      I have heard of people programming GNULinux systems in languages other than C. I myself have used C++ and Python to write industrial applications on GNU/Linux. Each such program used POSIX C libraries underneath. I can't think of any program I would write on GNU/Linux that I would voluntarily choose to write in C. C is "the language for Linux" only if you only write kernel code. The kernel maintainers have enforced this restriction not because C is powerful, but rather because it is not powerful, and thus can't surprise anybody much (modulo macros).

      The continued common usage of C for application programming is probably a result of language and library ABI instability in other languages, leaving C as the lingua franca for interoperability, at least in libraries. C++ ABI-instability, at least, will soon be a thing of the past, probably before gcc-3.5. After libraries built to a stable ABI make it into the distributions, it will be a lot less risky to depend on them.

    4. Re:The Power of C? by nkh · · Score: 1

      A friend of mine is writing OpenGL programs but he needs these programs to be really fast, that's why he's using C, and memory management is the heaven for him: you can make copies of structures ten times faster than any other language, it's like using assembly language to write a faster algorithm.

      You can write portable applications with Java or Ruby (I hate Python ;) but if you need optimised code, C is the best thanks to its relatively low-level.

    5. Re:The Power of C? by prockcore · · Score: 2, Funny


      double the_power_of_C = pow(x,299792458);

  11. 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 Anonymous Coward · · Score: 0


      Uh, are you trolling?

      Sorry to ruin your fun.

    2. Re:example code by Phaid · · Score: 1

      Shouldn't there be a #include after the #include ? The extern variable environ is available only if unistd.h has been included.

      Nope. unistd.h declares extern char **environ, so if you do not #include that header, your code needs to declare the variable. The example program does that, so this is OK in this case.

      I would argue that it's never very good practice to declare by hand things that are declared in header files, because the implementation can change -- witness the problems caused recently when errno became a macro, yet lots of code which used it failed to properly #include errno.h. But I'm guessing the example was coded this way for clarity.

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

      You should never use int main(void).

      size is declared size_t, so it should be printed with %z

      Yup, you are correct. It should not be cast to unsigned long, however.

      I also agree with you about the other examples, especially regarding the alloca cast.

    3. 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.
    4. Re:example code by gandalf013 · · Score: 1
      You should never use int main(void).

      Surely you meant void main instead of int main? Yup, you are correct. It should not be cast to unsigned long, however.

      Then how should it be done in C89? C89 does not define a format specifier for size_t objects. All it says about size_t is that it's an unsigned type.

    5. Re:example code by Anonymous Coward · · Score: 0

      Actually, pointer casts on memory allocation functions (that return void *) can help detect errors where you change the type of a variable you're assigning to. Since the casts will now mismatch, the compiler will signal a warning/error, thus pointing out your mistake. On the other hand, not including the right header can be checked for using prototypes. GCC has options to flag functions without prototypes with warnings and errors.

      Granted, this isn't that useful in a fairly small function, where you can see your declared variables and your functions close together, but it can be very helpful when you have globals or extensive function bodies, with lots of structures and various typedefs (which good C programming inevitably involves lots of). People will argue the stylistic merits of such things, but the truth of the matter is that veteran programmers come to realize that everything has its use, even the goto statement.

      About the only disadvantage I see is having to write all this stuff everywhere. It tends to require breaking malloc statements into multiple lines, and the like.

      That said, this is a book about Linux programming, not C programming. Portable C programming wouldn't even use something like alloca, so I'd consider it perfectly valid to use techniques that rely on a platform-specific environment.

    6. Re:example code by gandalf013 · · Score: 1
      Actually, pointer casts on memory allocation functions (that return void *) can help detect errors where you change the type of a variable you're assigning to. Since the casts will now mismatch, the compiler will signal a warning/error, thus pointing out your mistake. On the other hand, not including the right header can be checked for using prototypes. GCC has options to flag functions without prototypes with warnings and errors.

      I will use malloc for my examples below, but the same thing could be said for alloca.

      There are various ways to use malloc:

      1. type *v;
        v = (type *) malloc(n * sizeof(type));
      2. type *v;
        v = (type *) malloc(n * sizeof *v);
      3. type *v;
        v = malloc(n * sizeof *v);

      1. is what I see many programmers use. And it is error prone to

      • forgetting to #include stdlib.h
      • if one changes the type of v later on, then forgetting to change the type inside the malloc call

      2. goes halfway, and is thus if you forget to #include stdio.h, compiler may not be able to issue a warning since you are casting the result of malloc to some type, and thus compiler may assume you know what you are doing. It will default to malloc's return type as int since there is no prototype in scope. Likely result: core dump when you run the program.

      3. is the preferred way to do it IMHO. You don't need to worry about forgetting to #include sdtlib.h, since a decent compiler will issue a warning, and you don't need to worry about changing the type of v later on and forgetting to update the malloc call. Also, it is the most elegant (and easy to read) of the three calls.

      About the only disadvantage I see is having to write all this stuff everywhere. It tends to require breaking malloc statements into multiple lines, and the like.

      Exactly. And that is one reason to do away with it and use malloc the way it is used in 3. above.

      That said, this is a book about Linux programming, not C programming. Portable C programming wouldn't even use something like alloca, so I'd consider it perfectly valid to use techniques that rely on a platform-specific environment.

      Agreed. But I still can't understand why one would use alloca and casts to (type *) on void * object when the C standard guarantees that malloc is available on all portable implementations (even C89). When Linux has malloc, there is no reason to use alloca, particularly when one is doing it in a textbook. alloca isn't even POSIX.

  12. Re:Wow. by Anonymous Coward · · Score: 1, Funny

    The way people act on Slashdot, you'd think that they all think VB programmers are worthless pieces of junk.

  13. You wish this was off topic! by consolidatedbord · · Score: 1

    I am the POWER OF C. You cannot stop me!

    --
    while true ; do echo this is my sig; done
  14. 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.
    2. Re:Umm, whats with that user friendly comic. by irokitt · · Score: 1

      Yeah, and there's a glass of Guiness on the table.

      --
      If my answers frighten you, stop asking scary questions.
  15. 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.
  16. 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.
    2. Re:What *I* would like to see... by johnnyb · · Score: 1

      I've never seen a good GNOME book that tells you how to do all sorts of fun stuff like write Nautilus shell extensions, do Bonobo stuff, write filesystem filters, add Evolution plugins, and do drag-and-drop the right way.

      Most of them stick to Gtk+, with a bit of touching on the basics of the GNOME UI, but nothing that really delves into how to make it all work together.

    3. Re:What *I* would like to see... by Spoing · · Score: 1
      1. I've never seen a good GNOME book that tells you how to do all sorts of fun stuff like write Nautilus shell extensions, do Bonobo stuff, write filesystem filters, add Evolution plugins, and do drag-and-drop the right way.

      That's book #1. Book #2 would be for KDE.

      Q. With the consolidation happening through Freedesktop.org standards, does that include API or is it mainly file conventions, cut-and-paste, and a few special widgets/add-ons?

      Honestly, I don't know.

      --
      A firewall can not protect you from yourself. Turn off what you do not need. Do not use the firewall to do your work.
    4. Re:What *I* would like to see... by The+Governor · · Score: 1

      Might not hurt to learn how to type and spell too. Not to mention grammar.

      --
      The more I know, the more I know I don't know.
  17. Let's not forget... by Anonymous Coward · · Score: 0

    2112, The Gates of Delirium, Close to the Edge, Karn Evil 9, Tarkus, Echoes...

  18. Is Linux programming, C programming? by Anonymous Coward · · Score: 0

    "Elaborating a little, Linux programming is C, with the GLIBC library and the POSIX standard API."

    What a load of crap. It is true that the POSIX standard defines system calls in terms of C types, functions and variables. But this does not mean that the system calls themself are necessarily written in C, nor does it mean that other languages can't be used.

    ISO is f.x. publishing a POSIX standard using Ada instead of C.

    This is not meant to be a trolling post or starting a language war, but just a comment on the difference between using a programming language to describe an interface and actually using/implementing the interface.

  19. Uninformed article submission. by Anonymous Coward · · Score: 1, Insightful

    "Linux programming is the C Programming Language. Elaborating a little, Linux programming is C, with the GLIBC library and the POSIX standard API."

    For Linux kernel programming the logical choice might be C, but the article makes it sound like that's the only way to program on Linux.

    If you're a commercial programmer, chances are that C++ is more useful to you (shock, horror - C++ is not C). And I would recommend Python for higher level programming (and also for beginners to the programming world).

    1. Re:Uninformed article submission. by Anonymous Coward · · Score: 0

      If you're a commercial programmer, chances are that C++ is more useful to you

      Quite right. For the very good reason that C++ is a better language. Stroustrup didn't invent C++ just because he had nothing better to do.

      It has always been puzzling to me that programmers, whose entire skill set is based on newish technology, should cling so strongly to obsolescent tools and languages. Use of C is necessary in the kernel because if you do kernel programming you're really modifying an existing program. But for new applications on Linux, nobody should be using C any more.

  20. Re:What's with SCO's stock?! by Anonymous Coward · · Score: 0

    Very well done. But this is arguably more offensive.

  21. int main(int argc, char *argv[]) by Albert+Cahalan · · Score: 1

    The above is how you do it. See the 2nd edition
    K&R book, generally considered the main book for
    the ANSI C standard. The above works for C99 and
    C++ as well.

    Leaving out the prototyle, as in "main()", is
    also acceptable. It's gross though, and gets you in
    a bad habit that will lead to loss of type-safety
    when using a C compiler.

    Here you go again:
    int main(int argc, char *argv[])

    (and don't think about changing the names
    either, because that's not how K&R did it)

    1. Re:int main(int argc, char *argv[]) by gandalf013 · · Score: 1
      int main(int argc, char *argv[])
      is exactly equivalent to
      int main(int argc, char **argv)
      Leaving out the prototype "works", but as you said, it's gross. The function parameters can be named anything (since they are just that: function parameters). But the names argc and argv are used by convention.
    2. Re:int main(int argc, char *argv[]) by Albert+Cahalan · · Score: 1

      K&R used *argv[] in "The C Programming Language",
      second edition.

      Heretics use **argv or **av or *av[] or....

  22. Re:Wow. by Anonymous Coward · · Score: 0

    They are.

    Now please do shut up.

  23. Is this an absolute beginner's guide? by Anonymous Coward · · Score: 0

    I'm looking for an absolute beginner's guide. I'd like to learn C (or some other language), but have never written a single line of code in my life. I would love it if someone could recommend a great beginner Dick and Jane type guide. (either book or online.)

  24. 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!
  25. What? Where?! by kcm · · Score: 1
  26. addall price comparison by Saeger · · Score: 1
    Well, according to AddAll.com's price comparison for this exact book, it's still cheaper at Amazon than bookpool, AND it's in stock.

    --

    --
    Power to the Peaceful
  27. Teach Yourself Prorgamming in Ten Years by data7 · · Score: 1

    first time i`ve read it as "Teach Yourself Programming in Tears" 0.o Ain`t that true ?

  28. compared to Stevens? by dmorelli · · Score: 1
    Coincidentally, I'm getting close to buying books on this very subject.

    Can anyone say how this book compares to Advanced Programming in the UNIX Environment by W. Richard Stevens? I was pretty much ready to buy it today.

    the Stevens book

    Thanks!

    1. Re:compared to Stevens? by Anonymous Coward · · Score: 0

      All Steven's books are classics. Anything that you see on the shelves todays, that has to do with network/unix programming, basicly rehashes the same material and isn't anywhere as complete.

      Definately buy Stevens.

      HTH,

  29. C? you must be kidding by Anonymous Coward · · Score: 0

    Certainly Linux kernel programming mandates C, but thankfully Linux programming (as with all Unicies) isn't C programming.

    > Even a language as powerful as C needs libraries

    Eugh, what a statement. C isn't powerful, it doesn't even have useful functionality for something as basic as string handling without those libraries you mention, and when you add them all you get is a bunch of unsafe operations over character arrays that you must manage yourself.

    When I read somewhere about C's excellent array handling functions, malloc, realloc, memcpy... I just couldn't stop laughing.

    We have better tools, some even predating C, that truly are powerful - with first class strings, lists, procedures (maybe with continuations as a bonus) even first class continuations. These powerful tools are much more suited to system programming than C could ever be. Heck, they are just more suited to humans.

    So why do we need another book (or maybe just the reviewer) to tell us how to use one inadequate tool for a set of tasks that are normally difficult enough on their own?

    C is great (though maybe not the best) for kernels and implementing a decent language in. But even that is stretching it. If this book is tied to C for system programming, it is surely worthless for all but those unfortunate enough to be tied to C for system programming too. Sadly I suppose that is a lot of people, but its such a waste.

    1. Re:C? you must be kidding by FatherBusa · · Score: 1

      You know, I never hear anyone disagree with the type of thing you're saying here. It's unsafe, there's no garbage collection, the pointer abstraction is confusing, the macro system is terrible, it's just high level assembler, etc., etc.

      But there are lots and lots and lots of people who code Linux programs in C -- the vast majority of the programs I come across, at any rate. These people surely aren't being coerced into it by some manager. I assume that most of the people writing sophisticated software are multilingual (hard to get to get really good without learning at least half a dozen languages, in my opinion). They surely all know about OO, templates, assertions, abstract classes, and whatever other language features are out there.

      It's like the biggest silent majority in computing. All these people merrily hacking away in C without complaint.

      I would like to hear someone talk about why they like to code in C. I'm not asking for a language war. I would just like to hear from this silent majority.

    2. Re:C? you must be kidding by Anonymous Coward · · Score: 1, Insightful

      C is for people who understand how computers work, and how they work best, and who can't or won't accept "easier" or "faster" (to develop in) programming languages just because they won't always generate the best code. There will always be that edge case where that nice object oriented language (including C++) or functional language will absolutely butcher an algorithm and be suboptimal, and with C all the edge cases can be patched up. C is also excellent for any system programming because of its correlation to the physical memory of the system. C can almost always generate the fastest possible code, because any other construct another language uses can be implemented as close to the physical hardware as necessary, and sometimes faster. C is thus a very general purpose tool in which any kind of programming can be done, despite the obtuseness of doing it that way. Ultimately, machine language and assembly language alone offer more power than C. It is likely that the quality of power is what attracts the majority of C programmers. Sure, all (real) languages are turing complete, and thus equivalent, but you don't see people eating nutrient gruel all day because it's packed with all the things better tasting foods have. C is most pleasing to the palate.

    3. Re:C? you must be kidding by Anonymous Coward · · Score: 1, Insightful

      I program in C mostly for portability reasons, not performance. One of the first things any good programmer should learn is that performance is the last thing you should ever design for (although it's good to keep it in mind, so you don't make life harder for yourself, you generally end up scrapping your first few attempts anyway).

      A lot of the open source projects you read about have portability to multiple platforms as a goal, or are system-level software/utilities that really needs to be coded closer to the metal (my application, for example, is a network server which needs to be able to fiddle around with lots of bits on a grand scale).

      Sure, C may be glorified assembler, but it's portable glorified assembler. C remains the one language you can count on to run on just about any platform; the first piece of application software for any new general purpose computing architecture is generally the C compiler.

      I don't think it's a silent majority, though. Most programs are not the sort of things people do as labors of love, but are most likely applications (Web or otherwise), where domain knowledge is more important than the programming. That's why you have so many people touting the benefits of Perl, PHP, Python, or whatever; they're much better languages for writing such programs quickly and efficiently.

      I would say the general mentality in these cases, though, is that such programs should not be designed to last forever. Easy to code, easy to throw away. C culture takes a more monumental approach to programming. I notice programs that are written in C are designed more for other programs to use (libraries, frameworks, servers, etc.), rather than doing something in and of themselves. Often the first thing you end up doing in any major C programming project is accumulating a library of functions so you can get down to your real business. :)

      That said, I've noticed a lot more interesting and useful stuff seems to be written in Java these days than anything else. I've actually found it hard these days to find decent libraries with C bindings for a number of common tasks. And I wouldn't mind a better C than C, which had support for a few more modern concepts in a way that wouldn't overtax the portable assembly idea to the point where it's no longer useful (aka, no VMs and unstable ABIs please).

  30. Re:What's with SCO's stock?! by Anonymous Coward · · Score: 0

    After checking out the JavaScript, I must say I'm impressed with the code.

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

  32. X is Y by Tom7 · · Score: 1

    C is not the only programming language that works on linux. If it were, I sure as hell wouldn't use the OS.

  33. Re:What Linux has is Mono by Anonymous Coward · · Score: 0
    What the OS is written in really doesn't have a bearing on the languages available for application development. I agree with you that (most?) application developers shouldn't be working in C or C++. It's not a slam on the languages, or the developers, just that one tool is not the best fit for all needs (desipite what Java pundits will say!).

    With that said, having a multi-lingual runtime available which can satisfy application development needs (good DB support, relatively straightforward UI creation, etc.) IMHO is a Good Thing (TM). This is where the Mono effort fits in. Provide a simpler programming environment, compatible with M$'s direction, and have it Open Source.

    Remember, though, that much of what is currently being done in Linux is server side development, where application developer needs are not as paramount as being able to interact at an intimate level with the operating system. This is where C++ and C shine.

    So check out Mono, kick the tires, and maybe even contribute a bit to their effort if you like it.

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

  35. Duplicate Titles on Books?... by Anonymous Coward · · Score: 0

    The first time I saw the title of this new book, I had a double-take to my bookshelf, cuz I *already* have a book there called "Linux Programming By Example", written by Kurt Wall and published by Que (ISBN 0789722151) in 2000. It's a pretty good book loaded with examples and doesn't hold back much.

    So now we have two (at least) books with the same title. Guess Linux must be making it...

    (QillerPenguin, AC'd for no reason)

    1. Re:Duplicate Titles on Books?... by rsheridan6 · · Score: 1

      I have the same book. I was wondering why they were reviewing a four year old title.

      --
      Don't drop the soap, Tommy!
  36. Re:re "Teach Yourself Programming in Ten Years" by adamofgreyskull · · Score: 1

    I've actually written a couple of quick and dirty Perl scripts to convert cds to ogg and wma to ogg. Same with PHP, a couple of trivial snippets on my website, but not much else. :o)

    I know what you mean about techniques, me and my housemate are always saying this, once you get to grips with concepts, you can pick up language syntax after the fact. But jumping around between languages with these generic techniques, I can't help thinking that very few people will ever know *everything* about a language, however unnecessary knowing everything may be for day to day use.

    A language I'd like to learn, for the reason you mention, grokking new ways of doing things, is Lisp, having heard the evangelism on /. :o)

  37. bathtub reading by dbcowboy · · Score: 1

    I like to read in the bath-tub. Obviously overly big books are to heavy to read this way. This book is sized well. I made it through the first two chapters in todays soak. Course its not just size... the book has to hold my interest too. Found it on the shelf at my local BN. So far, so good... recommended. Soap optional.

  38. Re:re "Teach Yourself Programming in Ten Years" by alienmole · · Score: 1
    A language I'd like to learn, for the reason you mention, grokking new ways of doing things, is Lisp, having heard the evangelism on /. :o)

    Read a book like Structure and Interpretation of Computer Programs (SICP). Not only does it teach you ways of doing things, it also teaches you ways of thinking about and analyzing those things, i.e. it should increase your understanding of the languages you have to work with. The biggest lesson the more academic languages have to teach has little to do with the languages themselves, and everything to do with gaining an understanding of the underlying concepts.