Gabriel Nordeborn - Rescript
Gabriel Nordeborn from the Rescript team showcases the OCaml-based language's superpowers including pattern matching and seamless React integration for frontend development.
his week we talk to Gabriel Nordeborn, a core member of the Rescript team. Rescript is a langauge that compiles to JS but has some serious superpowers. Whether it is it's awesome pattern matching, or greate react integartoin there is a lot to love. Come learn about it with us.
Sections
- [00:00:00] Introduction
- [00:02:38] First Project and Transition to Development
- [00:04:47] Discovering Rescript and Initial Impressions
- [00:11:09] Rescript vs TypeScript: Key Differences
- [00:22:56] Interoperability with JavaScript and TypeScript
- [00:25:21] The Art of Writing Bindings in Rescript
- [00:28:37] Tools and Integration with JavaScript Ecosystem
- [00:32:43] Rescript's First-Class Support for React and JSX
- [00:40:54] Exciting Features in Rescript Version 12
- [00:43:55] Future Vision for Rescript and AI Integration
- [00:47:33] Conclusion and Final Thoughts
Transcript
[00:00:00] Introduction
Gabriel: So the philosophy is kind of we want to things to be simple, like to stay ~~simple, ~~simple data structures, simple types.that with a few very sharp tools you can get really far. And, um,
Not too much magic, essentially because we believe that makes things more maintainable, more approachable.
Andrew: Hello, welcome to Dev Tools fm. This is a podcast about developer tools and the people who make 'em. I'm Andrew, and this is my co-host Justin.
Justin: Hey everyone,~~ uh,~~ we're really excited to have Gabriel Nordboe on with us. Uh, the Rescript team. ~~Uh, ~~and rescript is the language I've had my eye on for a long time. It looks really awesome. ~~Um, ~~so it's like a. Purely functional, like strongly typed language that has a more of a sound type system than TypeScript has.Gabriel, you work on, uh,
~~Uh, ~~but it like compiles to JavaScript. Um, we'd like to hear a little bit more about you. So would you like to tell our listeners a little bit more about yourself?so I'm really excited to dig in and talk more about that. But before we do, uh,
Gabriel: Sure, of course. Hey, everyone waving for those on the audio podcast. Uh, out of,~~ uh, uh, my name is Gabriel. I am, um,Stockholm, Sweden. uh,~~ language itself for maybe three years or so now. Uh, rescript,I got two kids living here. I've been involved with, uh,Uh, I've been a software developer for.and I've been working as, um,
~~Well ~~over a decade. ~~Um, ~~but originally I'm actually a behavioral scientist, so I studied a bunch of psychology ~~in, ~~in university. ~~Uh, ~~so that's where I ~~kind of, uh, ~~got into this and then I fell into ~~the, the, ~~the programming stuff as well. I've always ~~been, ~~been doing a bunch of programming when I was little, like ~~back when, ~~back when CSS was actual attributes on the dom nodes only?
No, like actual style sheets. And those things when guest books in PHP and my esquela was the big thing like ~~that, ~~that's when I. I had my, my, my starch in programming, so to speak. And ~~then, ~~then I tried to avoid going down the engineering route just because I didn't wanna get stuck by the computer for the rest of my life.
Uh, when I we're almost done with university and I had to do like my master's thesis,~~ uh,~~ I slipped back in and it worked out really well throughout university. I did the psychology stuff and then, uh,kind of, and then. I ended up getting a job as a developer, and then that's the kind of where that comes from.I did a web-based experiment, uh,
I, I've always been very interested in and involved in open source. That's very important to me,~~ um,~~ and something I value highly. Even before I did development, I was,~~ uh,~~ I was very interested in open source and using lots of open source software, helping out, like debugging and stack traces and whatnot.
[00:02:38] First Project and Transition to Development
Andrew: So was that first project ~~kind of ~~like the intersection of your degree in programming or was it just like some
Gabriel: No, it was a really, like a really weird, um, experiment. I, uh, I wanted to, there, there's like, there's, um, there's some, there's like color psychology,~~ uh, a, ~~a small, small, small branch of psychology with not lots of research in it. ~~Uh, ~~but there's a bunch of like, theory around colors and how colors can affect us and how that's like culturally bound.
Uh, so I did an experiment where I set up a. A WordPress site that kind of mimics a, um, a, uh, medical information site. And then I had my cousin who's a, like, um, a researcher for medicine. I had him make up a disease and then put that, ingested kind of, and answer questions.that disease somewhere in, in the, the website. And then people had to find information about the disease, uh,
And then the manipulation was. Three different color schemes. ~~Uh, ~~so did that affect the, like people were slightly slower on the red theme.the speed of, and the level of comprehension and those types of things? uh,Um. color theme, which, uh, may had a, an impact that was,Didn't really affect that. Like there was a small, like, uh, three-way interaction between like being a male and the red, um,
And then you could fear exercise a bunch of, oh, that's because back in the stone age when, uh, when your enemy got angry on you, like they had a red face, and that makes you scared and comprehension goes, yeah,~~ you,~~ you get the point.
Andrew: Yeah, that, that's interesting. ~~I, ~~I feel like Blue might have ~~some, ~~some association there, but there has to be a reason that every company uses Blue.
Gabriel: So ~~blue is, ~~blue is really ~~like, ~~that's soothing and, calming and those, but apparently it's different and, uh,in, eastern cultures compared to western cultures. Red is more soothing there, apparently. ~~Uh, ~~so it's, yeah. Interesting. ~~Uh, ~~yeah. Thing, but in, uh,when I, and after I did that and I came out to the, trying to get a job, turned out that this was back in.when I did that, uh,
2014 or so. ~~Um, ~~there was like two jobs in Sweden for behavioral scientists and 2000 jobs for developers. So I ~~kind of, ~~that was ~~the logical, ~~the logical choice. So I'm here at the computer for the rest of my life anyway, but I guess I gave it a shot at least.
Justin: So how did that lead you?
[00:04:47] Discovering Rescript and Initial Impressions
Justin: Like where in your journey did,~~ uh,~~ or what led you to discovering rescript?
Gabriel: I got started with PHP,~~ uh,~~ that was my base,~~ uh,~~ starting out. And then as all the things I've come to then love. I hate them at the first site. So, uh, and,~~ uh,~~ sometimes needed more interactive stuff than you could deliver with just service side rendering.we were doing lots of client work. I worked at a web agency, uh,
So like natural thing,~~ uh,~~ JavaScript, right? Uh, old frameworks. a colleague of mine showed me react. I instantly hated it. ~~Uh, ~~looked terrible.and back then, this was just when React had came out, essentially. It was still the very, like the new thing on the block. Angular one was the big thing, backbone. Those, uh,
Why would you do, I think I. Specifically said, like, why would you ever do anything with JavaScript if you just have PHP and the server, right? ~~You have, ~~you have your query, PS you can just re-render. ~~Right? Um, ~~but we had a couple of requirements which made that ~~we, ~~we had to use that. And so ~~kind of ~~got into it.
I, warmed up to it. ~~Uh, ~~and then eventually, since I like to I, uh,kind of this time has actually existed.think about these things and analyze, eventually I saw flow like,back, that was the hot thing before TypeScript when TypeScript was a thing, but wasn't really that hot. This has actually,back when that was. Back when, um,
Not, all of the open source stuff they did. not a lot of uh,like Facebook project. Facebook had a massive kind of, looking at the graphs now. You wouldn't believe that. But this was back, like flow was a hot, interesting, uh,um. momentum going with React and,Had a massive, um,Uh, saw that wow, so I looked into Flow, uh,there's a, discover bugs and issues before we ship it to the clients.there's a way to, um,
Excellent. I didn't have a background in any of the type languages in that sense. I've done a little bit of like c and stuff, but yeah, it doesn't really count. Um. and those, and then back then in this was maybe 2018, the first time So I thought flow was really interesting. uh,Um, uh, TypeScript. and then I eventually also of course got into, uh,Uh, type safety,but we used Flow a lot, used TypeScript a lot, but it was always like, I was always looking for more, so to speak, in terms of, uh,I, recent ML was a thing and B script.I saw this, uh,
~~Uh, ~~so ~~I, ~~I ~~kind of, uh, ~~slipped into that, landed all that. And quickly realized that this is what I would like flow or TypeScript to become, for me to be happy with it. ~~Well, ~~maybe not. ~~I mean, ~~it wasn't perfect back then. Neither is it now, but still like, uh, back then.if you compare it to the goals of Flow or TypeScript and the goals of recent backer script, um,
That, that was much more what I was interested in, like the inference clear as soundness in the type system, uh,like, um, that's easy to work with the mutability and not like I'm not at all,~~ um, uh, data structures, uh,hardcore functional programming enthusiast in that sense. I am, I'm very much a. Pragmatist, like I wanna do stuff that I, that works, uh,~~ that I feel like works ~~and, and, ~~and that I can ~~kind of ~~prove over the ~~long, ~~long run works.
And,~~ um,~~ a type system that is sound that you can trust with,~~ um,~~ nominal types instead of structural types,~~ uh,~~ and those types of things in places where it matters. That just resonated with me very much, so I started getting into that. ~~Uh, ~~so that's ~~kind of how I, ~~how I got into that. ~~Um. ~~From the beginning, essentially.
Andrew: Cool. ~~Well, we're, ~~we're big fans of TypeScript on the podcast. I'm literally wearing a TypeScript sweatshirt right now. ~~Uh, ~~we sell it at Shop Dev Tools fm. Uh, one of the features of TypeScript that I've come to love that a lot of people hate is like. It's a powerful type system, but you can ~~like ~~throw it out.but, uh,
So I guess in a sense that I love the un soundness ~~in some, ~~in some places where I can ~~like ~~be the arbiter of my own destiny, even if the types don't quite work out. ~~Uh, ~~what does a sound type system mean in practice?
Gabriel: So in practice, a sound type system means that if it compiles, it works like the, if,~~ um,~~ this is true for the internal things,~~ like,~~ so ~~like ~~if you compile a program. ~~Uh, ~~the compiler guarantees that the code you've written works in the way you've written it, the way it's ~~like ~~outlined, so to speak. Then of course, you have the edges, so to speak, like values that come in from the outside.
You have to type them. The right way or handle them the right way. 'cause those are, yeah, things can slip in. But,~~ um,~~ if you have a program that's written only in risk script, for instance, and it compiles, it works according to what you've written, so to speak. That's the,~~ uh,~~ the g the, the, a sound type system.the guarantee of, uh,
~~Um, ~~and again, like it's interesting that you with ness, um. I think we, we probably think more, more alike than you would imagine. Even though ~~I, ~~I go for the like, sound type system stuff. ~~Uh, ~~I'm not really, I am, I find type systems fascinating and fun, but I'm only interested in what it gives me in practice and what a sound type system gives me in practice is that I can trust that the things I write, the things I ship.And, um,
Will work according to the way I've written them. I can do refactors easily, but all like, this hasn't broken anything anywhere.the biggest thing for me is if I do a quick change in a massive application, it compiles. I trust that this is gonna work. I trust that this is, hasn't accidentally broken things. Outside of like behavioral, of course stuff, but, uh,
And I can also trust that the compiler's gonna guide me to handle all of the cases I need to handle. So, everything is exhaustively shipped for you,~~ uh,~~ by default, which means that the compiler will make sure that you handle all of the cases. That you are supposed to handle for this to work in all of the branches you have, essentially.for instance, in ReSCript, um,
~~So, um, ~~if you have anum for instance, and ~~you, ~~you wanna do something with thatum, risk Script will make sure that you handle all of the possible cases of Thatum. Unless you explicit ~~tell it, ~~tell it explicitly, tell it that you're not going to essentially, and there's a massive productivity gain for me from that.
So looking back, I think ~~like ~~what you described, you can just opt out whenever you want ~~to ~~to get the productivity gains. I feel the exact same way, just that I do it through the I, I get my productivity gains in another kind of area, so to speak. ~~Um. ~~But ~~then, ~~then there's a whole category ~~of ~~of program languages and, and, that it's sound for the sake of being sound.and programmers that care deeply about, uh,
And I'm not one of those in that sense. ~~Like ~~that's not really what interests me. That's cool if that's the case, but I'm interested in ~~the, ~~the productivity ~~it, ~~it gives me and the guarantees it gives me.
Justin: Let's take a step back real quick.
[00:11:09] Rescript vs TypeScript: Key Differences
Justin: Talk about,~~ uh,~~ rescript more generally. So rescript is a programming language that compiles the JavaScript and it has a sound type system. Uh, what else would you say about it?
Gabriel: Uh, it's a programming language that's focused,~~ uh,~~ I would say it's focused on the web. ~~Um, ~~it's focused on, so Rescript is, uh,uh. the language itself.Simplicity and speed. Like speed is a core feature. It's something we care deeply about, that we have a fast compiler, that we have a fast feedback loop in the editor, that we have a fast feedback loop wherever there's an interaction with, uh,
~~Uh, ~~we care deeply about simplicity. ~~Um, ~~the way I usually describe it is if you wanna ~~like, ~~contrast it ~~to, ~~to TypeScript. TypeScript, ~~um. ~~Wants to type the JavaScript you've already written or the JavaScript that you write, you're writing JavaScript and ~~it, ~~it wants to type essentially everything in JavaScript, right?
~~Uh, ~~and it does it really well. So ~~like, ~~type script is. Fantastic at what it does. It's a, an amazing type system, an amazing like feat of engineering overall. ~~Um, it tries to type, uh, all of, ~~all of JavaScript and all of JavaScript has grown over the years to be a pretty massive shed of tools. ~~Right. Um, ~~can't really clean it up too much because you'd break a lot of the web.
Which is you don't want to, right? You can evolve the language. Uh, but evolution is ~~kind of ~~slow and still, like there's a massive amount of features. There's a massive amount of ways of doing things. So imagine there's a shed of ~~many, ~~many tools. Some of those tools are really sharp, are really good, really well thought through a lot of the, those tools are.TC 39 is evolving the language, uh,
Not that sharp doesn't fit that well together, or there's four or five different tools that do the same thing from different generations in a tool, like in a product line and so on. Um, ReScripts philosophy and idea is that if you open the Rescript tool, shed. You'll try and like ~~where, ~~where's all the stuff?
Like you look around ~~and, and, ~~and try and find all of the tools. But ~~the, ~~the point is to have, we want to have few tools but that are really sharp and work very well together essentially. So the philosophy is kind of we want to things to be simple, like to stay ~~simple, ~~simple data structures, simple types.that with a few very sharp tools you can get really far. And, um,
Not too much magic, essentially because we believe that makes things more maintainable, more approachable. Yeah. And all of those things, it's ~~uh, ~~it's that philosophy essentially.
Andrew: Um, so I was reading, oh, go ahead.
Justin: go ahead. No, take it.
Andrew: Okay. Uh, one of so I was reading through the docs and, uh,like as you said, TypeScript, Ty tries to type the entire Java script like API, which is the differences with TypeScript that it lists is that, uh,kind of just even the way they're able to like.crazy. There's lots of stuff that can happen, uh,
Know that code paths have certain values available and types have happened. Crazy stuff is happening there. Uh, you guys say that you only do a subset of JavaScript. ~~Uh, ~~so in practice, ~~like ~~what does that mean? ~~Like, ~~what don't I have available to me? ~~Like ~~what programming constructs do I go to instead of other ones?on, but on the homepage, you,
Gabriel: pl there's plenty of stuff you don't have available to,~~ uh,~~ so to speak. So, classes is ~~the, ~~the main thing maybe in, in rescript, like you can get a dev development workflow. ~~Um. ~~That's very similar to the ergonomics of classes and methods and those things, but you don't have actual classes in the language, you don't have in inheritance.so one, uh,
Those things is functional in that sense. Like we encourage you to,~~ um,~~ write functions that operate on data and that you can change together and those things. So ~~like, um. That's, ~~that's one example. ~~Uh, ~~there's plenty of others. ~~Uh, ~~like the, again, like the JavaScript API ~~is ~~is massive. We don't have generators, for instance, generator functions, although we're ~~kind of ~~interested ~~in, ~~in getting them.
But essentially ~~when, ~~when we look at ~~what, ~~what things to bring in to rescript from JavaScript, we want them to work well with what. We already have. So the core kind of features of the language, for instance, variants, records matching those things we want them to like, should work really well with them.
It should also add something because ~~we, ~~we view all of the, like adding something to the language is a huge cost in that you're giving people another tool that they. May or may not use, but it can create confusion around should I use this for this or that for that, and so on. So we want it to be as simple as possible.
So the bar for adding new stuff is kind of for how to do asynchronous and concurrency in those things.high, but we also wanna stay close to uh,what, JavaScript developers typically want to use. what, uh,Um, ways of doing this than the native JavaScript way. so one example is asynchronous programming. We. Could have probably come up with a bunch of other, uh,Uh, mother language OCaml, but also in, in other languages,there's tons of priority in both our kind of, uh,
But we opt to. Build Asin Kuwait into the language, just like it works in JavaScript just because it's familiar. It's something that's virtually everywhere in the JavaScript ecosystem. And it has some kind of interesting, it gets some, more ergonomic, I would say, if I dare, than in, in JavaScript than, and TypeScript, so to speak.some interesting traits in Cript that makes it, um,
~~Um, ~~which are kinda interesting. ~~It's a, it's a, ~~it's a, so to speak. a good example of when. Bringing something in and making it work well with uh,the, effect,the existing language yields a good kind of synergy, uh,So, done a React component and.so for uh,like, if you've ever,for async weight, the specifically it's in rescript. Everything is an expression, which means that, um,
Your two layers of divs in, and you wanna write an if and you can't because it's not, you can't write expressions in the middle of jsx. Uh, make it a function computed before or, yeah. Everyone you have to write the ary or some other, um,has, in cript everything is an expression. You can put an if or whatever you want, a block of code wherever you want, essentially.has felt this, uh,
And what's, just from the get go. But what's great about this is that it allows you to co-locate your logic where it's supposed to be. So if you're forced to break something out to a function when it doesn't, it's only really for this place you have, you're forced to do an immediately invoked function or a nested turnery of five levels or whatever.what's great about this, it sounds, doesn't sound. Much, um,
Like of the programming language, not because that's what you want to do. And expressions everywhere is a,~~ um,~~ a very nice thing that lets you put code where it belongs. And for async weight. in risk of ~~the, if you're forced to do those things, you're doing them because of a. Limitation in quotes, um,the big thing is a switch, essentially, like, it, ~~it lets you pattern match on anything.
Uh, so you can switch a weight and something happens, and then you can pattern match on that promise, throwing or failing, rejecting. On it succeeding. So you can get ~~kind of ~~this nicely boxed in error handling. That's very succinct. so it's like the switch in JavaScript but on steroids is usually what we say. So you have a switch and then you can switch on virtually any data structure and the compiler will make sure that you handle all of the possible cases for this data structure. And you can also switch on an a weight, uh,It's, it's literally one extra line and it compiles to the regular, it's, uh,you know, and then have your, define your variable above in the scope and assign it or use of r if you're that kind of person.the try catch, uh,
Uh, yeah,~~ you,~~ you have your try catch and find on those things, but. ~~Uh, ~~you, it lets you integrate this right into the code where it matters, so to speak. So you're not, you don't have to do this ceremony of writing a tri catch, even though that's not really what you were after, so to speak. So that's ~~a, a, ~~a good example of when a feature from JavaScript blends very well into ~~the, the, ~~the core features of the language.and then, uh,
~~Uh, ~~and that's the kind of things we try and find. ~~Like, ~~so ~~when we, ~~when we bring in new stuff, which like, again, like. There's the high bar, but of course we want to, we want people to be as productive as they can be with JavaScript through Rescript. ~~Uh, ~~so we wanna bring in stuff from JavaScript as well. Um, it's important that it works really well with the rest of the language.but there's a high bar, but when we do it, it's,
Justin: Yeah. The, the Await, the switch weight thing is really nice because I think one of the problems I have with Asing a weight is. Many people just don't do air handling. It's just like they only code for the happy path. ~~Uh, ~~because it's like ~~kind of ~~annoying a little bit and you see like a lot of libraries that come out that there's, two pull essentially like.there's one that I'd used for a long time that you essentially like wrap whatever, you're gonna await and await that thing and then it'll like return, uh,
Array with like two items. One could be the success case and one could be their case, and then that like messes up the like type inference and a bunch of other stuff. So it's like, I don't know,~~ it's,~~ it's nice and. I, I would go further to say there's like so many niceties just because it's like a functional language.
You had mentioned pattern matching earlier, like proper pattern matching. So good. I use ts pattern a lot in TypeScript projects, ~~but you know, ~~it's unfortunate ~~that that's runtime. uh, kind of like ~~Rust has, it's like that's missing from TypeScript, JavaScript world.Uh, proper like variant enums,cost that you have to pay. And then, uh,
~~The, ~~the pipe operator, which we've been talking about in JavaScript for a long time, but like can't collectively agree on like how we want it to work. Uh,
Gabriel: It's, um, yeah, like pattern matching is probably the, go into rescript and then go back out of it, what that they miss the most just because it's,~~ uh,~~ it solves so many problems and quite elegantly as well. ~~Like, the thing that when people, uh,and it's again, like, uh, ~~you can emulate this well in TypeScript, I would say, like this pattern for instance.
Very cool. There's a bunch of other Panama libraries, but it's runtime. It's not first class in the language. ~~Um. Um, ~~in rescript, it compiles to really efficient JavaScript as well. ~~Uh, ~~it compiles to what you'd wr write by hand if you had to optimize it, which is a bunch of ifs, essentially, but you don't wanna look at that.
You wanna look at the nice, thing about,~~ um,~~ switch weight on those things. the nice switch instead. um,Um, one, one,but's, uh,Uh, really good thing with having a sound type system is that you can do. Very much with statical analysis or static analysis,~~ um,~~ around your program. So one example is we have a tool called Reanalyze in Rescript that can go through your entire program and figure out exactly, for instance, say you have a variant case or you have ~~a ~~a record, it can figure out that this record field is never read.one other, um,
It's constructed, but you never read it. For instance, it can figure out that it's never read nor,~~ uh,~~ written to or created. Um. async Await and error handling, it can also actually figure out that here's a promise that could reject, but we haven't handled the rejection, the possible rejection.And going back to, uh,
So it can kind of it's something I use all the time ~~and, ~~and one of the things I perhaps miss. Miss. One of the things I miss the most, I would say when I do TypeScript stuff, because I still do a lot of TypeScript stuff.do that type of linting for you. And it's a whole program thing and it's also very fast. So it's, um,
Um, um, being able to. reanalyze and have it analyze the code base and tell me what things are dead code. So like across the entire program, what things am I not using and down to the field level. and, um,Um, for me, who do a lot of work in big code bases,~~ uh,~~ of various,~~ um,~~ kinds, being able to.that is, uh,
Reliably clean up old code is, that should be removed essentially.is actually one of the biggest wins for me with the sound type system. um,Um, old experiments, things lie around. New person comes in, they browse the code base, they're supposed to find information about something. AI nowadays also, like the agent browses their code base, tries to figure out information, goes through a bunch of code that's really dead or old or in another convention or yeah, whatever,just because otherwise, you know how it's like, uh,
Outside of the obvious like gains of compilation speed and bundle size and all those things. So that's,~~ um,~~ that's something I really, that's a benefit of the soundness that you can do that with the type system.
[00:22:56] Interoperability with JavaScript and TypeScript
Justin: Speaking of soundness, you, you mentioned, ~~um. ~~You mentioned like there are types on the edge of the system that you have to ~~like ~~define to ~~sort of like, ~~and that's ~~your, ~~your like barrier of selling this, right? Like things outside of the rescript code or, and sound and type script has this same problem, right?
They have to. Define type definitions for everything. And like famously TypeScript has now, at this point in 2025, just a ton of type definitions for everything. Just about, you know, has a ton of types in it, but there are, like most libraries these days, it seems like they ship their own TypeScript types.definitely typed is, uh,
So when you think about ~~like. ~~Rescripts interrupt with the rest of the JavaScript ecosystem or like defining types for outside things. It's like ~~what is the, ~~what is the story around that?
Gabriel: ~~So, um, ~~I would say ~~this is, ~~this is definitely one of the, and so on.the points of the language where we have. A lot more work to do, or rather in the ecosystem, I would say. um,So, uh, you write bindings, which essentially are ways of describing that. If you call this function in JavaScript, you're supposed to expect these parameters, it returns this thing,in rescript interrupting with JavaScript or TypeScript, um,
It's a description ~~of, of, ~~of what outside world looks like. ~~Um, ~~and then, ~~um. ~~You get access to those functions in rescript and they admit the JavaScript is just what you'd expect, like the calls ~~for, ~~for JavaScript. ~~The ~~the big issues that we have around this is that. While Cript and, in TypeScript ~~and, ~~and JavaScript that you don't do in rescript or can't do in rescript, so to speak.and JavaScript has a lot of similarities, there are also a bunch of things that you do in rescript, uh,
Overloads is an example. Rescript doesn't have a concept of overloads,~~ um,~~ which is something I've really come to kind of, um, code,~~ with,~~ with overloads in rescript without breaking out each overload to its own kind of function binding.appreciate in the sense that it's very clear like exactly what things can do. uh,Um, you can't one-to-one express. A type script with,but it also means that, uh,
Um, come to always is can't you? Build a tool that automatically generates rescript from TypeScript. so there are like differences in, in the type systems that uh,make, because what people come,make, uh,Uh, but the results were never really satisfactory because of both the fact that ~~it's, ~~it's quite different.and back before all of the TypeScript research, the, this was something that people were exploring, uh,
Type systems. ~~Um, ~~but also that writing the bindings ~~is, ~~is ~~kind of ~~an art, so to speak.
[00:25:21] The Art of Writing Bindings in Rescript
Gabriel: Like you usually, when you,~~ uh,~~ when you use,~~ um,~~ a library,~~ uh, you're, ~~you're very seldom using all of it. So. and you wanna use it in your specific way. And there's a bunch of ways to write bindings ~~in, ~~in rescript that lets you ~~kind of ~~tailor the a PIA bit in how it looks.Most often you're using a small part of it, um,
So like you can have, you can inject default values for arguments, for instance. So one, one classical example is the read file in KPI of or read file for that matter. Doesn't have to be the sync version, but that takes,~~ um,~~ a iPath and then,~~ um,~~ you can pass the string of the encoding, right? ~~Uh, ~~then coatings in most cases is going to be U TF eight.of node, um,
Uh, parameter. So you never so you can create a binding in rescript that has a default value of UT F eight string for the options, uh,have it's not a,~~ um,~~ a wrapping on top of have to write UTF eight in rescript, but the emitted JavaScript. Always has UTF eight, but it's not wrapped in another function. So it's not an actual, um,the, it's built into the binding itself.the node API, it's,
So that's, so like writing bindings is kind of so to speak. But then we have also going the other way. Going from using rescript code from TypeScript. And luckily there we have a bunch of nice stuff in Cript. an arch, uh,Uh, which can you just annotate your types and,~~ um,~~ rescript functions and values.we have a tool called Gen Type, uh,
And then a TypeScript file for each RESCRIPT module gets generated with all of the types. In TypeScript, but translated from rescript so you can easily use them. ~~Um, ~~but this like ~~the, ~~the binding space is, is, is of course a, a big problem. It's, and stems mostly from, I would say, from us being a small community.is, uh,
So definitely type nowadays it has everything and then some. But back in the day when TypeScript was. Fighting it out with flow essentially. It also had a bunch of things, but most were ubs, right? The same with flow, flow type then and all those things. So we're kind of if I'll say when we grow,~~ uh,~~ when we grow,~~ uh,~~ a lot, there's gonna be quality bindings.at that stage now where, um,
But it's also ~~a, a, ~~a thing where I think people overestimate how much they. Use libraries and how much time they would spend writing the bindings for those libraries. But it's a thing ~~where, ~~where it's ~~um, ~~it's hard to say anything else than ~~this is a, ~~this is a problem. Essentially AI is gonna help some, like teaching the AI to write good bindings helps.
We're also experimenting with,~~ um,~~ so like rescript can emit TypeScript as an inter layer. So you can call rescript code type safely from TypeScript. But we're also experimenting with, okay, so can we have. Rescript, a compiler or gen type,~~ uh,~~ the tool. Can we have that emit a file that just checks that the bindings you've written would work with the TypeScript types of that library, so to speak.
So ~~like ~~if I have this binding for, um. so to speak? So we're doing a bunch of exploration around how we can improve the situation because ~~it is, it is a, ~~it is a problem.Yeah, we'll say React for instance, for use Memo or whatever, if the, is this function signature of the binding I've written, is that compatible with the use memo from the React Types package, um,
~~Um, ~~if you're in the blessed path. Like you, you come in and ~~you, ~~you work with React, for instance, where we have great bindings and a bunch of other libraries where we have great bindings then. You are pretty much set. Like ~~it's, ~~it's going to be fine, but if you need to wander off yourself into writing bindings it, it can be ~~kind of ~~daunting.
[00:28:37] Tools and Integration with JavaScript Ecosystem
Andrew: So code is just the tip of the iceberg when it comes to the JavaScript world. Uh, boil the ocean view of it and ~~kind of like ~~do it all for you?for better or worse, we have lots and lots of tooling. We have linting testing tools, bundling tools, build tools, all different types of tools. What's the story for rescript integrating with those? Does it like, take, uh,
Or is it interoperable with ~~like ~~the common tools we use today?
Gabriel: Yeah. So, um, the JavaScript ecosystem for packaging, for instance, you use the b like the same vendors that one of the goals of cript is to integrate as cleanly as possible into the JavaScript world. um,Uh, but you use a,so this means, for instance, you use. PM or pmpm or whatever you want to use, uh,what that looks.what Cript does is for each CRIPT file, it'll emit a JavaScript file, uh,
As handwritten as we can make it look essentially like it, it's supposed to look roughly as what you'd write by hand,~~ uh,~~ in JavaScript. ~~So, uh, our goal is to integrate like thinly into all of those things. Your bundlers linting, of course, is, is, ~~is a thing where it makes more sense to ~~kind of ~~do it in, rescript itself to LinkedIn Rescript.in, um,
We also, like LinkedIn is another topic,~~ uh,~~ but basically ~~like, um, ~~we don't have that many linters because we have such a tight. Type system. We have a couple of like com compiler warnings and stuff, so we haven't really seen ~~the ~~the need for that, but you could link the, and I know people do ~~like, ~~you could link the JavaScript output people use the React hook links.
For instance, we did a bunch of work in, we have a version 12 that's coming up here soon. We have done a bunch of work for making sure that the rescript output can work with a React compiler, for instance, efficiently. ~~Uh, ~~all of those things that comes with tr ~~uh, ~~having a goal of interrupting as clean as possible ~~with, ~~with JavaScript.
Andrew: Yeah, that I, I, I was gonna ask that when we got to the React section, if it integrated with like, kind of the bleeding edge tooling of the React ecosystem,~~ that's,~~ that's super cool that you can run stuff on the output. And like it's good enough output that you can like translate that back to ~~the, ~~the rescript code.
Gabriel: Yeah.
Andrew: Justin, you wanna.
Justin: Typically ~~this is, this is a, ~~this is a bit of an aside, but do you typically like check in the JavaScript code?
Gabriel: Uh, I, it's ~~kind of a, ~~a problem. Like we, we usually recommend you to check it in. I find it a bit noisy. ~~Uh, ~~but I've I don't actually, but I've, that's, it's, uh,been, how do we make sure we don't. accidental behavioral changes.been working actually quite recently on, okay, so if we don't check in our code, how,
'cause imagine like, I can trust it. ~~Right? ~~So that's good. But there's another layer in risk script, which is to emit the JavaScript. So what if there are changes in. They made the JavaScript that I wasn't anticipating now, like the com the compiler is very well tested and everything, so ~~I mean, it's, ~~it's not, you can trust output, but still, like when you do refactor, when you do bindings, when you do upgrade versions of the compiler or other versions of libraries, and it came ~~kind of ~~nice ~~to, ~~to just scroll through the actual like JavaScript changes also, like when you do a refactor that's purely on the type level ~~or, ~~or something like that, you restructure things work.go back to this thing with, oh, we have a sound type system. I make changes, it compiles, um,
It's ~~kind of ~~nice to. ~~When, ~~when it compiles and you also see that there are no changes in the actual JavaScript, then it's gonna work, right? It's not gonna be any behavioral changes because ~~the, ~~the generated JavaScript is the only thing that matters to the ~~end, ~~end user because that's what, what gets run.
~~So, um, well ~~I've been exploring building a, A-H-T-M-L diff page. You can scroll through for that. ~~Um. ~~It's also interesting to do that type of diffing of the code you've made purely at the type level. So we could have a, that's for ~~like, ~~for generated JavaScript, you diff the generated JavaScript for the type level.a sort of a diff tool for that. So you could have a CI action that always gives you a, um,
You could have a diff that just shows how the type signatures or the type output of all files have changed, so to speak, so that you haven't also accidentally made any changes,~~ uh,~~ that you, a goal is also that all of these things should be easy to. Plug in an AI that can do, for instance, so an AI could audit your generated JS changes or your type changes or whatever.you weren't anticipating. And for us, uh,
Like ~~it's, ~~it's always in the, ~~kind of, ~~nowadays, it's always ~~in the, ~~in ~~the, ~~the back of the head that it's supposed to work well with that as well.
Justin: Makes a lot of sense. ~~Uh, ~~yeah.
[00:32:43] Rescript's First-Class Support for React and JSX
Justin: So let's all, let's ~~kind of ~~switch gears and talk about React a little bit. ~~Um, ~~so re Skip has first class support for React. And I guess when we talk about React, we also like react and ~~like, ~~what does GSX look like inside of Free Script?have to talk about JSX, which is like a language feature as much as anything else. So how do you handle, uh,
Gabriel: ~~So, um, ~~JSX, we will start on that end. Uh, integrated into the actual parser. There's, it's an actual, ~~like ~~JSX nodes are actual a ST nodes in the compiler. JSX is a first class feature of the language, which means that it's, uh,Um, especially historically, have put all of our efforts, so to speak.and so it's a first class kind of thing. um,Uh, then we have React of course, which is where we've put,everything works. With JSX, uh,
We're very much trying to make one use case work really well, and then we try and move on to the next thing. And React has been, of course, with React popularity and,~~ uh,~~ the roots of the project React has been huge. ~~Uh, ~~so I would say we have, um. it's something we care a lot about.Very good React, support, uh,
It's an officially maintained, a package maintained officially by us,~~ the, the, the core team. um,~~ rescript. So we've been eyeing solid js, for instance,~~ uh,~~ Preact, but that's ~~kind of ~~cheating because ~~it's, ~~it's still ~~kind of ~~react.Um, Trying to make other frameworks that work differently, work well as well inside of,but we've recently also started working a lot on, um,
Um, based on bond that's purely server side, but that has,~~ like,~~ you write components, just like you'd write ~~your, ~~your regular app.but also other use cases because JS Jsx is um,kind of and especially when you have all of these. Nice features around pattern matching cool, uh,and, and those things. You can do a lot of cool things. So I, for instance, I've built a framework that's,and, uh,
Uh, jsx components,~~ uh,~~ you render them, you have context. You just don't have the client side stuff. You don't have use states and everything. And what,~~ uh,~~ that JSX. Looks and works exactly like the JSX, you'd write in rescript for React, but in the end it gets compiled and down to calls to a framework called Hyper Ons, which is a there you write, uh,small, produces HTML ~~from from, ~~from jsx.small framework that just emits, uh,
~~Um, ~~so given that it's first class and you nowadays can switch out, react from ~~to, ~~to your own thing or another library, ~~um. ~~It opens up ~~some, ~~some pretty interesting use cases, I would say. ~~Um, ~~but yeah, historically react has been ~~the, ~~the main focus. ~~Um, ~~and there are a few things in. ~~Like ~~React lends itself really well to a language like Cript because of a couple of things.
First, of course,~~ the,~~ the thing I talked about before, expressions everywhere, switches and stuff. But also something as simple as prop drilling. That's not really an issue in Cript because you have the inference. So you never have to, unless you want to, you never have to annotate the prop. You can al always like, that makes you ~~kind of ~~skip doing a few things because it's annoying to have to type it all of let the inference deal with all the problems, and that's a huge. For me at least, been historically a huge source of friction. Otherwise, that,the way, essentially. ~~So, uh, ~~I would say that's one of the the way through, uh,big, of a language like Cript big kind of benefits of, um,and, jsx and react together.and, uh,
Andrew: It is, it's interesting how when you make JSXA language FE feature and kind of factor it out of React, like the way I think about React and what it is and what it's doing in my application, like almost completely changes. ~~Uh, ~~and it's really cool that you can use that for other things just like you basically created your own little.
Framework,~~ uh,~~ with not too many bells and whistles.
Gabriel: yeah. And JSX can be molded to, ~~I mean. ~~Of the web is still like XML based ~~in, ~~in ~~most, ~~most ways. Like, so, um, XML or CV or whatever. ~~Like, uh, ~~it's just function calls at the end of the day, right?you can use it to just like other people do uh,in, but you can use it to emit,in the TypeScript world of course, like,
So it's just a nice format for those function calls and, in a nice way. So it's, and structuring them, um,um. I like, I, of course,~~ like,~~ like I said before,~~ I,~~ I absolutely hated Jsx when I saw it first, but I ~~really, really, ~~really like it now, and I have been liking it ~~since, ~~since a couple of weeks after hating it Yeah, it's, uh,So,
Andrew: Yeah,~~ I,~~ I found that that trend in my life as well, especially like with music, I'll like hear something and have almost a visceral reaction to it, like, that's bad. And then it gets stuck in my head and then lo and behold, that's like one of my favorite artists a year
Gabriel: Yeah. And then the shame, right? Like ~~you have to, ~~you have to admit to No, I, I didn't say I didn't like this. No, no. You,
you mis must have misheard. Yeah.
Andrew: ~~Uh, ~~so react for around 18 versions was kind of react 19, I feel ~~kind of, ~~it threw, it, threw a lot of that out and became very different. You guys list that you support like the normal hooks, but React has a whole bunch of other hooks now. It has concurrent mode. It has a bunch of bells and whistles that it didn't in like most of its history.the same, uh,
~~Uh, ~~does Rescript support those things or plan to support those things?
Gabriel: Yeah, I, um. to work with the compiler. One, one example is that we now have Risk, like direct compiler is one example, of course, where we've actually had to do a lot of work to mold our output to, um,a, JSX preserve mode, which means that, ~~um. The, ~~the la, like the JSX, you write in rescript, you can have rescript emit that as JavaScript as well.a, um,
So there's actual JSX in your JavaScript that gets admitted and ~~that ~~that's needed for ~~the, ~~the React compiler. ~~I mean, there's, ~~there's no, like that I'm aware of, no, nothing in the recent react versions that from a language standpoint cannot be. Supported things we traditionally have issues with, or is things like file-based routing, where in rescript everything is a globally unique module, so all files are.
Share in the same shared global scope. Um, gotta be fair. in addition to binding. This is also one of the things that people think they will hate the most when they come to, to rescript. And some people like, like,Like when they come into actually using it.some people really do hate it, but most people don't like when they, uh,
But that also means that we can't have a hundred different util rest files, which I would say is good, but we also can't have. A hundred different brackets, ID brackets, rest for file system routing. So you have to, when you wanna use that, you have to,~~ um,~~ write your,~~ uh,~~ your route files as JavaScript and then import script into that, which also works fine, but it's more work of course, and a bit of friction.
~~So, ~~but I, I don't think ~~there's, ~~there's nothing I'm aware of ~~in, ~~in React that we couldn't support or don't support.I'll, outside of that, uh,
Justin: ~~So let's see. As. ~~As you think about like you mentioned earlier that there's like a blessed path. There's ~~like ~~some libraries that have really good support or I'm sure there's ~~like ~~some libraries that were just written for rescript itself. the rescript ecosystem, you,Um, what, what does that ecosystem look like?what does that, like,
What are some of the like very well vetted, very well engineered like bindings or libraries that are like pretty common in the rescript ecosystem?
Gabriel: Yeah. ~~Uh, so, uh, ~~of course React is one example. Um, a very cool, ~~um. Uh, ~~schema library in the ecosystem, we have a, uh,kind of like a person in the ecosystem who's if you're a value bot. um,So, uh, by a,which is, uh,very, and very good.very well versed in the schema stuff. And it's really fast, really innovative, uh,
Um, graph crail stuff that works really well just because graph Crail and V script. Nowadays, there's a bunch of other,~~ uh,~~ solutions to end-to-end type safety, of course. But traditionally, graph Cal when it came was overall, we've traditionally had a lot of, uh,gave, a lot of ~~like, ~~possibility of end-to-end ~~type ~~type safety.gave, um,
And that just lends,~~ uh,~~ lends itself quite well to rescript. Graphical is funny because it's, I've been working with it for ages now, and it's still ~~like ~~if you squint a little. GraphQL and Cript is really similar in the concepts they have. Uh, or a limited set ~~of, ~~of what Rescript has essentially, but like unions, enums those things, it's all, it all pretty much looks the same in graph as it does ~~in, ~~in Cript, for instance.graph is like a subset, I would say, or,
Um, and other things,~~ um,~~ as well. And then there's a bunch of,~~ uh,~~ innovative like own rescript stuff around forms so uh,it, it, back and forth. it maps really well, uh,Um, uh. Uh, bun,we have a bunch of other things like the node, node stuff, of course, um,and, so to speak. ~~Um, ~~yeah, so there's a ~~couple of ~~couple of and other things, uh,different too.different things and then there's lots of things in the works, uh,
Um, yeah.
Justin: ~~So, uh, ~~you're working on version 12. ~~Uh, ~~that's in, is it in beta now?
Gabriel: Yeah, it's in beta. It's, now I dare say ~~it's, ~~it's really close. it's, uh,Uh, it's taken a lot of time to get this working really well.but we've been doing a lot of things for version 12, so it's, uh,
[00:40:54] Exciting Features in Rescript Version 12
Justin: What are the big features that are coming out in version 12?
Gabriel: So version 12 has,~~ um, the, the big thing for us that's been around for a while in rescript is that version 12 does all of the, like remaining big cleanups from. Our history, so to speak, in, in molding, rescript into this JavaScript focused, uh,~~ language that we want it to be. Uh, so, uh, around that.there's a bunch of things, uh,
We've replaced the build system completely,~~ um,~~ which yields,~~ uh,~~ some massive speed ups in some cases I've seen. ~~I, ~~I have a couple of projects, for instance, where it's like from a clean slate. ~~Um. ~~And so on. So that's the thing. There's a bunch of other things 60% faster to compile from, um,in, in the language itself.in, um,
~~Uh, ~~much better support for dictionaries. ~~Uh, ~~lots of more like powerful type things in how you can structure your types, how you can, ~~uh. ~~Move between types, how you can share things between types and those things. We have a couple of experimental features that I'm really excited about as well. ~~Um, ~~yeah, so it's, some of the things in it ~~is, it's packed with things essentially, and we're starting to, like,is, um, are, ~~are nice because they kind of fully just in the language itself, right? So give us a receipt that uh,we, and with pattern matching and all of those features, that means that you can write. JSON decoders and encoders,we've been able to, uh,um. so as union, so to speak,To make things work nicely together. uh,Like, you can model JSON as a variant in rescript,just like I talked before, like we want things to work well together. And that's usually quite a big challenge, right? To make things really work well. So one, one example is we've now gotten to a stage where, um,you can, oh, this js, I'm, I expect this to be an object. It's supposed to have a user prop.you can get a, you can have a JS structure that you get from an API, and then you can pattern match your way on, on that to what you expect it to be. So for instance, like,
That's supposed to be another object. It's supposed to have a name prop with, that's a string. It's supposed to have an age prop. That's an. Float or rent or whatever,~~ uh,~~ and so on. So ~~like, that's a, uh, kind of ~~a testament to all of those things working really well together, right? So like ~~the, ~~the features of the language come together in a nice way.
Um, a lot of things around that essentially, and then a bunch of optimizations and yeah, again, like and we 12 has, um,it's, than what we had before.it's packed. So we're looking to, we're really looking forward to getting this out. And for us um,it's, closer to JavaScript,it's uh,kind of, um. like we've cleaned up a lot of things, we've replaced the entire standard library, for instance, to something much more,Now that we've finally done a bunch of, uh,
Um, from. From the old standard library to new standard library, even if the signatures of the functions are wildly different in the old standard library to the new one,~~ uh,~~ and so on.and we worked hard on, on making sure uh,that automatically migrate,that transition is hopefully going to be quite easy. So we built an entire like migration framework where you can, uh,
So we're hoping that from version 12 and on,~~ um, we're, ~~we're going to be able to focus more on just sharpening the language rather ~~than, ~~than get making sure that everything fits well together like we've been doing now.
Andrew: Sorry,
Justin: Andrew, we have a few future facing questions. Maybe we could just like lead into those and wrap up.
Andrew: ~~yeah, let's do that. Um, ~~so we just talked about V 12 a little bit. You got a lot of exciting things coming, like jam packed release For sure.
[00:43:55] Future Vision for Rescript and AI Integration
Andrew: Where do you wanna see rescript go in the next five years? ~~What, what, ~~what's your vision for the ecosystem?
Gabriel: ~~So, um, ~~I would say continue bringing things in from JavaScript and molding it to like the useful things, molding it ~~to, ~~to our, ~~um. To, ~~to work ~~in, ~~in the rescript ecosystem, so to speak. But I'm, general AI stuff. Like how a language like rescript is suited for agent DEC coding, for instance.I'm also quite interested in and excited about, uh,
And that's something where we've actually spent a lot of time now with V 12 for se, for example, something as. Mundane as error messages is hugely important for an agent to be able to recover, right? So you wanna get ~~to a, ~~to a place where you can put an AI agent on your code base and just have it bang its head on the computer until it ~~kind of ~~compiles, right?
~~Um, ~~and in order for it to be able to do that, you have to have error messages to kind of for it. hint on. On what's wrong in a good way and how to fix it. Especially for a language like rescript that's small, where you don't have the benefit of there being massive amounts of training data, uh,Right? Um. coding just because the feedback loop is so fast. It's really simple. ~~Um, ~~if it compiles, it works, all those things. And also that we, the type system is simple in a way that makes it possible for us to. I would say in, in, if not all, then most situations give you an actual good error message.But risk, it lends itself really well to, to ai, uh,
Like we don't now, but we could. ~~Right. ~~So that's the, and we spend a lot of energy in trying to make this really work. 'cause most often when something doesn't compile, you're doing something wrong and we can ~~kind of ~~figure out what you were ~~kind of ~~intending to do and ~~like, ~~here's a. In the best case scenario, we can just say that, oh, this is supposed to be this thing instead.
~~Like, um, ~~but ~~in, ~~in, in the more common case, maybe there's maybe three different routes you could take from here and we could present that to the user or to an agent ~~and, ~~and let them ~~kind of ~~decide on which, I'm working on right now that I'm really excited about.which way to go essentially. So there's a bunch of things, um,
Uh. in the future as well. ~~Um, ~~but we also like, like just finding all of these like patterns that make you. Able to write good apps. So That specific thing, because of course, like AI is going to be big, uh,like errors as values and exhaustive error checking for all the code, like the, like effect for instance has.one thing that's very popular now is, um,
Uh, and result types built into the language of rescript. And there's a concept, I'm not gonna bore you with the details, but there's a concept called polymorphic variants in, in, in rescript, which are essentially structural unions of things. So in rescript you can write functions that return results. You can mix them freely between async and not async because you have async Kuwait and all of these functions, as you call them throughout ~~your, ~~your application, the type system can track all of the possible errors that can be produced by those result types and then force you ~~to ~~to handle these whenever you call.and that's the thing that's actually first class in the language of rescript. uh,So. we have options,And you can do it all. Also very driven by inference. uh,So, uh, the result type,we have, uh,
Function, like a great pattern that's thankfully getting popular now as well. Uh, right. but the cool part about it is that it's all native and built into the language itself. ~~Um, ~~and it's all inferred. So you don't have to write any annotations, you don't have to pre declare. You can go into function.So it's, um,
Two of the 10 functions you call in your decode function and have that produce another error. And then all of the call sites in your code base. That interacts with that is going to be force you to handle that automatically, so to speak. So there's a bunch of those things as well. ~~That's, ~~that's interesting to see how we can ~~kind of ~~Yeah.
Get closer to and make easier.
Andrew: Yeah, errors is value. Seems like a super useful feature. Uh, we've talked about it a lot on this podcast. ~~Um, ~~
[00:47:33] Conclusion and Final Thoughts
Andrew: well, thanks for coming on. Uh, Justin has to give up his room. ~~Uh, ~~well, thanks for coming on. We covered a whole lot of ground here about rescript. It's a very interesting language and I might give it a try.
Uh, I, I particularly, we didn't talk about it, but your rescript relay package looks like phenomenal. Like, just like there's barely any Read me there. The API is so nice. So thanks for coming on and ta telling us all about rescript.
Gabriel: Thank you very much for having me. Very enjoyable. Thank you.
Did you enjoy this article?
Recommend it — Standard Reader surfaces well-loved writing to more readers across the network.