A long time ago, Sylvain and I wrote a French book on learning programming with OCaml. Recently, the OCaml Software Foundation funded its translation to English. The book is available here:
Many thanks to Urmila for a translation of high quality.
The book is available as a PDF file, under the CC-BY-SA license. The source code for the various programs contained in the book are available for download, under the same license.
The book is structured in two parts. The first part is a tutorial-like introduction to OCaml through 14 small programs, covering many aspects of the language. The second part focuses on fundamental algorithmic concepts, with data structures and algorithms implemented in OCaml. This is also a nice way to learn a language!
The book does not cover all aspects of OCaml. It is ideally complemented by other books on OCaml.
This looks like a lovely contribution to the OCaml ecosystem, and programming more generally. I look forward to reading it more closely. Thanks for your efforts here!
It starts by unapologetically digging heavily into mutation, which I disliked at first.
When I started learning OCaml, I was new and quite enamored with FP, and had a bit of a caricature mind set “mutation bad, functional good”.
Since then my view softened somewhat, my preference is still is to try FP first though.
Anyway I enjoyed working through the interesting exercises up to chapter 2 (for now), by comparing and observing the contrast of the different styles one can employ using OCaml (and more).
And FP is introduced incrementally, arguing for its existence etc.
I’ve got quite a bunch of books and this one feels like one of the best “all rounder” on my bookshelf.
I particularly enjoyed the N queens solution, a bit of a moment for me.
Always nice to see a new book (in English) on OCaml!
Is there some GitHub repo or a different place where we can flag errors in the translation, etc? E.g. I’ve noticed on page 11 “Let us now condier some additional details” I guess this was meant to say “Let us consider”.
Another question from the community: Is there any chance that this pdf can be published as EPUB as well? PDFs are hard to read on mobile devices and the fonts do not scale . EPUB is a much more versatile format.
Thanks @bbatsov for reporting the typo. Yes, we intend to set up a GitHub repo for readers to report typos and errors. This is on our TODO list (together with nicer web pages )
Thanks so much for this book! I always felt like OCaml was a fairly beginner-friendly language (some compiler messages notwithstanding…), and I’ve been sad that there isn’t much in the way of instructional materials for the novice in English.
I will be happy to recommend this book the next time the subject comes up!
I clicked the link download the preliminary epub file which downloads as lpo.epub, but in reality I have got a pdf file (called lpo.epub) which is 12 bytes shorter than the pdf file (1979697 versus 1979909 bytes).