Bonsai: Dynamic web apps without JavaScript? OCaml makes it possible.
·2 min read·Intermediate
“
Tired of JavaScript for every web app? Imagine using a different, more robust language for the frontend. Jane Street has a solution that might surprise you.
In 30 seconds
01Bonsai is an open-source library from Jane Street for building dynamic web apps.
02It allows frontend development using the OCaml language, bypassing JavaScript.
→
💡
What this means for you
For the average person, it means web applications might become more stable and robust. For developers, it's a concrete, powerful alternative to the usual frontend suspects.
Tired of digging through menus and dashboards to check your Lighter points? Now you can just ask an AI. A new community project makes it all easier, or at least more chatty.
·2 min·Beginner
03The tool provides a more stable, functional approach to web development via Js_of_ocaml.
0101
What's this 'Bonsai' and what's it for?
Bonsai is an open-source library, created by Jane Street, that lets you build interactive web applications without touching JavaScript. It works by translating your OCaml code into something the browser understands, kind of like a silent interpreter.
Jane Street, a quantitative trading firm known for its fondness for functional languages, released Bonsai on GitHub. This tool is designed for those who want OCaml's safety and power on the client side too. After all, why stick to one language when you can use two (or more)?
0202
OCaml in the browser: magic or just clever?
No magic involved, just an ingenious compiler. Bonsai relies on Js_of_ocaml, a project that takes code written in OCaml and transforms it into JavaScript, making it executable by any browser. It's a bit like having a simultaneous translator, but for code.
Basically, you write your frontend logic in OCaml, a language known for its stability and robust type system. Then, Js_of_ocaml converts that code into JavaScript. The browser runs the generated JavaScript, and voilà, you have your web app without ever writing a line of JS. The Bonsai framework uses Js_of_ocaml to compile OCaml code into browser-executable JavaScript.
📬 Enjoying this article?
Get the best AI news every week, straight to your inbox.
0303
And if I'm not an OCaml guru, why should I care?
If you're not a JavaScript fan or you're looking for more stable alternatives, Bonsai offers a different path. It might not be for everyone, sure, but it opens doors for those who prefer functional languages or want a more predictable development experience. Fewer runtime surprises, if you catch my drift.
For code purists or those from the OCaml world, it's a godsend. It means less mental "context switching" and more consistency in the tech stack. You don't necessarily have to learn a new JavaScript framework every six months. Bonsai enables OCaml developers to create dynamic web applications, extending the language's use to the frontend. Not bad at all, right?
Imagine telling your PC what to do and watching it execute everything on its own, without touching a key. It sounds like sci-fi, but a new open-source project promises to let AI work directly on your desktop.
Tired of AI models that take ages to reply, or drain your wallet every time you use them? Good news: someone just mapped out a way to make them sprint. Picture a practical path to making large language models both faster and cheaper.