ReScript: A Fun Programming Language That Compiles to JavaScript

Louis Petrik
5 min readJul 13, 2024
Source: the author

After all the frameworks and libraries, a new trend appears: People are building entire programming languages that transpile to JavaScript. Some of these programming languages have this as their only purpose. One of these is ReScript.

The languages aims to be an alternative to JavaScript and TypeScript, and can be used to replace both everywhere in the stack.

You wouldn’t stick with me if we were to go over all the features, right? So, let’s focus on what makes ReScript different compared to JavaScript and TypeScript.

Getting started

Creating a new project is easy: npm create rescript-app@latest. As the template, select the “Basic” one to get started.

I recommend opening two terminals. In the first one, we start the ReScript transpiler using npm run res:dev.

In the other terminal, we run the generated JavaScript file with nodemon, so every time we change our ReScript code, the resulting JavaScript code is executed: nodemon src/Demo.res.mjs. Alternatively, you can rerun the generated JS code manually each time using node src/Demo.res.mjs.

Ready to get fully started?

Hello world

--

--