Update underlying OCaml version?

Is there any plan to update the pulled-in OCaml version? As of now, it’s 4.06 IIRC, does it make sense to update it someday? Some new features can be reused in rescript I think.

What features do you have in mind?

Nothing in particular to be honest, we could discuss that. In the grand schema of things I think about effects :slight_smile: It’s a distant future yet if we keep ocaml up-to-date it’ll be easier to start a discussion. Let me put it differently, is it hard to upgrade OCaml? I know objects were dropped but this shouldn’t be hard to drop them once again, should it?

Effects are going to be very hard to implement efficiently, especially considering rescript’s goal of producing readable JavaScript. It essentially requires throwing and handling an exception every time there’s an effect, which is just way too slow in JS runtimes.

Other than that it shouldn’t be too hard to upgrade, as I understand it. But it’s not clear that there’s any significant benefit to be had from it.


That’s assuming proper continuation doesn’t come to JS by that time in one form or another.

Not sure what you mean by continuations, but even if the necessary features were standardized and implemented in browsers today, it would still be many years before rescript could actually use it, since most developers need their apps to run in older browsers as well.

rescript still produces ES5-compatible code. Even if you enable ES6 modules, the only thing that changes is the code for importing from other modules.


Well, not quite. Rescript’s async/await is compiled to ES async/await, and that’s ES2017.

Which makes me wonder if effects could somehow be compiled to generators (which obviously predate async/await) and maybe CSP, but admittedly I haven’t dug into it, so I may not know what I’m talking about.

True, since today! :smile:

There’s some discussion in this PR adding support for effects in JSOO using CPS (not CSP) transformation. The gist of it is that it’s 2-10x slower and 1.5-2x heavier. And it certainly wouldn’t be very readable.


Just throwing it out there, but a potential benefit of updating the underlying compiler could be to benefit from the work that’s been put into OCaml’s developer tooling. There’s an LSP now and a bunch of incremental compilation stuff. Last December I did the advent of code in OCaml and was pleasantly surprised by the improvements in DX.

That being said, I don’t know if OCaml’s strides in that area would have any effect on ReScript with its separate LSP and toolchain.

Well ocaml-lsp used to be compatible with bucklescript, but after the rebranding it got decided to start a new LSP from scratch, it has pros and cons.

Monadic let* is one thing that could be interesting to have.

I think that’s pretty much just syntax sugar. Since rescript is its own syntax, I don’t think it should be too hard. And from past discussion, I think there’s desire for it to be in a much more limited form anyway. No user-defined operators and probably less general constructs.