Bonsai: Janestreet's UI Library

Jane Street’s Bonsai UI library for OCaml prompts debate over whether specialized, strongly typed web frameworks still matter in an era when AI can generate bespoke UIs on top of mainstream JavaScript stacks. Supporters highlight Bonsai’s ability to share types between frontend and backend, its Elm-inspired incremental state-machine model, and its use for both web and terminal interfaces, especially in high‑information‑density trading tools. Critics question its timing, visual polish, ecosystem integration with existing JS tooling, and sparse documentation, while others note that for an in‑house shop with deep resources, these trade‑offs may be acceptable.

Platform & Scope

  • Initial confusion about being “web-only”; clarified that there is also a Bonsai_term terminal implementation.
  • Core library is framed as a generic, incremental, composable state machine framework; Bonsai_web and Bonsai_term are specializations for browser and terminal.
  • Some ask about using it for HTML reports or TUIs; responses say it shines for complex interactive stateful UIs, not simple static reports.

OCaml, Ecosystem, and “Same Language Front/Back”

  • Many like that frontend and backend can share OCaml types and logic; others note this has been possible for years with prior OCaml-to-JS efforts.
  • Comparison with js_of_ocaml vs Melange and other “compile to JS” stacks (Scala.js, F#, ClojureScript, KotlinJS, Fable).
  • Recurrent theme: integrating such stacks with the broader JS ecosystem requires wrappers and interop, which can be painful.
  • Some skepticism that in the age of LLMs, generic UI libraries matter less; counterargument is that better frameworks still help both humans and AIs avoid mistakes.

JS, WASM, and TypeScript Tangent

  • Discussion of tail-call optimization limitations in JS and the need for trampolines.
  • WASM is seen as promising but currently hampered by lack of direct DOM/web API access and heavier download size.
  • TypeScript is debated: some say it’s “just JS with types stripped,” others stress that a few constructs still require compilation and that it remains a distinct language.

Design, Aesthetics, and Information Density

  • Several comments criticize the sample UIs as visually unpolished or “’90s-looking.”
  • Others strongly defend high information density and minimal whitespace, especially for trading/finance workflows where speed and side-by-side comparisons matter.
  • Counterpoint: zero or inconsistent margins can hurt legibility even for expert users; tension between discoverability for new users and productivity for power users is highlighted.

Adoption, Tooling, and Docs

  • Concerns about bus factor, compilation speed, hot reload, and maintainability; some report OCaml compiles quickly and is very maintainable.
  • Bonsai is described as verbose relative to React/Vue, with some expecting LLMs to absorb the boilerplate.
  • Broken documentation links and lack of a public demo page are noted; DOM update strategy (direct vs diff) is raised but not clearly answered.
  • Confirmed heavy internal production use at its originating firm; uncertainty about suitability as a greenfield choice in typical product teams.