Doc Review: Updating S-Expressions Tutorial

We’ve been working on updating and improving the Learn documents on OCaml.org, and we would love your help and feedback in reviewing them.

Did we miss anything?
Does something need clarification?

We’re also still hoping for feedback and comments on the updated Getting Started documents: A Tour of OCaml and How to Write an OCaml Program. The Install OCaml tutorial will be coming soon for community feedback.

Let’s shape these up so newcomers can quickly get up and running and minimise confusion around adopting OCaml.

Thanks for your help!

6 Likes

I’m not a user of sexp (yet) but I noticed one thing that confused me a little.

Up front it says that the JS Core library is not a dependency, which implies it is not required required to use sexplib:

The sexplib created by Jane Street provides support for S-expressions in OCaml. It was developped to provide support for S-expression to Base and Core. However, S-expressions serialisation does not depend on these packages. In this tutorial, we only use sexplib. You can install it using opam.

(Also a spelling error: developped.)

But then later under Constructing it implies that the Core library should be used deal with sexps:

The Core package provides many ways to deal with S-expressions, a Sexp module to deal with the S-expressions themselves, and sexp_of_t / t_of_sexp functions provided by data type modules (like String, List, etc.) that allow users to convert OCaml data to and from S-expressions.

I think the above might be better as an afterthought or footnote, since many people will not be using Core.

Thanks for writing this, I will refer to it in the future when I used sexplib!

3 Likes

Thank you so much for your feedback! We’ll address these things and let you know when it’s done.

Nicely done :slight_smile:

So far, I’ve only dealt with S-expressions for testing purposes.

Regarding OCaml to OCaml communication, is there any advantages to use this format vs JSON ?

Also, it’d be nice to mention alternatives and explain why and when using them would be appropriate or not.

For instance, marshaling is in the standard lib if I’m not mistaken but some libraries also provide version independent binary formats.

I think this format is smaller than json, especially for representing ocaml data-structures like sum types. It is also easier to write a parser and a printer for it, and to write it by hand (see dune files) which counts for something

1 Like

It’s definitely smaller, and perhaps attains the most minimal generic textual representation possible. I’m not sure it’s more human-readable.

1 Like

And it’s not super interoperable, everyone has its own idea on how to represent key value maps see my comment here.