HeadlinesBriefing favicon HeadlinesBriefing.com

GitHub's Bonsai: OCaml UI Library for Reactive Web Apps

Hacker News •
×

Bonsai is a UI library for building performant, reactive web applications in OCaml, used internally at Jane Street for tools like their corporate directory and trading system monitors. Components are implemented as purely functional state machines, enabling incremental rendering and composability. Bonsai separates state, incrementality, and rendering, allowing primitives to be reused across UI and business logic.

OCaml's type system enhances code legibility and error reduction, especially for large apps. The framework supports a powerful templating language, component-specific stylesheets, and automated tests, including realistic DOM manipulation scenarios. Bonsai's core library enables general-purpose incremental state machines, with specialized versions like Bonsai_web for browsers and Bonsai_term for terminals.

Preprocessors like ppx_html and ppx_css facilitate HTML and CSS integration.