Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Book of Programming Examples?
4 points by hanniabu on Aug 12, 2015 | hide | past | favorite | 5 comments
I was curious if anybody knows of a book that's comprised of a collection of well commented code from various languages. Sort of like a collection of short stories, but each 'story' 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....

Reason why I'm looking for this is I'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's something where I can hopefully finish looking over a section each walk or something. Also wouldn't hurt to see how procedures and best practices are carried out in various languages.




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


There used to be lots of cookbook type books like 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.


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


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.


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

https://github.com/faif/python-patterns




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: