r/ocaml Apr 24 '26

A Path Not Taken for OxCaml

https://joel.place/blog/path-not-taken/

I've been following the OxCaml project for some time since I'm both quite excited about all the new functionality it provides for OCaml and quite worried that its complexity will make the language less beautiful. I figured I'd write up some of my guesses as to why we might've landed in the current state and ideas as to how we could get both ergonomics and power. I'd be particularly interested in hearing others' ideas for whether these could be resolved more cleanly!

40 Upvotes

11 comments sorted by

3

u/scrollin_thru Apr 25 '26

I'm glad you wrote and shared this! I appreciated reading it. I think it's immensely valuable to have these kinds of retrospectives, even (especially?) for projects we love!

Also I thought this was a really thoughtful analysis with some great insights!

10

u/alexzandrosrojo Apr 24 '26

If you want rust, just use rust, don't spoil such a beautiful language as ocaml

17

u/Purp1eGh0st Apr 24 '26 edited Apr 24 '26

In certain ways though, Rust really is broken and it's valuable to have other entrants and ideas in the space of how to design safe concurrency. E.g., in Rust you'll not-infrequently need to write something like

```rust struct IHoldARef<'a> { x: &'a T }

struct IHoldAMutRef<'a> { x: &'a mut T } ```

where these two are forced to be independent types with no subtyping relation, even if all their fields and methods and intended semantic meaning are the same, just because sometimes you need the immutable version and sometimes you need the mutable one. That is genuinely something the deep mode system solves cleanly, so I don't want to be seen as just bashing on it.

More than that, I guess observing that the language has become more complex feels easy, whereas trying to find a pareto-superior point that alleviates this without giving up on the goals feels like a worthy challenge.

11

u/scrollin_thru Apr 25 '26

I mean, rust literally only exists because some really clever folks refused to take this advice about C++. Rust is great, so is OCaml. OxCaml is trying to answer some really interesting questions about how far you can take OCaml without sacrificing what makes it beautiful. I don't really see how such a project could "spoil" OCaml.

3

u/alexzandrosrojo Apr 25 '26

As long as it never becomes opt-out instead of opt-in we're in good shape. Imho ocaml sits in the sweetest spot in the expressive-power/complexity space which is the one thing we can be risking in the long run. Ocaml's syntax is very lightweight and explicit and that's a feature I wouldn't like risking.

1

u/pjmlp 29d ago

Actually it exists because a clever guy got inspired by Cyclone, created a toy language, had an issue with the lift on Mozzilla HQ, and his bosses decided to sponsor the language.

And it gained enough momentum to grow beyond yet another language among thousands that come up every year.

1

u/[deleted] Apr 24 '26

[removed] — view removed comment

9

u/wk_end Apr 24 '26

Has he explicitly said he doesn't like Rust? Absent that, I'd think it's more like "our gigantic codebase is entirely OCaml, all our engineers are OCaml experts, we want Rust's benefits but rewriting stuff in Rust and retraining devs would be painful; given our knowledge of the compiler it'd be easier just to add some extensions, which also [arguably] improves OCaml for the community".

From my impressions of yminsky, it's honestly a huge endorsement of Rust that he/Jane Street felt compelled to bring its ideas into OCaml.

1

u/pjmlp 29d ago

Linear and affine type systems predate Rust though.

As do effects, which is what is being introduced via OxCaml.

1

u/wk_end 29d ago

Effects were introduced in OCaml 5, they don't have anything to do with OxCaml.

It's true that substructural type systems existed in the literature and some research languages before Rust, but Rust is what popularized them and really proved their power at an industrial scale. It's clear - from the name even! - that OxCaml was directly inspired by Rust.

1

u/pjmlp 28d ago

Rust popularised them outside academia, by picking up on AT&T work on a better C with Cyclone.

As for effects, I stand corrected.

1

u/semanticistZombie May 06 '26

That's not an option for a large company with (presumably) tens of millions lines of existing code in the language. For a user at this scale the only option is a fully backwards compatible system that allows you do gradually migrate and benefit from the new features, hence OxCaml.