janestreet / bonsai

A library for building dynamic webapps, using Js_of_ocaml
MIT License
368 stars 39 forks source link

pointers to bonsai vs reflex-dom (haskell) contrast #11

Closed ghost closed 3 years ago

ghost commented 4 years ago

I am trying to understand whether to spend a few spare minutes every once in a while on reflex-dom, bonsai, or something else. Can you point me to any papers or talks to help set some context? A direct comparison would be awesome, but understand that can take time

TyOverby commented 4 years ago

Ooh, reflex-dom looks neat!

Sadly, papers, talks, (tutorials), aren't in the best shape right now. Though now that Bonsai has begun stabilizing, we're working on all those aspects.

Something that I think makes Bonsai interesting is that the library is (to my knowledge) the only reactive UI framework that implements components as an Arrow, rather than the more traditional tree-based approaches (React/Vue/etc) or the FRP approaches. However, Instead of the dual-type-parameters ('input, 'result) t Arrow signature, Bonsai implements another signature, based loosely off of the Arrow Calculus paper. This means that you have two types ('a Value.t and 'b Computation.t) and a function for variable-substitution between them: val sub : 'a Computation.t -> f:('a Value.t -> 'b Computation.t) -> 'b Computation.t. This "sub" function is typically used via ppx, so you'd write

let%sub a = some_computation in
...

This is likely too short of an explanation to convince you one way or another, but I'll ping you here when papers, talks, blogs go up! In the mean time, if you decide to look into Bonsai a bit more, feel free to send me an email! (which you can find in my bio)