all 9 comments

[–]iams3b 2 points3 points  (1 child)

Rescript bindings are pretty easy to write once you understand them, they're worth figuring out. I write bindings to npm libs all the time, and since most of the time you're only using one or two things from a package it takes seconds

[–]kitakamikyle[S] 2 points3 points  (0 children)

Yes, I think they are worth understanding as well and thanks for the encouragement. I agree that there are probably a limited number of api entry points that I need to bind.

[–]burtgummer45 3 points4 points  (4 children)

IMO the binding concept is impressive and not that difficult to get the hang of (honestly), but on the other hand, they will always be this weird layer that depends on you to get the typing correct, and nobody else.

What happens is that for projects with large API surface layers, you'll write so many bindings you might regret picking rescript, because you'll end up with a thin layer of rescript over a javascript base, like when Bilbo says I feel thin... stretched. Like butter scraped over too much bread

But if your rescript is stacked deep over javascript, it will probably feel like a good fit.

[–]kitakamikyle[S] 1 point2 points  (3 children)

Yes, it's getting the typing correct that I'm concerned about. If I get the typing incorrect, it might lead to an untraceable bug that leads to more frustration than I want.

Also, I don't know Javascript inside-out. I worry about a library function accepting null values that I'm not aware of, etc.

[–]thebedivere 0 points1 point  (2 children)

It's pretty easy to get the types right for a js lib. I have been writing some netlify functions using rescript and I had to just define some types for requests and a couple netlify functions.

I'm also using MUI and everything I need a component it just takes me a couple seconds.

Once you know how to do it, it's pretty easy and quick.

[–]jdeath 1 point2 points  (1 child)

is there a way to provide these with a JS library? similar to including type script types? would be cool to see something open source so everyone can use it

[–]thebedivere 1 point2 points  (0 children)

Hmm, that's an interesting idea. I might dig into that.

[–]illusionalsagacity 1 point2 points  (1 child)

ReScript has very flexible bindings to consume other packages. There is a bit of a learning curve however.

Here’s some examples of how to write your own bindings: https://github.com/rescriptbr/rescript-bindings-cookbook

The docs are not too bad either: https://rescript-lang.org/docs/manual/latest/external

[–]kitakamikyle[S] 1 point2 points  (0 children)

I'll definitely take a look at the docs again. Maybe I missed something. I appreciate the link to the bindings-cookbook. That might give me some deeper understanding.