News for hackers. Stuff that matters.
Re:Melange 1.0: Compile OCaml / ReasonML to JavaScript by pbiggar on Monday June 12, 2023 @01:58PM (#36298025)
When we (darklang.com) were working with Rescript, I was not optimistic about Melange's approach, but in retrospect I think it has legs.

The challenge with ReScript is that the authors really were focusing on the JS ecosystem, and didn't care at all about OCaml. Their fusion with the ReasonML community didn't make a whole lot of sense. ReScript is a much better language now that it has split than it was then, if you look solely through the lens of a better JS.

But, as Elm and other compiled-to-JS languages have learned, Typescript has gotten good enough that other languages might not be sufficiently better than TS to attract enough interest to have a vibrant community. Doubly so since the JS-interop story isn't nearly as good in ReScript as it is in Typescript (though it's much much better than in Elm).

However, the aim of writing programs in OCaml which compile to nice JS and also native OCaml, and allowing both client and server to be written in OCaml, remains valid and interesting (and I would argue was held back by js_of_ocaml, the pre-existing way to do it). So I think there is something interesting here, though it isn't a ReScript competitor except tangentially.

Though I cannot really understand where ReasonML (a JS-like syntax for OCaml) fits into this - if the target is OCaml devs, than surely the ReasonML syntax stuff is not valuable anymore?

Re:Melange 1.0: Compile OCaml / ReasonML to JavaScript by anmonteiro90 on Monday June 12, 2023 @02:05PM (#36298151)
Hi Paul, appreciate the kind words.

Your perspective on the project is exactly how we think about it: Melange provides the tooling for fullstack (@davesnx likes to call them Universal) Reason/OCaml applications.

I suspect my time in Clojure(Script) has heavily influenced how I look at a "Language of the System"[1], and that's effectively what we're trying to do here.

Re: ReasonML, I very much understand the sentiment. In my mind right now, ReasonML is only there to provide JSX and reason-react support. I suspect we'll eventually write a JSX PPX for OCaml and stop using ReasonML down the road (fairly longer term).

[1]: https://www.youtube.com/watch?v=ROor6_NGIWU

Re:Melange 1.0: Compile OCaml / ReasonML to JavaScript by m0meni on Monday June 12, 2023 @02:48PM (#36298951)
Thanks for Melange! I fully believe in the mission, backing, and philosophy of Melange over ReScript.

To add a counterpoint, though I'm in the minority, I think ReasonML is really really important to keep OCaml accessible to a larger amount of people. I work in a very cross-platform context and program in 5/6 different languages a month, and despite having a lot of experience with different syntaxes, OCaml is just weirdly unique enough that it's hard to immediately transfer my skills. I haven't written OCaml seriously in a while, and even looking back on my own code, for example the PPX I wrote https://github.com/AriaFallah/ppx_str 5 years ago, I can't really read it without zoning in and thinking quite hard vs. just flowing.

Re:Melange 1.0: Compile OCaml / ReasonML to JavaScript by anmonteiro90 on Monday June 12, 2023 @02:54PM (#36299081)
Thank you :-)

You also make a good point. I didn't go into too much detail about ReasonML in another comment, but I know Jordan (@jordwalke) has plans for a ReasonML v4 [1] with slight syntax improvements. I don't currently know the status of that work, however, but I think we'll want to make progress soon.

So the TL;DR is more that ReasonML is not going anywhere, especially since Ahrefs have a huge ReasonML frontend codebase [2].

[1]: https://github.com/reasonml/reason/pull/2605 [2]: https://tech.ahrefs.com/ahrefs-is-now-built-with-melange-b14...

Re:Melange 1.0: Compile OCaml / ReasonML to JavaScript by square_usual on Monday June 12, 2023 @02:04PM (#36298133)
I think it has value in that some people find OCaml syntax confusing, especially developers who have only had experience with C-style languages. For them, ReScript makes sense as an alternative syntax to a great language!
Re:Melange 1.0: Compile OCaml / ReasonML to JavaScript by meitros on Monday June 12, 2023 @04:12PM (#36300278)
Out of curiosity, what do you think the issues with js_of_ocaml were?
Re:Melange 1.0: Compile OCaml / ReasonML to JavaScript by pbiggar on Monday June 12, 2023 @05:47PM (#36301669)
The main problems as I perceive it: - unreadable generated code (aka, hard to debug in the browser) - not very accessible (complex docs, unclear what it is or how to use it)
Re:Melange 1.0: Compile OCaml / ReasonML to JavaScript by testcross on Monday June 12, 2023 @09:12PM (#36303814)
on any decent size application the output of bucklescript/rescript/melange is also unreadable. I never understood that argument.

some real problems with jsoo are (non exhaustive list)

- "heavy" FFI (both in term of setup and syntax)

- the output is a big single .js file, which doesn't allow reloading of a single component and doesn't integrate well with stuff like webpack

- slower compilation time

- lacking documentation for the javascript audience

Re:Melange 1.0: Compile OCaml / ReasonML to JavaScript by swuecho on Monday June 12, 2023 @08:33PM (#36303452)
What is your journey about F# and Fable?

I find Fable is good too and generated code is very readable.