DEV Community

Cover image for Revery - Cross-Platform Desktop Apps With Reason
K
K

Posted on

Revery - Cross-Platform Desktop Apps With Reason

Cover image by Frank Brown, on Flickr

Currently, I'm researching my next project, a book about creating software MVPs and one big need that pops up rather often is the ability to build cross-platform applications with one code-base.

While I think that React-Native is the way to go, it's always a good idea to look at what other solutions are out there. Flutter, for example, got much hype lately โ€” a framework to build cross-platform apps with the Dart programming language.

Today I want to look at another promising approach: Revery

What

"Revery is kind of like super-fast, native Electron - with a bundled React, Redux, and a fast build system - all ready to go!"

Revery is a (currently experimental) cross-platform desktop app framework build with the Reason programming language.

Reason is a new OCaml syntax that aims to be more accessible for JavaScript developers; it also features a JSX like syntax. While it's mainly used to compile to JavaScript, via a tool called BuckleScript, it can compile to native binaries too.

Reason offers a sound type system with non-nullable types and pattern-matching, which should address the most notorious bugs of JavaScript code-bases.

Revery doesn't render native widgets, but its own widgets with the help of GPU accelerated rendering.

Why

While Electron is undoubtedly the fastest way to build desktop apps at the moment, it comes at the cost of its size and with a few performance issues. Electron ships with a whole browser to allow developers to leverage the web-ecosystem.

Frameworks like React-Native have the approach of using native widgets, which leads to better performance and smaller applications, which is a massive win on mobile devices, but it also leads to inconsistencies, because iOS and Android don't offer 100% overlap in native widgets or even their behavior.

So why not Flutter?

I think the main reason is that Flutter currently focuses on mobile development.

Revery has mobile platforms as targets on its roadmap, but it focuses on the desktop first.

How

Let's see how we get the example project of Revery up and running.

First, we need to install esy which a package manager for native development with Reason. It's installed via npm.

$ npm install -g esy

Next, we need to clone the example project with git from Github and open the project.

$ git clone git@github.com:revery-ui/revery-quick-start.git
$ cd revery-quick-start

Now we need to install the dependencies and compile everything with esy.

$ esy install
$ esy build

The first build will take some time, but after that, we can run the compiled binary directly.

$ _build/install/default/bin/App

Which opens the app and shows a window with text and button.

screenshot

In App.re we find the source and can change it as we wish.

Conclusion

I think Revery is a nice addition to the cross-platform framework landscape and Reason/OCaml is certainly an interesting language, with many nice features that address problems I know from my day-to-day JavaScript work.

The fact that Revery borrows concepts from React makes it especially interesting for me.

Top comments (17)

Collapse
 
vinceramces profile image
Vince Ramces Oliveros • Edited

Nice to see that it compiles down to native code and not bringing the whole chromium source. While flutter has flutter-desktop-embedding and go-flutter-desktop-embedding, it compiles down to native code using skia-engine and C++ embedder, it also has orientation built in for landscape and portrait, so resizing the window won't be an issue. The drawbacks for us is the instructions provided is not clear and hard to setup, It is now in experimental and would likely to be released in May 2019 as one of the Project manager announced during Flutter Live. Hoping that the setup is easy as 1 2 3.

I've seen the repo and would likely to try and test it out soon.

Collapse
 
kayis profile image
K • Edited

Yes, with the Google backing Flutter is a very practical solution. Revery is very experimental, but I think Reason/OCaml has more potetial than Dart, so let's see where this goes ๐Ÿ™ƒ

Collapse
 
vinceramces profile image
Vince Ramces Oliveros

I've never compare languages just because of its features and syntax, benchmarks is all I care the most.Production ready, Developer experience, Cross platform and Community is the one thing I am influenced at most.

That said. I wish Reason could grow much more to compete with other big tech companies. I have high expectation to its capabilities.

Thread Thread
 
rhymes profile image
rhymes

Isn't Reason backed by Facebook?

Thread Thread
 
kayis profile image
K

Kinda.

I think they wrote parts of some of their apps with it, but I think mostly because of it's compile-to-js features and less because of the native stuff.

Thread Thread
 
vinceramces profile image
Vince Ramces Oliveros

Sorry, I was referring to ReasonML and Revery as it grows. I only saw the revery repo and not the ReasonML. Sorry if it was misunderstood. Reason is being backed by facebook, yet they're focusing on React and React Native as they're JSX and React Community loved it.

Thread Thread
 
kayis profile image
K

As far as I know, the proof of concept of React was written in OCaml

Thread Thread
 
justgage profile image
Gage

Actually standard ML, which is a very close cousin.

Collapse
 
farukg profile image
farukg

Hi,

TLDR;
SvelteJS-Devs & Revery-Devs & ReasonML-Devs should work together on a unified project XD.

I just found out about Flutter/Dart, was seeing more and more here and there. They have so much already. If I was about to build a native app, i would probably choose Flutter even though i realllly like (to learn) ReasonML and its functional features for 2 reasons. No, actually 3 reasons. The last Reason just popped up again while typing:

you just can not google "Flutter vs Reason". You'd get results like "5 reasons to use Flutter today!" and nothing about ReasonML. I like puns, but finding information is a little hard, the word reason is soo frequent XD.

I think they just don't publish enough about ReasonML. Which is my 2nd reason. Bad Marketing compared to Flutter or React. Maybe also not enthusiastic enough. It has to be somewhat more exiting so that it over-weighs the concerns about learning maybe some useless stuff (<- totally not what i think of ReasonML!)

Lately, i watched a talk about SvelteJS from Rich Harris youtube.com/watch?v=AdNJ3fydeao&t=... which made feel bad about React ^ Which would be the no. 1 reason not to choose ReasonML. They have a rock solid type system and everything, but compile to a plain-old JS-Library?? (i know I'm too hard on React right now, sorry, i don't mean it haha)

While Rich Harris uses the same JS to write an AOT-compiler for some other newly-made-up flavor of JS+HTML/CSS? something feels wrong here.

Admittedly, both of course use flow or TS, but still.. the claim of ReasonML is that it has a superior super-sound mega-stable type-system which is around for 20 or 30 years (which I believe), but if at the end you fallback to the language you were criticizing earlier than the credibility suffers a little...Thats what I think and why I find Revery promising, maybe its a small step to compile to super-fast JS like svelte :D

Best,
Faruk

Collapse
 
omrisama profile image
Omri Gabay

Yo this is awesome. I've been reading a lot about a possible solution to the Electron problem. Looks like this might be it!

Collapse
 
kayis profile image
K

Yes, I also read about Electrino, which tries to use the OS' browser engine.

github.com/styfle/awesome-desktop-js

Collapse
 
sleepyfran profile image
Fran Gonzรกlez

This looks super cool! I'll definitely keep an eye on this as it's completely not production-ready right now. Thanks for sharing!

Collapse
 
kayis profile image
K

Yes, but the OCaml eco-system is rather mature, so I have high hopes ๐Ÿ™ƒ

Collapse
 
johnpaulada profile image
John Paul Ada

Man am I excited for this. I've been trying it Reason in small bits since watching Cheng Lou's talk in 2017. I hope I can try this out soon :D

Collapse
 
jacobherrington profile image
Jacob Herrington (he/him)

I'm really interested in this -- thanks for sharing.

Collapse
 
kayis profile image
K

You are welcome ๐Ÿ™ƒ

Collapse
 
jochemstoel profile image
Jochem Stoel

Hmm. I'm not convinced (yet).