News for hackers. Stuff that matters.
Re:Bonsai: Janestreet's UI Library by flufluflufluffy on Monday August 03, 2026 @06:00AM (#49153587)
> And because Bonsai is written in OCaml, it becomes possible to use the same language and types on both the backend and frontend.

Finally! I was waiting for this to become possible!

Re:Bonsai: Janestreet's UI Library by philipwhiuk on Monday August 03, 2026 @06:59AM (#49154060)
Similar attempts include Scalajs.

The general challenge becomes integrating the fractional front-end code written in your backend-language that compiles to JS with the rest of the JS ecosystem.

JaneStreet have a love of writing their own stuff from scratch so it doesn't apply to them but it might to you.

Hence most people end up with frontend-as-backend rather than backend-as-frontend.

Re:Bonsai: Janestreet's UI Library by raphinou on Monday August 03, 2026 @07:33AM (#49154373)
Such attempts are quite common. Some I remember:

https://ocsigen.org/ in Ocaml too

https://websharper.com/ for fsharp and csharp. Really good when I used in in fsharp

Maybe https://melange.re/v7.0.1/ too? (Not sure)

Re:Bonsai: Janestreet's UI Library by vintermann on Monday August 03, 2026 @09:00AM (#49155221)
I took this as a joke in reference to the popularity of JavaScript on the backend for the last two decades.
Re:Bonsai: Janestreet's UI Library by reactordev on Monday August 03, 2026 @09:12AM (#49155355)
that's because most people's intro to CS was how to build a webpage.
Re:Bonsai: Janestreet's UI Library by zero_bias on Monday August 03, 2026 @03:01PM (#49160024)
Modern web development is more like computer alchemy
Re:Bonsai: Janestreet's UI Library by lbourdages on Monday August 03, 2026 @07:28AM (#49154329)
Couldn't WASM solve that problem once and for all? Is there some limitation that WASM has that JS doesn't?

Disclaimer: I am very inexperienced at front-end development.

Re:Bonsai: Janestreet's UI Library by danielheath on Monday August 03, 2026 @07:48AM (#49154496)
> Is there some limitation that WASM has that JS doesn't?

You need a JS trampoline to call your WASM and make browser primitives available to it, and IIRC calls into browser code incur some extra overhead, but those are pretty manageable.

Additionally: for high level languages, source code is _much_ smaller than compiled binaries. If your initial needs are simple, your users are likely downloading more than 10x as much code.

Re:Bonsai: Janestreet's UI Library by applfanboysbgon on Monday August 03, 2026 @09:40AM (#49155687)
WASM does not (yet) have access to the DOM or web APIs, meaning every direct interaction with the browser must first go through JS interop anyways, with a resulting performance penalty. There are proposals, and maybe we'll see it happen by 2035, but as of now WASM is best suited for heavier workloads where the edge in application performance outweighs the cost of JS interop with the browser rather than being a universal solution.
Re:Bonsai: Janestreet's UI Library by nobleach on Monday August 03, 2026 @08:34AM (#49154919)
Yup, and Clojure/ClojureScript!
Re:Bonsai: Janestreet's UI Library by vips7L on Monday August 03, 2026 @12:30PM (#49157980)
KotlinJs and ClojureJs too. You always end up having to write wrappers or dealing with problems that would just work if you just used normal js/ts.
Re:Bonsai: Janestreet's UI Library by gleenn on Monday August 03, 2026 @02:49PM (#49159877)
Clojurescript not ClojureJs, and Typescript doesn't run in the browser, it has the exact same issues/limitations: it must be compiled to JavaScript first.
Re:Bonsai: Janestreet's UI Library by warpech on Monday August 03, 2026 @03:00PM (#49160010)
Compiling TypeScript is just stripping out types
Re:Bonsai: Janestreet's UI Library by Stratoscope on Monday August 03, 2026 @03:38PM (#49160420)
That is true only if you confine your TS code to be pure JS plus type annotations.

There are TS constructs that require compilation into equivalent JS, such as enums and namespaces.

Re:Bonsai: Janestreet's UI Library by igl on Monday August 03, 2026 @04:16PM (#49160865)
absolutely nobody used those outside of a language demo. We also got --erasableSyntaxOnly last year to remove them from the language. The TS team considers them “mistakes“ for a really long time now
Re:Bonsai: Janestreet's UI Library by Stratoscope on Monday August 03, 2026 @05:29PM (#49161691)
Thanks for the correction! It was a long time ago that I used TypeScript, and making things worse (for my memory) it was an Angular project.

So today, most people and teams avoid the parts of TS that require compilation into different JS, and --erasableSyntaxOnly lets you enforce this, right?

Re:Bonsai: Janestreet's UI Library by igl on Monday August 03, 2026 @06:00PM (#49162045)
Exactly. There is plenty of code change however introduced by bundlers who do “bundling“, polyfill injection, minification, this kind of stuff.
Re:Bonsai: Janestreet's UI Library by p_l on Monday August 03, 2026 @04:16PM (#49160852)
"fortunately" we can load swc compiled to wasm to deal with that.
Re:Bonsai: Janestreet's UI Library by hermanradtke on Monday August 03, 2026 @03:58PM (#49160657)
Are there any other?

