5 ms·
Real World OCaml is indeed awesome -- while it is free, if you do find yourself making good use of it, please also at least buy an ebook version. Totally worth
by jallmann 12y ago
Real World OCaml is indeed awesome -- while it is free, if you do find yourself making good use of it, please also at least buy an ebook version. Totally worth its bytes in gold. (No affiliation, just an OCaml dilettante who's benefitted a lot from RWO).
For good code to learn from, I'd also recommend Batteries, another stdlib replacement [1]. It's not as expansive as JSC Core, which arguably makes the code easier to browse, IMO. Ditto for lwt in place of Async. Really, a lot of the FOSS tools and libraries in the OCaml ecosystem are extremely high-quality -- and still improving at a rapid pace, thanks to OPAM.
If any of the RWO authors are reading this, I'd love an expanded version (or another book) with more advanced features of the language -- GADTs, a deeper treatment of the functor/module system, covariant/contravariant types, Camlp4 and/or the extension points mechanism, etc.
[1] I recall reading somewhere the extlib/batteries author said he would have written the library in a more functorial style if starting over today, but I still find it an excellent example of clean, idiomatic OCaml.
- avsm 12y ago> If any of the RWO authors are reading this, I'd love an expanded version (or another book) with more advanced features of the language -- GADTs, a deeper treatment of the functor/module system, covariant/contravariant types, Camlp4 and/or the extension points mechanism, etc. I'm actually meeting our editor (Andy Oram) in a couple of weeks at OSCON to discuss just this. We deliberately stayed away from newer features (e.g. GADTs) that we didn't feel had enough of an outing in production codebases, but with the release of OCaml 4.02 due in a few months this is a good time to do a refresh and fix that. What aspects of the module system would you like to see more of?
- jallmann 12y ago> I'm actually meeting our editor (Andy Oram) in a couple of weeks at OSCON to discuss just this. Great to hear that! > What aspects of the module system would you like to see more of? The book is actually comprehensive in this respect, but the module system is just a lot to digest. I'm not actually an expert, so I really don't know what could/should be done, only that sometimes it takes me a while to figure out "best practices", or what's required by the compiler, or the semantic implications of some of the more unfamiliar syntax. For example, recently I saw: module Client : module type of Client.Make(IO) which differs from the "module type of" usage discussed in the book. The OCaml module system is extremely rich, with a learning curve to match. I don't really feel that I know how to exploit the system to its fullest just yet. Maybe a section on common patterns or best practices would be helpful. On a side note, thanks for all your effort, not just on the book but also in keeping the OCaml community vibrant. I wouldn't be nearly as interested without all the work that's going on now.
- avsm 12y agoThanks, that's all very useful feedback. There have been several significant improvements to the module system in 4.02 (including generative functors and module aliases [1] in signatures), so I agree that there's quite a bit more to write about. We have a very short section on common patterns that could perhaps be expanded into a chapter. [1] https://blogs.janestreet.com/better-namespaces-through-module-aliases/ https://blogs.janestreet.com/better-namespaces-through-modul...
- a0 12y agoRWO does an excellent job in introducing OCaml's main features in a simple and pragmatic way. It really does show the strength of the language and demonstrates the building blocks one can use to write high quality software. One aspect that I think could be explored deeper is how to architecture complex applications with the language. How the module system can be used to build abstractions and protocols for not-trivial systems? For example how one could build a database with it, or even an operating system? I'm in the process of learning OCaml and what is really difficult for me is to understand what are the most idiomatic and efficient ways of modelling application domains. Although there are many open-source projects one can learn from (like JaneStreet's libraries, Nymote sub-projects, etc), the concepts and practices they use are sometimes hard to understand just reading the source.
- amirmc 12y agoI was just about to suggest looking at projects like Mirage/Irmin et al but since you mention Nymote, I assume you've already found your way to them. If it helps, we have a series of blog posts about some of the recent library releases on the Mirage blog [1], some of which go into the design of those libraries. Perhaps they'd be useful? [1] e.g. http://openmirage.org/blog/introducing-ocaml-tls http://openmirage.org/blog/introducing-ocaml-tls
- a0 12y agoThank you! I'm impressed with the serie of blog posts the Mirage team posted lately – really informative and inspiring. I think this kind of system design articles are really valuable to actually learn how to use the language in the wild. Another good example of a very good software design reading I've fuond is the OCamlgraph's paper[1], which demonstrates the strength of the ML's module system in a not trivial situation. [1]: http://www.lri.fr/~filliatr/ftp/publis/ocamlgraph.ps http://www.lri.fr/~filliatr/ftp/publis/ocamlgraph.ps
- pjmlp 12y agoI would like to see some more Windows love than on the first edition. Bought the ebook, and ended up just reading it as a means to see what changed since the Caml Light days and differences to F#.
- edwintorok 12y agoIIRC one of the chapters in RWO did briefly touch on type variance.
- mjt0229 12y agoAs I recall, GADTs are also touched on, but I agree that I still want more of all of these things.
- hackerboos 12y agoI've just bought the dead tree version on the recommendation of the OP. Cheapest place to buy in the UK is the Book Depository.
- amirmc 12y agoThere's a new blog post up where GADTs have been used in one of the OCaml-TLS libraries (i.e ASN1) https://news.ycombinator.com/item?id=8020125 https://news.ycombinator.com/item?id=8020125