ReasonML/BuckleScript vs PureScript JS Interop

I’ve probably said a 100 times on here that I like it, yes. However, making a language that uses Lisp syntax is a one-way ticket to pointless discussions with people about how it looks weird. It’s disliked almost instantly by most people and the only people who actually like it are people who know that there might be more to it than just “Oh, it’s there to make you think twice”.

Note that I wasn’t saying that Lisp syntax has no upside. It’s clearly the syntax that makes the most sense for a language built for using macros. That’s not what we’re talking about, though. We’re talking about positive and negative differentiators and primarily the ones that hit newcomers.

My assertion is that almost no one thinks OCaml syntax is weird enough to back off from it, whereas the same cannot be said for Lisp syntax. Is it the way it should be? No, but that’s how it is. If we had some magic crystal ball that could tell us the truth, my guess is that it’d say that the people who say “OCaml syntax is weird” are mostly people who had never heard of OCaml or at the very least had never used it before Reason came along. They pick up that OCaml syntax must be bad because the community members say it, and so the meme lives on.

1 Like

On the subject of FFI: how does GHCJS and JS of OCaml handle FFI? Does anyone here know? :slight_smile:

Unsure about GHCJS (I’ve barely dabbled in it enough to see that it works), but JSOO does it by exposing a Js module that allows for unsafe calling (so you just add types to the hoist functions for those, it looks more like let js_document = (Js.Unsafe.js_expr "window")##.document or let v = Js.Unsafe.global##.document if you have a global object in scope). You don’t want to use those in user code but rather making wrapping libraries around whatever you are wrapping, like using external in BS or native FFI or so. JSOO I think uses external behind the scenes but just wrapped up in an easier to use interface library that’s built in. It also has some types to allow auto-coercions and type matching and such too. In general if you are touching anything in Js. from user code then you are probably doing things wrong. ^.^

You know, I’m curious, I’m going to double-check on that…

Ah yep! JSOO does still use external internally, it’s just a simple mapping to the direct javascript call similar to BS (although you need a stub native thing to make the OCaml linker happy since JSOO runs ‘after’ linking, hence why they made the Js.Unsafe module to wrap that all up for ease of use).

1 Like

Word from Bob on this: https://twitter.com/bobzhang1988/status/1125038877796757504

Yep, exactly that, they are optional just to make binding more ‘direct’. :slight_smile: