Hacker News new | ask | show | jobs
by a-saleh 2703 days ago
Wait, I assumed this will be a js-app, but it actually is a executable binary?

Is that the courtesy of https://github.com/jordwalke/pesy ?

For some time I wanted to try ReasonML for server-side development, but for some reason I assumed, that most of the ecosystem would be node.js based.

4 comments

Hi I'm Jordan and I work on Reason.

pesy is just a utility I made to help people create new native Reason projects (like fnm) quickly and easily. It's fun.

fnm is a native Reason app. We haven't advertised much of Reason's (OCaml's) native capabilities because we wanted to make sure we've built out a lot of the tooling that makes native development easy - for example https://esy.sh. Now that a lot of this native tooling is becoming polished, I hope you'll probably start seeing more projects like fnm.

Awesome!

I looked at Reason several months ago and my impression was, that if you want to do frontend stuff with bucklescript, you are one git-pull and npm install from a working scaffold, but if you want Reason with ocaml for native stuff, you would mostly be scaffolding yourself.

I am really glad I was mistaken :)

Several months ago that was probably correct. Recently, we've released new tools like esy that make it... easy, especially if you come from a JS background or are familiar with JS tooling. There's still a lot to solve, and native is just inherently harder than targeting JS, but a lot of progress has been made recently, and there's more to come.
Reason is merely a new syntax on OCaml. You can use BuckleScript (BS) to compile to JS, or not use BS to compile to native.

There exists a fast http server in native OCaml:

https://github.com/inhabitedtype/httpaf

Let's be a little more specific. "Reason Syntax" is merely a new syntax on OCaml, but ReasonML in general has a much larger scope - which includes every part of the toolchain/workflow up to and including package management, IDE integration, source formatting etc and more.
So Reason is to OCaml a little like Elixir is to Erlang - newer syntax, better tooling, same great foundation.
httpaf is quite low level. We need more abstractions on top of that for daily server development
One recent project which builds a usable layer on top: https://github.com/ostera/httpkit
The ReasonML ecosystem is quite confusing for newcomers. ReasonML could be compiled to a binary out of the box thanks to the OCaml toolchain. Pesy is a tool for making native development easier. Regardings Javascript compilation backend, you only hear about that because it's what the ReasonML team selling.
And I get that, I think I heard somebody from Reason community to say on some podcast once "We want to get the frontend stuff right first", or something along those lines :-)
That makes more sense to me now why doing server side reason compiles to a node.js app and not a more performant OCaml app. Server is not a priority yet.
Server side reason can already compile to native binaries (thanks to the OCaml compiler). While maybe smaller than the npm ecosystem there are a lot of high quality packages available on the OCaml ecosystem [1] that allow for a very pleasant server side development experience. For example https://github.com/rgrinberg/opium is a really nice high level toolkit. There are database bindings to Postgres, Mysql and the like, and high level interfaces to them like https://github.com/paurkedal/ocaml-caqti

[1] http://opam.ocaml.org/packages/

I feel you - it seems that most ReasonML blogposts are around JavaScript usage, but this is completely native and therefore faster (no VM necessary)