We need to stop recommending Real World OCaml as introduction text

You’re describing the needs of an intermediate dev who’s already familiar with the language’s building blocks & a bit of the ecosystem and wants to get productive in it.

but even then,

Being opinionated and up to date are qualities early in the learning process.

opinionated towards ensuring as little upfront complexity as possible, by reducing the set of libraries and features one has to choose from, sure, which RWO fails to do at least feature-wise. and you can’t really beat stdlib at this since it comes preinstalled and doesn’t use advanced features!
(more accurately RWO doesn’t intend to make that attempt since the target audience is different)

Other resources tend to rely on a large number of libraries that must be combined together, usually without introducing all those libs, and provide outdated snippets.

which of the beginner books/resources (examples linked here) does this??

Writing a CLI, executing a http request, manipulating json, reading a file, …

first and last one are built-in & straightforward stdlib modules. Arg module docs (both with the ocaml.org learning section) come with an excellent tutorials at the beginning, with a much, much simpler interface than Core.Command. middle two require external libraries installed when following RWO as well. in fact, all require external libs if you consider Core and Async external (and indeed they are, since the book makes a point that you only need Base and those other two are unix-only so not all the reader base will be able to follow along).
also, by the time you understand the code examples present in all four sections you described in RWO specifically, you’ll need to be familiar with all the things you later complained about in your comment plus some more.

Contrast that with the fact that if you google today “how to read a file in ocaml”, you should hopefully be redirected to ocaml.org learning sections, and those are adequate and receiving some focus nowadays for further improving.

I’m describing one need of a developer who has been able to write (at least) scripts or short programs in other languages and are trying to do the same in ocaml. They don’t necessarily have actual experience with ocaml nor with functional programming. Note that those are actual profiles I met. Indeed those are not people learning to program. RWO might be relevant or not for total beginners, I don’t know.

I’m thinking mostly about blog posts. But there are also such pages on v2.ocaml.org and I think I’ve seen some in ocamlverse.

Clearly most (all) of what was introduced in RWO is doable another way. Also I’m not saying that using libraries is bad, my main complaint is about resources which uses some without properly introducing them (supposing existing knowledge about the ecosystem).

There’s no need to be familiar with all the concepts I mentioned earlier to start to be productive and use some of the code that is in the book. It’s also not necessary to read all the examples of the 3 sections. Actually it might even be possible to skip a large part of the first section and only jump there when digging deeper in a snippet of the second section.

It’s great that ocaml.org is starting to get more and more examples. I’m happy to see that things are improving there basically every day. There are very good courses available online. The MOOC used to be very good. But currently it hasn’t reached a point which makes the RWO irrelevant in my opinion.

2 Likes

As @hyphenref said, typeclasses don’t replace deriving mechanisms and macros. They do make those mechanisms easier to use though, since instead of needing to refer by name to a specific derived function, you can just use a generic type-disambiguated name. For example, when using ppx_show for type foo, you need to call show_foo because that’s the function that is created. With typeclasses, a simple show call would suffice.

I personally love ppxs and can no longer imagine programming real-world projects without them, since they can replace a ridiculous amount of boilerplate, error-prone code, preventing obfuscation of the business logic.

7 Likes

We should reimplement the whole SICP book into OCaml :grinning:

3 Likes

Please do share an update once it is ready!

Will do!

Cheers,
Nicolas

1 Like