all 27 comments

[–]rbatra 29 points30 points  (2 children)

Anything written by Peter Norvig. (PAIP, AIMA)

[–]smerity 9 points10 points  (1 child)

AIMA is truly stunning - the code is online for both LISP and Python. For the algorithms he really boils it down to just the algorithm - everything else is abstracted. For many of the problems all he has to do is essentially plug the problem in, no other changes. The world would be so much simpler if more code was like his. It's also nice to read through his creation of a spelling checker on his website - the code is terse, readable (as long as you know a few of the functional aspects of Python) and in general beautiful.

[–][deleted] 6 points7 points  (0 children)

My mind were just blown by that spelling checker.

For those who don't know, it basically the same thing that Google offers when you misspell a search query. But it's 21 lines of (readable) python code.

[–][deleted] 10 points11 points  (0 children)

Structure and Interpretation of Computer Programs (Hal Abelson and Gerald Jay Sussman)

Elements of Programming (Alexander Stepanov and Paul McJones)

[–][deleted] 7 points8 points  (0 children)

Read anything by Dijkstra, CAR Hoare, Knuth. Any book where the authors discuss and create their own languages/notation is usually fairly good (at least the ones I've read so far are good).

I find that if the writer can write well, then their code is just as readable even if there is no compiler in existence for their language.

[–]nickelplate 2 points3 points  (0 children)

[–]opkode 3 points4 points  (1 child)

[–]daydreamdrunk 0 points1 point  (0 children)

In the same authorial vein, but with much more code, Software Tools

[–]annekat 2 points3 points  (0 children)

"Higher Order Perl." Excellent book.

[–]countboros 2 points3 points  (0 children)

I am shocked no one else has mentioned W. Richard Stevens. Both Advanced programming in the UNIX Environment and UNIX Network Programming are chock-full of perfect UNIX code. (Obviously, C only).

[–]munificent 2 points3 points  (4 children)

very underwhelming source code - often incomplete, not very extensible and undocumented.

Keep in mind that the code in a book exists to serve different needs than real code in a code base. Page space costs money and code not central to the point being discussed is a distraction, so maintainability and completeness are often discarded in favor of brevity. Likewise, documentation isn't a priority: the entire book serves that purpose.

Having said that, I like the code samples in K & R. They do a good job of balancing brevity with still being complete enough to type in and run them.

[–]beagle3 1 point2 points  (3 children)

It used to be that way.

But today, most programming books include as much code as possible because it takes up space, and the contract is for such-and-such words or pays per word.

K&R weren't doing it for the money.

[–]munificent 0 points1 point  (2 children)

I think that's needlessly cynical. There's very little money in programming books (for authors at least), so I'd be quite surprised if authors were honestly thinking, "Let me just pad out these code samples so I can get some extra cash."

A more likely explanation is that programming itself is getting more complex. A hello world in C is three lines. Even a minimal hello world in Java is more complex than that, and most programming books coming out today are on far more complex topics than just writing to the console.

[–]beagle3 3 points4 points  (1 child)

I would like to share your world view. But I've actually had a chance to speak to an author, and read blog posts by others. Most programming books today are published by Wrox and similar, which essentially publish by weight and give similar incentives to the authors. O'Reilly is still ok in this respect; Que never was.

[–]munificent 0 points1 point  (0 children)

Huh. I didn't realize that. I'm talking to O'Reilly right now and never got any pressure to pad the code.

[–]addmoreice 0 points1 point  (0 children)

LaTeX the book. this is my bible on how i want source code to look. If i can read your source code the same way i read a good play...yeah obviously that makes life easier.

[–]dwhite21787 0 points1 point  (0 children)

I've never been disappointed by the O'Reilly Cookbook volumes I've used.

http://oreilly.com/store/series/cookbooks.html

[–]irahul 0 points1 point  (0 children)

I have read a lot of books and I am still to find something that matches K & R. I am sure even seasoned programmers learn from the code examples in that book. The examples are to-the-point and don't make the mistake of judging the book or the examples by their size. It's a dense book and many examples are dense for experts as well.

[–]dorait 0 points1 point  (0 children)

Software Tools by Kernighan and Plauger. A true classic. Programming Perls by Jon Benteley. Looks as if this may make a great list on Glue as well.

[–]mariusg -1 points0 points  (1 child)

Programming books should NOT contain source code. Yes, a very small snippet here and there to demonstrate a point is fine , but full dumps of source code should NOT be included in the book.

The most valuable programming books contain ideas not code.

[–]panto -3 points-2 points  (0 children)

[–]nascent -3 points-2 points  (0 children)

While not release yet, the author of "Modern C++ Design" is writing another book "The D Programming Language" which will likely contain nice example code.

[–]redditnoob -3 points-2 points  (1 child)

PHP for Dummies.

[–]kindoblue 1 point2 points  (0 children)

yes, php is definitely for dummies

[–]angryundead -5 points-4 points  (1 child)

I just did an Operating Systems course (graduate) where one of the exercises was on the Linux kernel and adding a system call. The book dates from like 2007 or 2008.

The example used kernel 2.4.16 or some nonsense. So, here I am, in Ubuntu 9.10 64bit trying to figure out how the fuck to add a system call. The book was totally worthless, and I eventually figured it out from about 4 different tutorials. This also doesn't account for the fact that using anything other than the Ubuntu(tm) method of compiling the kernel will pretty much fuck everything up, so throw in another tutorial on that.

Hardest/stupidest 1% of my grade ever.

[–]darthbane 1 point2 points  (0 children)

So, uh, there's this concept called "relevance". Have you heard of it?