Oxidizing OCaml, and a new opam switch

We just posted the thrilling conclusion to our blog trilogy on Oxidizing OCaml, which talks about some of the things we’ve been working on (and some of our space-age plans) around extending OCaml to support some of the same kinds of things that Rust lets you do, but in a distinctly OCaml-ish way.

Here are the posts:

Maybe more excitingly, you can play around with the version of our internal compiler that has the bits of this we’ve implemented thus far (mostly, the local/global stuff, but the beginnings of uniqueness as well) as well as our open-source libraries, via an opam switch.

This is very much a bleeding-edge, unstable version. We use it internally for real work, but we refactor it mercilessly, and the language features are most definitely not stable. We hope one day to propose a lot of this upstream, but for now, it’s just a preview of some interesting experiments.

The thing I’m most excited about all of this is the prospect of data-race free OCaml. The ability to leverage the great work done by the Multicore team, but safely, is a prospect I’m very much looking forward to.

Also, a bunch of Jane Street compiler folk will be at ICFP next week. If you’re interested in learning more, that’s a good time to grab one of us.

y

53 Likes

Super cool! As a part time rustacean, much of it resonated. It’s a big divergence from status quo ocaml, no doubt. The new concepts really do seem to map nicely with the rust concepts, albeit rebranded. Shall I be looking forward to a Signals n Threads ep soon? :grinning: :pray:

2 Likes

Can’t the “local” annotations be automatically inserted by some static analysis?
That would be cool.

2 Likes

This was a great read. Is there visibility on the chances of integration upstream, particularly of locality modes?

Data race freedom is exciting as well. Reading it, however, I wondered how intentional data races fit into this scheme. In OCaml, it is legal to race on a non-atomic value; and it can make sense to do it when you don’t care about having a total ordering between reads and writes. Efficient implementations of parallel-safe data structures sometimes involve intentional races, the same way relaxed atomics are often used in C.

2 Likes

I installed new OCaml using README but I can’t test examples with unique extension. Where could

✗ ocamlc -extension unique                                                              
ocamlc: wrong argument 'unique'; option '-extension' expects one of: comprehensions local include_functor polymorphic_parameters immutable_arrays module_strengthening layouts layouts_beta layouts_alpha simd.
Usage: ocamlc <options> <files>
Try 'ocamlc --help' for more information.
✗ ocaml                                                                                                                                    
OCaml version 4.14.1+jst
Enter #help;; for help.

# let dup x = unique_ (x, x);;
Error: Unbound value unique_

But this stuff seems to work somehow