ReScript versus Fable

I really like F#. I’ve been looking at Fable. Seems pretty nice - lots of community support, great editor support, great core library, let!. They seem to have a decent interop story with javascript. Can’t get it to produce TypeScript though. And the javascript it produces is not my favorite - uses Classes for example. Is there a “story” for how ReScript compares to Fable? Advantages and disadvantages?

My advice, try making a small sample app in both and see which one you like better :slight_smile:

3 Likes

I spent some time deciding between those two, and I ended up with Rescript. It’s really a question of personal choice, but I see several points where for me rescript clearly beats f# + fable:

  • Compilation speed:

It takes 0.2s to compile my current small rescript project from scratch, and 10 times faster to recompile all my files. In other fsharp test apps I’ve developed I’ve had 6s of initial compiling. It’s not as bad as typescripts, but one thing that I definitely did not like is how much slower the fsharp compiling step is in fable. I wanted to see how slow could compiling a big fsharp fable project be and the results where not really good. Nothing on the fable part, that one is actually quite fast, but F# compile times are very mediocre. Rescript feels almost like an interpreted language when developing server-side apps.

  • Type system:

The rescript type system inherited from ocaml is far more expressive than the f# one. You dispose of more powerful tools such as module functors, polymorphic variants, GADTs, etc. Most of these you might not want to use them because of complexity, but it’s really nice to have them for better type programming.

  • Tooling:

Even though Ionide is far more mature than the vscode rescript plugin, I actually prefer the rescript DX. Yes you have code lenses and other nice features with Ionide, but if your project scales I’ve experienced some slow intellisense, syntax coloring breaking, …

With rescript the intellisense is almost instant.
On the other hand f# has fantomas for code formatting, if you care about it.

There’s also Rider with f#, but I don’t like IDEs

  • Syntax:

F# syntax is really lightweight compared to rescript. It’s really nice to read, but I’ve had problems where I did have to wrap an anonymous function with parentheses while writing a pipeline. The final result looks good, but I don’t know, personally I see the disadvantages of having such lightweight syntax. With rescript, all having parentheses, commas between arguments and curly brackets everywhere makes the type inference work like a charm.

  • JSX support by default

There are other things like computation expressions which make complex monadic code simpler, and I could extend myself far more into pros and cons I’ve seen. Personally I really miss active patterns in rescript, which extends and makes pattern matching even more powerful.
This is my personal experience, and it might differ for you, so I recommend you that you try both languages and see which one you like most.

6 Likes