# -*- mode: org -*- #+TITLE: Programming Books that Make You Smarter #+AUTHOR: Peter Salvi #+EMAIL: vukung@yahoo.com #+LANGUAGE: en #+OPTIONS: H:1 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t #+OPTIONS: TeX:nil LaTeX:nil skip:nil d:nil todo:t pri:nil tags:not-in-toc #+INFOJS_OPT: view:nil toc:nil ltoc:t mouse:underline buttons:0 path:http://orgmode.org/org-info.js #+EXPORT_SELECT_TAGS: export #+EXPORT_EXCLUDE_TAGS: noexport #+LINK_UP: #+LINK_HOME: These are wonderful books that would help anyone become a better programmer. Most of these are known and loved by a small group of geeks, but are not picked up by a broader audience because of the programming language used in them. In many cases, however, the message conveyed is not how to program in the given language, but how to look at programming problems from another perspective. Every language needs a different mindset, and I believe that these books make you think in ways you never did before. I would recommend them even if you will never program in these languages. Some of the books are distributed on the internet for free, I hope the links will stay working. * Assembly ** R. Hyde, /The Art of Assembly Language/, 2nd Ed., No Starch Press, 2010. A nice introduction to the inner workings of the computer and to assembly programming. I think every programmer should have a thorough understanding of assembly (in an arbitrary architecture). You may want to read this first, to be able to fully enjoy the two books below. Online version: http://www.artofasm.com/ I find that I actually like the original version better, which used conventional assembly instead of HLA. You can find it here: Original version: http://flint.cs.yale.edu/cs422/doc/art-of-asm/pdf/ ** J. Bartlett, /Programming from the Ground Up/, Bartlett Publishing, 2004. Practical assembly for programmers. Online version: http://savannah.nongnu.org/projects/pgubook/ ** H. S. Warren, /Hacker's Delight/, Addison-Wesley, 2002. Advanced bit-shuffling techniques for optimized code. ** I. Zhirkov, /Low-Level Programming/, Apress, 2017. A very good and up-to-date introduction to assembly (and C) programming, with many exercises and very nice examples (including a Forth interpreter). * AWK ** A.V. Aho, B.W. Kernighan, P.J. Weinberger, /The AWK Programming Language/, Addison-Wesley, 1988 An introduction, reference and cookbook in one volume for the deceptively simple AWK language. It even has exercises with solutions - a really fun book to work through. Learning this text-processing DSL can boost your productivity and also help you think in a data-driven mindset. Online version: https://archive.org/details/pdfy-MgN0H1joIoDVoIC7 * Clojure ** C. Emerick, B. Carper, C. Grand, /Clojure Programming/, O'Reilly, 2012 This is an introductory text to Clojure, which is a Lisp dialect on the Java VM, with a more functional approach than Common Lisp. This enables features like lazy evaluation and a novel transaction-based concept for multithreaded programming. It combines Haskell-like list comprehension with real macros emerging from the code-as-data paradigm, while offering access to Java libraries. * Common Lisp (See also _Scheme / Lisp_ for books on other lisps.) ** P. Seibel, /Practical Common Lisp/, Apress, 2005. (Common) Lisp is my language of choice, for various reasons. It has some features that make it the [[./comfortable-language.txt][most comfortable]] language (for me), like macros, closures, REPL... This book is the best introduction to Common Lisp and to programming in the Lisp Way. Read it and then move on to the books below. Online version: http://www.gigamonkeys.com/book/ ** P. Graham, /ANSI Common Lisp/, Prentice Hall, 1996. Another great introduction to the language, with lots of exercises (which seems to be a lost art in today's programming books). It is part tutorial, part reference, with extended examples and interesting appendices. ** P. Graham, /On LISP/, Prentice Hall, 1993. Advanced Lisp programming, mostly using macros. After experiencing the power of metaprogramming in Lisp, you won't be content with "conventional" languages anymore. Online version: http://www.paulgraham.com/onlisptext.html TexInfo version: http://mirror.lug.udel.edu/pub/fink/distfiles/onlisp.texi.gz Nice PDF version: https://bitbucket.org/blevyq/onlisp ** D. Hoyte, /Let Over Lambda/, Lulu.com, 2008 Advanced Lisp programming, mostly using closures. This powerful construction is now making its way into more mainstream languages as well. ** E. Weitz, /Common Lisp Recipes/, Apress, 2016. This is a reference book of advanced CL techniques, but I've read it cover to cover, and learned a lot from it, even though I've been using Lisp for more than a decade. It covers, in addition to the core language, some of the best open-source libraries, as well. ** S. E. Keene, /Object-Oriented Programming in Common Lisp - A Programmer's Guide to CLOS/, Addison-Wesley, 1989. Everything you wanted to know on how to use CLOS. I would recommend this even to people who doesn't use CL, just to show them that there are other ways to do OOP. When you feel comfortable with CLOS, move on to: ** G. Kiczales, J. des Rivières, D. G. Bobrow, /The Art of the Metaobject Protocol/, MIT Press, 1991. This book explores object-oriented reflective techniques for language extension & design, through the derivation of Common Lisp's object system. It also lets us peek under the hood of CLOS, and serves also as a MOP reference. A bit dry, but interesting book. ** P. Norvig, /Paradigms of Artificial Intelligence - Case Studies in Common Lisp/, Elsevier, 1991 A book on building AI systems - with Common Lisp at its best. Online version: https://norvig.github.io/paip-lisp/ * Erlang ** F. Cesarini, S. Thompson, /Erlang Programming/, O'Reilly, 2009 An Introductory text on Erlang - a language based on the message passing techniques of concurrent programming. Twists your brain in ways you have never imagined. * Forth (& Factor) ** L. Brodie, /Starting Forth/, 2nd Ed., Prentice Hall, 1987 A wonderful book teaching the essentials of Forth programming. The simplicity of its syntax and the power of the language is really astounding. Online version: https://www.forth.com/starting-forth/ ** L. Brodie, /Thinking Forth: A Language and Philosophy for Solving Problems/, Prentice Hall, 1984 This classic teaches programming practices still relevant today. While some topics are specific to Forth, most of the ideas are applicable to other programming environments, as well. It encompasses all aspects of programming, such as analysis, design, problem solving, implementation, factoring, even style and documentation. A reprint and an ANS Forth-compatible version are available as parts of the Thinking Forth Project: http://thinking-forth.sourceforge.net/ ** R. W. M. Jones, /jonesforth/ - a literate Forth compiler This is a simple, but fascinating program, written in a literate style. Reading this, you can build a compiler from the very foundations, which is an experience you'll never forget. Online version: http://git.annexia.org/?p=jonesforth.git ** B. Rodriguez, /Moving Forth/, In: The Computer Journal (59-60, 62, 64, 67, 69, 71, 74), 1993. This series of articles investigate the various methods and tricks for implementing a Forth compiler on various architectures. If you have read jonesforth, this is the next step. Online version: http://www.bradrodriguez.com/papers/moving1.htm ** C. Childers, /RetroForth/ The bootup image of RetroForth, complete with a metacompiler, is thoroughly commented in a literate style. It is also lots of fun to read. Online version: [[http://rx-core.org/rx.fossil/artifact?name=be6515c5f9edcf9ea673be069ad1b2688ed5463a][RetroForth Commentary]] ** S. Pestov, /Factor/ The Factor programming language does not seem to be active any more, but it has a neat help system and browsing the vast standard library and examining its code is very rewarding. Online version: http://docs.factorcode.org/ * Haskell ** W. Kurt, /Get Programming with Haskell/, Manning, 2018 The best introduction to Haskell I have seen so far. This book also teaches the practical aspects of Haskell programming, with many extended examples, and exercises (with solutions). ** B. Milewski, /Category Theory for Programmers/, 2019. This is not exactly a book, but a series of blog posts converted into a book. Also, it is not exactly about Haskell, but (as the title says), about category theory, which is a very abstract branch of mathematics, but which has very practical applications in (functional) programming. The examples are in C++ and Haskell, but the reader is not expected to know the latter. Knowing (the basics of) category theory helps to make sense of many Haskell constructs, and this is by far the easiest introduction I know of. If you want to see more diagrams and less code, see e.g. B.C. Pierce's /Basic Category Theory for Computer Scientists/ (MIT Press, 1991). For a more thorough (and dense) introduction, see S. Awodey's /Category Theory/ (2nd Ed., Oxford University Press, 2010). Online version: https://github.com/hmemcpy/milewski-ctfp-pdf ** M. Lipovača, /Learn You a Haskell for Great Good/, No Starch Press, 2011 Haskell is a strictly functional language with a lot of lazyness and a mind-boggling (but amazing!) type system. I've read quite a few tutorials, but this is the book that made me grasp what Haskell is all about. Online version: http://learnyouahaskell.com/chapters ** B. O'Sullivan et al., /Real World Haskell/, O'Reilly, 2008 After a good introduction (like LYaH above) this is the book that tells you all the intricacies of Haskell programming through practical examples. While other books mainly emphasize the theoretical aspects of Haskell, here you will find that it can actually be used for real programming, as well. Online version: http://book.realworldhaskell.org/read/ ** S. P. Jones, /The Implementation of Functional Programming Languages/, Prentice Hall, 1987. This is to Haskell what /Anatomy of LISP/ is for Lisp. Well, for Miranda, to be exact, as Haskell only appeared in 1990. The book first explains the translation of functional programs into an enriched lambda-calculus, and then analyzes the evaluation of this intermediary language. Check out also the more practical book below. Online version: http://research.microsoft.com/en-us/um/people/simonpj/papers/slpj-book-1987/ ** S. P. Jones et al., /Implementing Functional Languages: A Tutorial/, Prentice Hall, 1992. This is a more practically oriented version of the book above. It does not cover the conversion between the high-level language and the intermediary "core" language, though. Online version: http://research.microsoft.com/en-us/um/people/simonpj/papers/pj-lester-book/ ** R. Bird, /Thinking Functionally with Haskell/, Cambridge, 2015 Another nice introductory text to both Haskell and functional programming. To me, its main attraction is that each chapter has a number of exercises (with solutions!), something that LYaH lacked. It also has chapters on algorithmic proofs and efficiency, topics that are usually overlooked in beginner books. Still, I wouldn't recommend it as a first book, because of its ad hoc structure, and its focus on proofs (which makes it a bit dry to my taste). ** /The Monad Reader/ This is a webzine for Haskell programmers, containing high-quality articles. Homepage: http://themonadreader.wordpress.com/ * Inform ** G. Nelson, /The Inform Designer's Manual/, Dan Sanderson, 2006. Inform is a language for writing interactive fictions. This book shows the power of DSLs, and is also fun to read. ** A. Reed, /Creating Interactive Fiction with Inform 7/ And now for something completely different: programming in a way you've never done before. The Inform 7 compiler parses English sentences - probably the most novice-friendly language ever! * J ** C. A. Reiter, /Fractals, Visualization and J/, 3rd Ed., 2007. Any book on J would be good to make you think in new ways - it's not only that a seemingly meaningless string of garbage is actually working code; the ubiquity of matrices in this language is awe-inspiring. I chose this book because the nice graphics add some extra enjoyment to the ride. * MIX ** D. E. Knuth, /The Art of Computer Programming Vol. 1-3/, 3rd Ed., Addison-Wesley, 1998. No list of programming books would be complete without this. All the basics of programming, data structures and algorithms are there. Rumor has it that there will be a 4th volume coming out soon. * ML ** L. C. Paulson, /ML for the Working Programmer/, 2nd Ed., Cambridge, 1996 In addition to an introduction to functional programming and Standard ML, this book has /a lot/ of interesting topics, ranging from data structures and algorithms to writing interpreters and theorem proving, and many exercises. ** C. Okazaki, /Purely Functional Data Structures/, Cambridge University Press, 1998 Okazaki's thesis, published later in book form. A classic treatise on how to build and modify data structures in a purely functional context. I particularly liked the chapter that draws parallels between the representation of natural numbers and tree data structures. The original thesis: https://www.cs.cmu.edu/~rwh/theses/okasaki.pdf ** J. D. Ullman, /Elements of ML Programming/, ML97 Ed., Prentice Hall, 1998 A nice introduction to Standard ML, and to the world of functional programming in general. However, it uses a non-ML-y style (tupled arguments, redundant semicolons...) to ease the transfer from conventional programming languages. ** M. Felleisen, D. P. Friedman, /The Little MLer/, MIT Press, 1997 An introduction to (a subset of) ML and to using a refined type system, in the style of The Little Schemer. * Perl ** The Perl Manuals Perl has very good tutorials. Read them (or at least [[http://perldoc.perl.org/perlintro.html][man perlintro]]) and move on to this book: ** M. J. Dominus, /Higher-Order Perl/, Elsevier, 2005. Perl programming using advanced programming techniques, with a lot of nice exercises. Online version: http://hop.perl.plover.com/book/ * Prolog ** I. Bratko, /Prolog Programming for Artificial Intelligence/, 4th Ed., Pearson, 2011. If you buy only one Prolog book, this should be it. It covers the basics as well as some advanced techniques. There are examples of many AI applications, such as expert systems, machine learning, or game AI. There is also a chapter on metaprogramming. ** W. F. Clocksin, Ch. S. Mellish, /Programming in Prolog - Using the ISO Standard/, 5th Ed., Springer, 2003. The standard text for learning Prolog. ** W. F. Clocksin, /Clause and Effect - Prolog Programming for the Working Programmer/, Springer, 1997. This is an interesting book for those who have some programming experience. There is little explanation, most of the book consists of larger, interesting examples, showing how Prolog works. ** L. Sterling et al., /The Art of Prolog/, 2nd Ed., MIT Press, 1994. This is also an all-in-one book, starting from the basics, but also presenting advanced programming techniques, and many interesting application examples. It is a bit more technical, and focuses more on programming languages - interpreters, compilers, program transformation, and less on artificial intelligence. ** H. Coelho, J. C. Cotta, /Prolog by Example - How to Learn, Teach and Use It/, Springer, 1988. This is a big showcase of short Prolog programs, presented as 175 problems with solutions. ** R. A. O'Keefe, /The Craft of Prolog/, MIT Press, 1990. Aimed at experienced Prolog programmers, this book explains how to write good Prolog code. A classic. ** H. Aït-Kaci, /Warren's Abstract Machine/, MIT Press, 1991. An in-depth tutorial on the de facto standard virtual machine behind Prolog. It is now out of print and downloadable for free (along with some slides): http://wambook.sourceforge.net/ ** U. Nilsson et al., /Logic, Programming and Prolog/, 2nd Ed., Wiley, 1995. This is an introduction to the inner workings of Prolog for the mathematically inclined. It covers the basics of several variants of logic programming, such as constraint programming or concurrent logic programming. It is now out of print and downloadable for free: http://www.ida.liu.se/~ulfni/lpp/ * Rust ** J. Blandy et al., /Programming Rust/, O'Reilly, 2017 Rust is a relatively new language, which may still go through some changes. It has many nice features, like a type system inspired by Haskell and ML, and Scheme-style hygienic macros. But its main feature, which will open up your mind, is how it manages memory by "borrowing" and lifetimes. * Scheme / Lisp (See also _Common Lisp_.) ** H. Abelson, G. J. Sussman, /Structure and Interpretation of Computer Programs/, 2nd Ed., MIT Press, 1996. Also called the "Wizard Book" or "SICP", this is an introduction to programming in general using Scheme as a medium. An abundance of exercises helps you understand the concepts. There is even a videocourse downloadable on the internet. Online version: http://mitpress.mit.edu/sicp/ TexInfo version: http://www.neilvandyke.org/sicp-texi/ Nice eBook version: https://sicpebook.wordpress.com/ ** R. K. Dybvig, /The Scheme Programming Language/, 4th Ed., MIT Press, 2009. An introduction and reference to the Scheme language (R6RS). Online version: http://www.scheme.com/tspl4/ Personally I like the 3rd Edition better, which covers the smaller R5RS language, and thus more compact - you'll learn the rest from your favorite implementation's manual anyway. Also the R5RS standard is a common ground every implementation can do. Online version: https://www.scheme.com/tspl3/ ** C. Queinnec, /Lisp in Small Pieces/, Cambridge University Press, 2003. The complete guide to write your own Scheme/Lisp compiler. This is also called the modern-day version of Allen's /Anatomy of LISP/ (see below). ** J. Allen, /Anatomy of LISP/, McGraw-Hill, 1978. This book explains how to write an interpreter or compiler to (an old version of) lisp. Its non-lispy notation may be strange at first, but it serves an important purpose: abstract definitions and the actual representations are completely separated. After so many years, it's still a deep and very enjoyable read. ** P. Henderson, /Functional Programming - Application and Implementation/, Prentice Hall, 1980. This book is similar to /Anatomy of LISP/, but using a strictly functional language. It teaches the functional paradigm, and then moves on to show how to implement a compiler for the language (on a SECD virtual machine). Additional topics like lazy evaluation and non-deterministic computation are also included. Contains exercises (with solutions!). ** D. P. Friedman, M. Felleisen, /The Little Schemer/, 4th Ed., MIT Press, 1995 A fun read in dialogue format leading you step-by-step to the Y-combinator and the construction of a Scheme interpreter. ** D. P. Friedman, M. Felleisen, /The Seasoned Schemer/, MIT Press, 1995 This is the sequel to "The Little Schemer", using the same didactic style, introducing some more advanced language features, like destructive methods and continuations. ** D. P. Friedman, W. E. Byrd, O. Kiselyov, /The Reasoned Schemer/, MIT Press, 2005 The third book in the series take us to the field of logics, building a Prolog-like language in the process. ** D. P. Friedman, M. Wand, /Essentials of Programming Languages/, 3rd Ed., MIT Press, 2008 This is a book about interpreters, and the languages they interpret. Its main message is that any sufficiently complex system needs a DSL, and for that, an interpreter. It also discusses various types of languages while creating an interpreter for them, adding one feature at a time. * Smalltalk ** C. Liu, /Smalltalk, Objects, and Design/, toExcel, 1999 This is the book usually recommended by the community along with the 'blue book' (or its later edition, the 'purple book'), which are the language reference manuals. Smalltalk is a unique language that also needs a different frame of mind than most languages you have encountered before. Unfortunately, since GUI is an important part of the language, implementations differ considerably. However, most Smalltalk systems have some kind of help to get you started - and then just explore, explore, explore. I recommend Pharo, a very small, fast and clean Smalltalk. Other implementations include Squeak and Smalltalk/X. There is a collection of free books here: http://stephane.ducasse.free.fr/FreeBooks.html * Language-independent Books Here I list some books that are about programming generally, and do not use any specific language. ** A. K. Dewdney, /The (New) Turing Omnibus/, Freeman / Holt, 1993 This is a collection of 66 topics, ranging from formal languages and algorithms to computer vision and cryptography. There is even a description on how to build a minimal computer. Each chapter is only a few pages, just long enough to spark your interest, recommend some relevant books, and present some problems to think about. Sadly, my Holt Paperbacks edition contains quite a lot of misprints. ** A.Y. Bhargava, /Grokking Algorithms/, Manning, 2016 This short book is written in the style of /Starting Forth/, and is a wonderful way to get acquainted with basic algorithms and data structures. It uses a bit of Python here and there, but not much. This is the book to get for children or hobbyists - for professionals, read on. ** S. S. Skiena, /The Algorithm Design Manual/, 2nd Ed., Springer, 2008 All kinds of algorithms you may need. It is split in two parts - the first part is a logical walkthrough on programming techniques, graph algorithms or dynamic programming methods. The second part is a reference, listing problems and possible algorithms that you can use, as well as existing libraries. ** T. H. Cormen et al., /Introduction to Algorithms/, 3rd Ed., MIT Press, 2009 Another nice book on algorithms, with a bit more depth and coverage. It is less of a reference, though, and more of a university course. ** R. Sedgewick, K. Wayne, /Algorithms/, 4th Ed., Addison-Wesley, 2011 This is similar in scope - maybe a bit less comprehensive, but much more accessible in style and organization. Unfortunately uses Java instead of pseudocode. ** J. Bentley, /Programming Pearls/, Addison-Wesley, 1986 Interesting real-life problems, rendered as exercises for the reader, then a detailed explanation follows. A must read. ** J. Bentley, /More Programming Pearls - Confessions of a Coder/, Addison-Wesley, 1988 The sequel. ** R. Bird, /Pearls of Functional Algorithm Design/, Cambridge, 2010 A worthy successor of Bentley's "pearl" books, this volume looks at functional programming techniques in the same fashion. An essential read for all Haskell programmers, but its notations may scare off the uninitiated. ** S. J. Russell et al., /Artificial Intelligence - A Modern Approach/, 3rd Ed., Pearson, 2009. The definitive text on AI. But be sure to check out the language-dependent alternatives (see _Prolog_ and _Common Lisp_). ** P. Seibel, /Coders at Work/, Apress, 2009 A series of interviews with some of the most influential programmers. I normally don't read interviews, but these are packed with interesting information and anecdotes; I got a lot of inspiration from this book. ** M. C. Feathers, /Working Effectively with Legacy Code/, Prentice Hall, 2004 A book on simplifying existing code, creating unit tests, and refactoring. ** J. R. Hindley et al., /Lambda-Calculus and Combinators - An Introduction/, Cambridge, 2008. This may be an odd choice here, as this book is strictly about the theory of computation, and has little to say about programming. It is nevertheless a fascinating topic, and I think that this mathematical background is important to know even if you don't use it. ** C. Hankin, /An Introduction to Lambda Calculi for Computer Scientists/, 2nd Ed., Kings College Publications, 2004 As above, but a lighter, more easily digestable read, focusing on typeless lambda calculus. Also covers some practical aspects. * My favorites I love all these books, but there are some I consider exceptional. If I had to choose just a few, the list would go like this... Elementary books: 1. The (New) Turing Omnibus 2. Structure and Interpretation of Computer Programs 3. Prolog Programming for Artificial Intelligence 4. Starting Forth Advanced books: 1. On LISP (& Let Over Lambda) [requires basic Lisp knowledge] 2. Programming Pearls (& More Programming Pearls) [requires basic programming skills] 3. Clause and Effect [requires basic programming skills] 4. Pearls of Functional Algorithm Design [requires basic Haskell knowledge] Books on implementing programming languages: 1. Anatomy of LISP 2. Functional Programming - Application and Implementation 3. The Implementation of Functional Programming Languages [requires basic Haskell knowledge] 4. jonesforth [requires basic Forth knowledge] * So what should I read? My highly opinionated guide would be something like this: - /Lisp block/: 1. *Structure and Interpretation of Computer Programs* 2. *Practical Common Lisp* 3. *On LISP* 4. (if you want more => Let Over Lambda, Common Lisp Recipes, Anatomy of LISP / Lisp in Small Pieces) - /Low-level language block/: 1. *Starting Forth* 2. Low-Level Programming 3. *jonesforth* 4. *Moving Forth* - /General block/: 1. The (New) Turing Omnibus 2. The Algorithm Design Manual (and if you liked it, Introduction to Algorithms) 3. Programming Pearls (and if you liked it, More Programming Pearls) 4. Prolog Programming for Artificial Intelligence (or: Artificial Intelligence - A Modern Approach / *Paradigms of Artificial Intelligence*) - /OOP block/: 1. *Smalltalk, Objects, and Design* 2. Object-Oriented Programming in Common Lisp 3. The Art of the Metaobject Protocol - /Haskell block/: 1. Get Programming with Haskell (or: *Learn You a Haskell for Great Good* + *Real World Haskell*) 2. Pearls of Functional Algorithm Design 3. *Category Theory for Programmers* 4. *The Implementation of Functional Programming Languages* (maybe with Lambda Calculus and Combinators - An Introduction) (The blocks can be studied in sequence or in parallel.) Note that all books in bold are free, so you can start learning right away! * For my students I tend to suggest to my students that they get acquainted with Lisps, Prolog and Forth to get a different mindset about programming. While SICP and PPAI are very nice books, most of the contents are included in other courses, so here I would choose shorter, language-oriented books: 1. The Scheme Programming Language (3rd Ed.) [~300 pages, but half of it is reference] https://www.scheme.com/tspl3/ 2. The AWK Programming Language [~200 pages] https://archive.org/details/pdfy-MgN0H1joIoDVoIC7 3. Clause and Effect [~150 pages] 4. Starting Forth [~350 pages, but lots of fun!] https://www.forth.com/starting-forth/ ... and also, for those interested, lambda calculus: 5. An Introduction to Lambda Calculi for Computer Scientists [~150 pages] There are, of course, those who don't like to read. For them, I suggest to play with DrRacket and Pharo.