DEV Community

Alex Lab
Alex Lab

Posted on

Can we compare Rust with WASM and ReasonML in the frontend future ?

ReasonML is here for a while but seem not very welcomed by the frontend community, yet. As Rust is strongly pushed by Mozilla throw WebAssembly.
How would you compare them together, how do you see their places in the future ?

Top comments (2)

Collapse
 
yawaramin profile image
Yawar Amin

ReasonML targeting JavaScript doesn't really compete for market share with Rust targeting WebAssembly. JavaScript is here to stay, people will need to target it for all kinds of apps, both frontend and backend. ReasonML is imho perfectly suited to this space of pragmatic, type-safe functional programming for targeting JavaScript. At this point I consider TypeScript to be its biggest competitor (there's some evidence for this: see 2018.stateofjs.com/javascript-flav... ).

The primary blocker to WASM for a lot of languages, is garbage collection (or rather WASM's lack thereof). This is what really makes Rust so well-suited to WASM (not any marketing efforts by Mozilla). If you need to target WASM today–the perf cost of JavaScript just isn't feasible–use Rust, no question.

That said, there is some very experimental work to give ReasonML a WASM backend. A lot remains to be done though. Overview here: medium.com/@sanderspies/the-road-t...

Collapse
 
rhymes profile image
rhymes

So Reason through BuckleScript compiles to JS, right? That in theory should make it possible to use WebAssembly from the compiled JS. Not sure how far along native interoperability is, it probably entails compiling Reason/Ocaml to it directly, and not just targeting JS as an output.

I'm not sure you could compare Reason and Rust directly though, unless you're talking in the general sense of two languages that can compile to native code.

ReasonML is here for a while but seem not very welcomed by the frontend community, yet

I might be mistaken and I know they are not the same thing but I feel like TypeScript is taking Reason shot at "mainstreamability". JS developers seem to be mostly interested in typing to help them with large code bases and TS gives them those without increasing the cognitived load too much. TS also allows them to incrementally improve the code without having to rewrite it. We'll live to see what happens in all of those communities of developers.

How would you compare them together, how do you see their places in the future ?

Currently Rust has the better tooling around WebAssembly but once WebAssembly will be "finished" in the browser and the system interface will be completed, I'm sure which language is used to target wasm will not matter much if at all (and that's a great thing!). I'm really excited about the future of WebAssembly on and beyond the web.