4 ms·
> 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 t
by flufluflufluffy 2mo ago
> 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!
- philipwhiuk 2mo agoSimilar 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.
- lbourdages 2mo agoCouldn'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.
- danielheath 2mo ago> 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.
- applfanboysbgon 2mo agoWASM 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.
- raphinou 2mo agoSuch attempts are quite common. Some I remember: https://ocsigen.org/ https://ocsigen.org/ in Ocaml too https://websharper.com/ https://websharper.com/ for fsharp and csharp. Really good when I used in in fsharp Maybe https://melange.re/v7.0.1/ https://melange.re/v7.0.1/ too? (Not sure)
- vintermann 2mo agoI took this as a joke in reference to the popularity of JavaScript on the backend for the last two decades.
- reactordev 2mo agothat's because most people's intro to CS was how to build a webpage.
- zero_bias 2mo agoModern web development is more like computer alchemy
- nobleach 2mo agoYup, and Clojure/ClojureScript!
- vips7L 2mo agoKotlinJs 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.
- gleenn 2mo agoClojurescript not ClojureJs, and Typescript doesn't run in the browser, it has the exact same issues/limitations: it must be compiled to JavaScript first.
- warpech 2mo agoCompiling TypeScript is just stripping out types
- Stratoscope 2mo agoThat 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.
- hermanradtke 2mo agoAre 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.
- Stratoscope 2mo agoThe 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.
- emmelaich 2mo agoGoes way back to 2006 with GWT. https://en.wikipedia.org/wiki/Google_Web_Toolkit https://en.wikipedia.org/wiki/Google_Web_Toolkit
- deciduously 2mo agoThere's also Fable for F# but I believe this commenter is being sarcastic. Javascript is a common backend language.
- deleted 2mo ago[deleted]
- xp84 2mo agoI’m that ridiculous person who would rather learn OCaml from scratch if it meant I never had to use JS Kidding of course. Mostly.
- shawn_w 2mo agoI'd rather learn MUMPS or COBOL than use JS... not kidding.
- catlover76 2mo ago[dead]
- fulafel 2mo agoBefore JS became a common backend language, you could do this with at least one stack: Clojure & ClojureScript.
- TacticalCoder 2mo ago> 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?
- klodolph 2mo agoSarcasm, definitely
- rhgraysonii 2mo agoA 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.
- nesarkvechnep 2mo agoYeah… 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.
- kccqzy 2mo agoWhy wait? It’s been possible since forever. I wrote UI in OCaml eight years ago. https://github.com/kccqzy/drawing-guessing/blob/master/client/src/Index.ml https://github.com/kccqzy/drawing-guessing/blob/master/clien...
- keepupnow 2mo ago[dead]
- Conscat 2mo agoI 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.