The Rebirth of ReScript

Issue #255.January 18, 2024.2 Minute read.
Bytes

Today’s Issue: CSS paintball lessons, the downsides of visualizing entropy, and the will of our benevolent App Router gods.

Welcome to #255.


Eyeballs logo

The Main Thing

People going on Splash Mountain with horse masks on

On our way to the world of underground type checkers

The Rebirth of ReScript

ReScript just launched v11.0 of its “TypeScript the good parts™️” programming language last week, and the team is calling it a huge milestone that’s packed with meaningful new features.

If you haven’t been initiated into the underground world of non-TypeScript static typing, ReScript grew out of two projects — the OCaml-based ReasonML language created by Jordan Walke (yes, that one) back in 2016, and an OCaml-to-JavaScript compiler called BuckleScript.

Both of these projects shared a lot of the same goals (and the same contributors), so they decided to join forces back in 2020 to fly under a new banner called ReScript — which introduced a more simplified syntax than Reason and a unified compiler and build system.

Today, ReScript’s goal is to give developers “the full power of JavaScript in a robustly typed language, without the fear of any types.” It uses OCaml to do this, but you don’t actually need to know any OCaml to use it 🙏.

Which brings us to the million-dollar question: Why would I ever use this instead of TypeScript?

The biggest difference is that ReScript intentionally covers only “a curated subset” of JavaScript, instead of the entire JS feature set like TypeScript does. It’s kind of like a prix fixe menu at a fancy restaurant vs. the Buc-ee’s gas station approach of providing you with everything you could ever possibly need in one place.

Some of ReScript’s areas of focus include plain data and functions over classes, clean pattern matching over fragile if statements, and proper data modeling over “string abuse.”

This more limited scope obviously comes with some tradeoffs, but it does produce some unique benefits too:

  • Simpler types with less pitfalls and no any, no magic types, and no null/undefined errors

  • A super fast build system for codebases of any size and a compiler that “naturally guides you toward writing code that’s performant by default”

  • Doesn’t need type annotations, because the types are inferred by the language and are always guaranteed to be correct

Because it compiles to JavaScript, ReScript also lets you use any JS library you want and can automatically generate TypeScript types. Last week’s v11.0 release introduced customizable variants, which improves its JS/TS interoperability even more.

Bottom Line: We’ve seen large projects like Svelte and Deno move away from using TypeScript internally for various well-documented reasons. Will ReScript’s less-is-more approach be enticing enough to attract more developers who feel the same way? Stay tuned.

        

Stream logo

Our Friends
(With Benefits)

When I tell my sheep I'm building in-app video from scratch

Stream is the easiest way to build video features

Building in-app video from scratch is like trying to make your own batch of Mtn Dew from scratch — overly complex and completely unnecessary.

That’s because you can just use Stream to quickly build enterprise-ready video features that can instantly scale to millions of users with their global edge network.

Stream’s APIs and JavaScript/React SDKs make it easy to build everything your users want in days, instead of months:

  • Video calling API gives you all the Zoom-like features users expect, with super low latency and advanced security features

  • Livestreaming API lets users broadcast from their phones or RTMP and comes with live chat and flexible moderation tools (see demo)

  • Audio Rooms API gives users a Twitter Spaces-like experience with live audio transcription, audio track redundancy, and more

Try it out for free — and see why companies like Adobe, Soundcloud, and Imgur all use Stream in production.


Cool Bits logo

Cool Bits

  1. Ahmad Shadeed created this interactive guide to Designing better target sizes with CSS.

  2. Graphite.dev is a free, next-gen code review platform built on top of GitHub that gives you pretty much everything GitHub has been promising to build for the last 5 years — stacked PR’s, intelligent notifications, and a helpful CLI that automates squashing and rebasing. Just sign up with your GH account to see how much faster it allows you ship to code. [sponsored]

  3. Matt wrote about 16 Lesser Known Accessibility Issues.

  4. Dep Tree lets you visualize the entropy of a codebase with a 3D force-directed graph. The last time I tried to visualize the entropy of something, I didn’t clean my room for a month, so I’m a little nervous about this one.

  5. Stability AI released a new code completion model that’s 60% smaller than CodeLLaMA, has equivalent performance, and works offline without needing a GPU.

  6. Matthew Kwong wrote about his experience Migrating from Zod to Valibot.

  7. Datadog created this free DevOps Kit with multiple free resources to help you build a data-driven DevOps culture around observability, collaboration, and data sharing. [sponsored]

  8. Lee Robinson wrote about how to fix ten common mistakes with App Router. Mistake #1: not wearing a black turtleneck and thanking the triangle gods for their benevolence before using route handlers for the first time.

  9. Dominik wrote about The Query Options API which features patterns that he’s teaching in our upcoming course, query.gg.

  10. Vladyslav Zubko wrote this Case Study of a migration from TypeScript to JSDoc. We can always make room for you on the Underground Type Checkers Express, Vladyslav. Just say the word.