Linux Programming by Example
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 ConsiderNothing 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.
Cutting and pasting makes things really easy.
while bankvault >= $0
..DarlsWallet == DarlsWallet + ($699 x StationCount)
repeat until bankvault = empty
Now all we need is a "Linux Documentation Writing by Example" Then we could tell people WTFM instead of RTFM. =)
Lagito ergo expectabo
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.
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.
The common meta build tools can be a nightmare to learn all at once.
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.
[
I thought the appropriate google bomb was litigious bastards.
-no broken link
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...
Can you integrate US and Canadian map searching into a CRM application with Linux?
Can we mod the original article as +1, Funny?
I can see the following "problems" with some of them (if I am wrong, someone please correct me):
ch02-printenv.c:
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:
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.
The way people act on Slashdot, you'd think that they all think VB programmers are worthless pieces of junk.
I am the POWER OF C. You cannot stop me!
while true ; do echo this is my sig; done
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!
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.
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.
2112, The Gates of Delirium, Close to the Edge, Karn Evil 9, Tarkus, Echoes...
"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.
"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).
Very well done. But this is arguably more offensive.
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)
They are.
Now please do shut up.
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.)
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!
Linux documentation, you say?
--
Power to the Peaceful
first time i`ve read it as "Teach Yourself Programming in Tears" 0.o Ain`t that true ?
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!
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.
After checking out the JavaScript, I must say I'm impressed with the code.
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...
C is not the only programming language that works on linux. If it were, I sure as hell wouldn't use the OS.
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.
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.
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)
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)
/. :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
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.
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.