Namespaces are heavily discouraged. Some teams still use enigma but most people in the know us unions of strings.

I know the TS team regrets enums and I have not seen any plans for adding additional keywords that break type stripping.

Re:Bonsai: Janestreet's UI Library by Stratoscope on Monday August 03, 2026 @05:24PM (#49161638)
The other one I read about was parameter properties in constructors.

And thank you for the correction! It was quite a few years ago that I used TypeScript, and I think the landscape was different then.

Making things even fuzzier in my mind, this was an Angular project, and it was hard to keep track of what was Angular and what was TypeScript.

It sounds like people these days actively avoid the parts of TypeScript that require translation into different JS code.

Re:Bonsai: Janestreet's UI Library by gleenn on Monday August 03, 2026 @06:15PM (#49162171)
Isn't that like saying the Internet is only written in English if you strip out all the non-English. All C-style languages are fully cross compatible if you only use semicolons.

I can't write Typescript into a browser without cross-compilation and "stripping out types" involves parsing and manipulating code. That's a different language.

Re:Bonsai: Janestreet's UI Library by jitl on Monday August 03, 2026 @10:14PM (#49163684)
No. 98% of typescript specific syntax can be replaced with U+0020 SPACE to yield runnable JavaScript. The runtime semantics of the two languages are congruent. the same cannot be said for any other language im aware of.
Re:Bonsai: Janestreet's UI Library by gleenn on Tuesday August 04, 2026 @01:48AM (#49164718)
I'm sorry but if you need a transpiler to get it to run in a browser, character replacability and runtime semantics don't matter. Typescript doesn't run in the browser, it's obviously a different language.
Re:Bonsai: Janestreet's UI Library by vips7L on Monday August 03, 2026 @06:16PM (#49162182)
Except TS has much wider community support. The type definitions/wrappers are already written.
Re:Bonsai: Janestreet's UI Library by balencpp on Monday August 03, 2026 @09:11PM (#49163311)
Doesn't apply as much to Clojurescript due to it being dynamically typed and its flexibility. Sure, you often write a wrapper, but it's more of an abstraction and a good practice, not a necessity in cljs.
Re:Bonsai: Janestreet's UI Library by sysguest on Tuesday August 04, 2026 @03:02AM (#49165177)
"due to it being dynamically typed"

hmm ok nope

Re:Bonsai: Janestreet's UI Library by emmelaich on Tuesday August 04, 2026 @02:45AM (#49165063)
Re:Bonsai: Janestreet's UI Library by deciduously on Monday August 03, 2026 @09:06AM (#49155292)
There's also Fable for F# but I believe this commenter is being sarcastic. Javascript is a common backend language.
Re:Bonsai: Janestreet's UI Library by xp84 on Monday August 03, 2026 @06:29PM (#49162294)
I’m that ridiculous person who would rather learn OCaml from scratch if it meant I never had to use JS

Kidding of course. Mostly.

Re:Bonsai: Janestreet's UI Library by shawn_w on Monday August 03, 2026 @07:04PM (#49162533)
I'd rather learn MUMPS or COBOL than use JS... not kidding.
Re:Bonsai: Janestreet's UI Library by fulafel on Tuesday August 04, 2026 @03:43AM (#49165495)
Before JS became a common backend language, you could do this with at least one stack: Clojure & ClojureScript.
Re:Bonsai: Janestreet's UI Library by TacticalCoder on Monday August 03, 2026 @09:53AM (#49155842)
> Finally! I was waiting for this to become possible!

Sarcasm?

Do you want to have a talk as to why JaneStreet wasn't built on JavaScript?

Re:Bonsai: Janestreet's UI Library by klodolph on Monday August 03, 2026 @09:15PM (#49163329)
Sarcasm, definitely
Re:Bonsai: Janestreet's UI Library by rhgraysonii on Monday August 03, 2026 @11:19AM (#49156963)
A really great place to reach for this is Elixir/Phoenix now that the set theoretic type system is in place with LiveView. I have been doing some pretty large/complex codebases gradually working towards fully integrating working this way for the past 5 years and it has been great.
Re:Bonsai: Janestreet's UI Library by nesarkvechnep on Tuesday August 04, 2026 @01:41AM (#49164679)
Yeah… I’ve been a professional Elixir developer for 5+ years and additional 4 as a hobby. The quality of the ecosystem and the practices are nowhere near those in OCaml. Sad to say it. People just want to write imperative procedural code and monkey patch in tests so they can test anything at all.
Re:Bonsai: Janestreet's UI Library by kccqzy on Monday August 03, 2026 @03:34PM (#49160372)
Why wait? It’s been possible since forever. I wrote UI in OCaml eight years ago. https://github.com/kccqzy/drawing-guessing/blob/master/clien...
Re:Bonsai: Janestreet's UI Library by keepupnow on Monday August 03, 2026 @08:57PM (#49163223)
You are the pioneer and must be worshipped.
Re:Bonsai: Janestreet's UI Library by Conscat on Tuesday August 04, 2026 @12:15AM (#49164308)
I don't think someone mentioned yet, but the (now defunct?) company Outrun Labs built a product Revery which seems almost exactly like what Jane Street has done (to my amateur eyes). OniVim was their only end user product afaik, built on this tech.