Profile avatar
z-th.bsky.social
I like building stuff. I mainly tweet about ReScript, Relay and GraphQL. ReScript core contributor. @arizon_ab.
33 posts 467 followers 25 following
Prolific Poster
Conversation Starter

I had the great opportunity to be on Developer Voices to talk a bit about ReScript!

This is going to make a few use cases, like when dealing with one-off nested shapes, much easier.

Explored options for my new personal project, from more common ones like Phoenix Liveview, to niche ones like Moonbit / Swift fullstack on Spin, Gleam fullstack with Wisp and Lustre, etc... Looks like I'm ending up with ReScript and @z-th.bsky.social stuffs like Resgraph, ReScriptRelay and pgtyped 😅

The new dot completion also works for objects. Objects are structurally typed, doesn't need a type definition, and are quite useful in some scenarios. Completion for object fields will be more ergonomic and get better discoverability with this addition.

With the new dot completion enhancements in our editor tooling you'll now get completions from the Option module when autocompleting on a record field that's an optional value, instead of just no completions like before.

This is one of the more exciting features I've worked on for the editor in a while. Pragmatic, useful and ergonomic. Just what we should be focusing on. I'm really proud of what we're doing! I look forward to 2025, which I think is going to be a big year for ReScript.

peak tech style is wearing the @rescript-lang.org hoodie

With the next version of RescriptRelay, you'll get access to a few new Relay APIs that makes using Relay without React with the full fragment based workflow possible. This opens up a few exciting possibilities, like using RescriptRelay + ResX to do (semi) static websites powered by Relay.......

I've been playing around with @rescript-lang.org for a React project I'm working on and I'm super impressed with how far it's come since I last checked it out! Also between ReScript and @gleam.run I'm absolutely spoiled when it comes to error messages

Type inference is simple but powerful. The compiler will infer each type that's unknown by usage. A consequence of this is that prop drilling is really simple, because you rarely have to annotate props. Just using the prop in the component defining it is usually enough.

ReScript, ResGraph and pgtyped-rescript is quite neat for building GraphQL servers 😍 Full type safety from DB to client, minimal boilerplate, all more or less "just ReScript".

In ReScript, pipes are normally used for chaining fn calls instead of method chaining with dots like in JS. This is a common gotcha for JS/TS devs who come to ReScript. To ease the transition we're experimenting with letting the editor tooling complete pipes also via dots.

This is one of the more exciting tooling things I've worked on recently. It just makes sense when you think about it, and I think it's going to be a huge boost in DX, especially for new comers. There are more cool things around this coming soon too. Shout out to @nojaf.com for the original idea!

In ReScript you can put expressions almost anywhere. Assign expressions to variables, put them anywhere in JSX, put them directly into function arguments, etc. Massive readability and productivity boosters, and you'll love it if you haven't written in a language with it before.

Since v11, ReScript has support for explicit partial application of functions using the "..." syntax at the end of the function call. Partial application of functions is useful in many scenarios, and this explicit syntax makes code easier to read and reason about.

Pipes are one of the most powerful concepts in ReScript. Pipes let you build function chains easily, with great support for type inference, and great editor support like autocomplete. It's just a syntax transform, so it compiles to regular, efficient JS function calls.

ReScript has first class support for tagged template literals since v11.1. A useful JS technique that's important for interop, and lends itself well to some pretty interesting use cases!

Dynamic imports shipped in ReScript v11. You can easily import both entire file modules, as well as single functions. For file modules, you simply await the module itself. For single functions, you use the `import` function. Makes things like React.lazy easy to use.

One example of this used in the wild - ResX, a server side framework for building websites. Emits HTML via JSX, has async components, and you can sprinkle in interactivity via HTMX. github.com/zth/res-x

I use this all the time and love it. Takes a lot of the pain away from dealing with promises.

We shipped a %todo extension point in v11.1. It makes it easy to postpone implementing something but not have the compiler block you continuing working. It'll produce a warning by default, and it's easy to configure the compiler so that it emits a hard error in for example CI.

ResGraph, implementation first GraphQL servers in ReScript, is still one of my favorite projects. It's just ReScript on the backend, with some constraints, and what you get is a JS GraphQL schema fully compatible with the existing JS GraphQL ecosystem. Lots of power with little effort!

In v12 we're hoping to ship Rewatch, ReScript's new build system, made by Jaap and Roland. Below is compiling a 375k LoC repo using the current build system vs Rewatch. 1. Current build system: 33.8s 2. Rewatch: 12.27s Speedup by a factor of 2.75 (!) in this example.

We'll ship our new standard library Core by default in v12. Core replaces the current standard lib and most of Belt, with one unified experienced that's built to look and feel more like the JavaScript APIs you're used to, while not sacrificing ergonomics.

We're further closing the syntax gap between ReScript and JavaScript in in v12: - First class regex syntax (previously needed wrapping in %re("<pattern>")) - Remainder operator - Use +, -, / and * for any number type, dedicated operators per type not needed And more coming!

Another new feature in v12 - variant type spreads in pattern matching! This allows you to refine variant types and easily match on a whole subset type without having to enumerate it. This was always possible with polyvariants, and now also with regular variants.

The thing I'm most happy about with this is that this is all just language features, that have been worked on in parallell, coming together. Untagged variants are just variants after all, with all the benefits that bring. More things like this are in v12, it's going to be a great release.

Quite a few new useful features coming to ReScript in v12! For example, first class syntax and pattern matching for dicts! Dicts are an important tool when interoping with JS. Cristiano has also done massive work improving the efficiency of the emitted JS, which can be seen in the output here.

A very exciting new thing for ReScript - unified operators by @hyeseong.kim ! Unified operators mean that operators (+ - /) can be used with float and bigint as well, not just int. 1.5 + 3.0, 1 - 3, and 1n / 3n all works as you'd expect, no special operators needed. Massive DX improvement imo.

Relay is working on support for preloadable connection based pagination. You can easily buffer/preload an arbitrary amount of items in anticipation of the next pagination. Exciting because this is a fairly common thing to want to do, and it's difficult to do today. github.com/facebook/rel...

Latest ReScript experiment - provide pipe completions from the type's module in addition to regular field completions on record field autocomplete. This makes pipe functions from the type's module (that are sometimes needed) a lot more discoverable for JS/TS devs. Great idea from @nojaf.com!