A short review of fmlib_browser (web frontend library)

This is probably better as a blog article, but I’m guessing anyone who is interested is quite likely to find it here. It’s just some short notes on my first impressions (as an ocaml beginner) of the fmlib_browser web-app library.

Summary

Elm and the basics of the port

Elm is perhaps the best known of the functional compile-to-javascript languages and is particularly attractive to functional beginners. It has a focus on good error messages and simplicity. It’s overall architecture (global model, no side effects, update messages) has been copied many times.

The fmlib_browser package is part of a family of functional/managed-effect libraries from the same author. It has basically the same structure as Elm, just translated into ocaml which is then compiled to javascript with js_of_ocaml.

I’ll not repeat the excellent documentation and in any case for a general overview you can probably rely on the Elm introductory material too.

In use

Boring in the best way. Does what it says on the tin. There are some docs on hooking it up to dune and it works with ocaml 5.0.

Compilation seems pretty fast, but be aware that by default you will get a javascript file that starts at about 5MB. If you run dune build --profile=release then the output will be stripped and minimised and you will be closer to 100KB. When gzipped for transfer this will come down to about 33KB as a starting point.

That sounds large, but it increases fairly slowly from that point as you add actual code.

Who is this for?

If you like the idea of Elm, are already working in OCaml and don’t need a large ecosystem this might do what you want. It’s not suited to small plugins but for a dashboard or other application you would leave open for a long time should work fine.

11 Likes