

Ask HN: Book of Programming Examples? - hanniabu

I was curious if anybody knows of a book that&#x27;s comprised of a collection of well commented code from various languages. Sort of like a collection of short stories, but each &#x27;story&#x27; is a snippet of code performing a particular task. Ideally the book would contain examples from various languages such as Java, C, C++, Python, Ruby....<p>Reason why I&#x27;m looking for this is I&#x27;d like to gain familiarity with other languages in case I ever encounter them. I try an take breaks from the computer an go for walks throughout the day and would love to be able to bring a book with me and I felt like this would be great since I can continue learning but it&#x27;s something where I can hopefully finish looking over a section each walk or something. Also wouldn&#x27;t hurt to see how procedures and best practices are carried out in various languages.
======
Sean-Der
I am a big fan of Rosetta Code

Here is an example with a good amount of entries
[http://rosettacode.org/wiki/Sorting_algorithms/Quicksort](http://rosettacode.org/wiki/Sorting_algorithms/Quicksort)

------
thorin
There used to be lots of cookbook type books like
[http://chimera.labs.oreilly.com/books/1230000000393](http://chimera.labs.oreilly.com/books/1230000000393)
if you want longer examples getting annotated source code for open source
projects for things like jquery or underscore. Look at github projects also.

------
smt88
"Well-commented" doesn't mean explaining how the language works, what the
syntax means, what the standard library does, etc. That's what you'd find in
the language documentation, textbooks, and tutorials.

Just pick up an introductory book on each language and be sure it has lots of
examples.

Honestly, though, I don't think there's any point in becoming familiar with
those languages. If you know how to program, you're probably familiar enough
to read what's going on...

------
cafard
The book _Beautiful Code_ from O'Reilly Associates aims to do that. A glance
into the book shows C, Java, Perl, Python, Ruby, and Scheme.

------
dm03514
I like looking at design patterns in various languages, Examples are often
short sweet and discrete

[https://github.com/faif/python-patterns](https://github.com/faif/python-
patterns)

