Introducing MoonBit and a few reflections from building the ReScript toolchain

Some people here might still remember me from the early days of ReScript. Although I no longer maintain ReScript, the years I spent building its compiler, type system, and toolchain had an enormous impact on how I think about language and tooling design. Over the past three years I’ve been working on a new language called MoonBit, and I thought it might be interesting to share what it is and what I learned from the ReScript experience.

What is MoonBit?

MoonBit is a high level general purpose language like Swift, Golang and Java. It supports multiple backend including native (C,LLVM), Wasm(with/out GC) and JS, the Moonbit toolchain comes with a builtin coding agent(now rewritten in MoonBit itself.

MoonBit is a new statically typed, compiled language designed from the ground up to be AI-native. It aims to sit in a fairly pragmatic space: familiar syntax, predictable semantics, extremely fast compilation, and a standard library shaped around real-world software engineering rather than academic idealism. A large part of the vision is that AI will generate, refactor, and evolve a significant amount of MoonBit code, and the language, tooling, and packaging ecosystem are all designed with that in mind. In other words, instead of assuming a human-first workflow and then bolting AI on top, we try to co-design the whole experience so humans and LLMs can collaborate effectively.

The long-term goal is to build an end-to-end “software factory” where the language, compiler, IDE, package system, testing tools, and AI agents work together. This means making choices that sometimes look conservative but produce a more predictable environment for large-scale AI-assisted development.

Lessons I took from building the ReScript toolchain

Working on ReScript was both rewarding and instructive. A lot of decisions in MoonBit were shaped by that experience.

The first lesson was that the language and the IDE cannot be designed separately. ReScript didn’t have strong IDE support for a long time, partly because certain language features and compilation pipelines made tooling unnecessarily difficult(We inherited a lot from OCaml and don’t have fault tolerant lexer, parser, type checker in the beginning). For MoonBit, the IDE is treated as a first-class consumer from day one. Language services, incremental compilation, symbol queries, and navigation APIs are designed alongside the syntax and type system, not as an afterthought. The latest MoonBit IDE performance is superb that can respond under 100ms generally, we also shipped a web browser based IDE in the beginning(tour.moonbitlang.com)

The second lesson is the importance of controlling your own package ecosystem. With ReScript, depending on npm created both cultural and technical mismatches. MoonBit has its own package registry(mooncakes.io) and package manager from the start, which makes it possible to grow a community slowly, encourage idiomatic libraries, and avoid the dependency sprawl that often appears when a language simply inherits an existing ecosystem wholesale.

A third lesson is to be disciplined with inference. ReScript’s type inference was powerful but sometimes fragile. In MoonBit, top-level annotations are required and the type system avoids local generalization. Having slightly less inference leads to far more predictable code, easier tooling, easier refactoring, and more reliable AI generation.

Another takeaway is the value of giving developers strong support for data processing. ReScript had pattern matching, but in hindsight it could have gone further. MoonBit leans hard into this area with more ergonomic match constructs, better destructuring, and small pieces of syntactic sugar that make everyday code easier to read and generate. For example, we have native support for JSON, String and Bytes processing using pattern match, and pattern match over array is just as easy as List in ReScript.

Finally, there is the question of being “AI friendly”. It’s not obvious how to define this in theory. Instead of guessing, we take a more empirical approach: every new feature, syntax form, or sugar is evaluated by actually running LLM-based generation and seeing what produces more correct, idiomatic, consistent output. The language is co-designed with the tooling and with LLMs themselves. This matters in practice more than one might expect; tiny syntactic details can dramatically change the quality of generated code.


These are just a few reflections from someone who spent years building one toolchain and is now building another with the benefit of hindsight. MoonBit is not meant to replace ReScript or compete with it. They grew out of different goals and different eras. But many of the ideas in MoonBit trace directly back to the lessons I learned while building ReScript, and for that I remain genuinely grateful to the community that formed around it.

Happy to answer any questions or go deeper on any part if people find it interesting.

9 Likes

Welcome back, Bob!

Happy to see the lessons learned from ReScript are heavily applied to MoonBit. I was a little sad to see that it requires parameter annotations but I guess you can move faster with tooling support that way.

But you are moving crazy fast. How many people are on your team (paid?).

Concerning the package manager I am not sure. It’s nice to have big JS libs available. Probably just a wrapper or yarn/bun plugin could be enough for that (and also for managing bindings). Being similar to TypeScript is mostly good for the positioning of the language.

For a new language that compiles to native code I agree, you cannot do without a package manager. Great to see the vertical integration philosophy got brought to the next level!

Hello,

Thanks for sharing this insight. It just crazy how high the bar is these days to make a new programming language. You are dead right that IDE support and AI friendliness are things you cannot ignore when building the language.

It is is impressive to see how many backends you target. Did that not come with a ton of complexity to deal with?

How would MoonBit look like if I want to try writing some React component?
Does it have JSX? How do promises look like? I’m asking because these are so specific to JS and have no relevance for the other targets. How do you deal with this?

I’m also somewhat curious about the economics around making this. You must have been funded somehow I suppose. Will you need to come up with some way to make money off of this in order to ensure its future? I understand if this is a bit of a sensitive question to answer in public.

Great stuff!

2 Likes

Thank you!

I was a little sad to see that it requires parameter annotations but I guess you can move faster with tooling support that way.

It is only required for toplevel functions, for local functions, we can still infer the types.

How many people are on your team (paid?)

We grew from 0 to around 10 full time software engineers in the last 3 years.

Concerning the package manager I am not sure. It’s nice to have big JS libs available.

We need teach AI to use libraries in a uniform way, indexing the libraries ahead of time etc. Indeed, it is hard to resist the temptation to adopt a huge JS ecosystem, but we are betting on the long term, we want to rebuild a whole brand new ecosystem like Java in the era of AI : )

2 Likes

Did that not come with a ton of complexity to deal with?

Indeed, it complicate things a lot. We planned to target JVM as well, but decided to stay focused and not working on it.

How would MoonBit look like if I want to try writing some React component?

That’s not our current focus, but some community members wrote some interesting articles Moonbit で React アプリを書く

Does it have JSX?

No

How do promises look like?

We shipped our own structured concurrency model Announcing MoonBit Beta | MoonBit ,
JS support is coming soon, it supports auto-cancellation and interop with promise will be supported.

Will you need to come up with some way to make money off of this in order to ensure its future? I understand if this is a bit of a sensitive question to answer in public.

We are not interested in monetizing the toolchain itself. Our vision is to make MoonBit platform a software factory, MoonBit + AI will help you deliver software better and faster.

2 Likes

Welcome back, Bob!:clap::clap::clap:
So, if we want to bring the ReScript IDE experience up to the same level as MoonBit’s, what directions should we focus on and what specific work should we do?

I did not work on Rescript for very long time, it would be nice to get some funding to sponsor some expert working on it.