Real-world ReScript vs TypeScript build performance: Complete dinero.js core rewrite

ReScript vs TypeScript Build Performance: A Real-World Benchmark

I rewrote dinero.js’ core package in ReScript to benchmark build times against TypeScript. Here are the results:

Environment

  • OS: Linux 6.11.0-1018-azure (GitHub Actions)

  • CPU: 4 cores, Memory: 15Gi

  • ReScript: 12.0.1, TypeScript: 5.9.3

  • Node.js: v24.12.0

Results

Clean Builds:

  • ReScript: 0.502s avg (10 trials, 68 modules)

  • TypeScript: 1.273s avg (10 trials, 74 files)

Incremental Builds:

  • ReScript: 0.205s avg (10 trials, 3 modules)

  • TypeScript: 1.236s avg (10 trials)

Performance Summary:

  • Clean Build Winner: ReScript (0.771s faster, 2.5x faster)

  • Incremental Build Winner: ReScript (1.031s faster, 6.0x faster)

  • Incremental Efficiency: ReScript 2.4x faster than its clean builds, TypeScript only 1.0x

Methodology

Project Selection: I chose Dinero.js because its core package has a medium-sized API (74 TypeScript files), making the rewrite manageable while being substantial enough for meaningful benchmarks.

Rewrite Process: The port resulted in 68 ReScript modules mirroring the TypeScript structure. I performed an AI-assisted conversion over several days, leveraging the comprehensive test suite for validation. With minor internal API adjustments, I kept all tests passing except 4.

Testing Strategy: I colocated ReScript output files with source files (avoiding lib/ folder) and retargeted Jest imports from TypeScript to ReScript output (JS files). This approach was both practical and safe given the extensive test coverage.

Version Choices: I upgraded TypeScript from the original 4.8.4 to 5.9.3 to ensure the fairest possible comparison against ReScript 12.0.1.

Conclusion

I think the claims of faster build times, both clean and incremental, are proven to be true for this medium sized real-life codebase.

9 Likes

Code can be found here for anyone interested: GitHub - nathan-tranquilla/rescript-dinero: Benchmark comparison between TypeScript and ReScript implementations of Dinero

2 Likes

Awesome stuff!

May be worth running tsgo too if possible, I’d imagine it is the first thing TS advocates are going to reach for when they get defensive. https://www.npmjs.com/package/@typescript/native-preview it is what TS 7 will be.

3 Likes

Check out the benchmarks here for tsgo. ReScript wins for incremental builds, but TypeScript wins for clean builds.

============================================================
BENCHMARK SUMMARY
============================================================
Clean Builds:
   ReScript:  0.517s avg (10 trials, 68 modules)
   TypeScript: 0.29s avg (10 trials)
Incremental Builds:
   ReScript:  0.212s avg (10 trials, 3 modules)
   TypeScript: 0.284s avg (10 trials)
Incremental Savings vs Clean Builds:
   ReScript:  0.305s (2.4x faster)
   TypeScript: 0.006s (1.0x faster)
Clean Build Winner: TypeScript (0.227s faster, 1.8x faster)
Incremental Build Winner: ReScript (0.072s faster, 1.3x faster)
============================================================
1 Like

I was a bit puzzled by the incremental build time in TypeScript being the same as the clean build. That didn’t make sense to me, so I did check out the repository locally and I verified that the incremental flag is not set anywhere, neither in the command line or in the tsconfig file.

After setting incremental to true in the tsconfig file, then the results do change. This is what I get in my laptop.

============================================================
BENCHMARK SUMMARY
============================================================
Clean Builds:
   ReScript:  0.362s avg (5 trials, 68 modules)
   TypeScript: 0.225s avg (5 trials)
Incremental Builds:
   ReScript:  0.255s avg (5 trials, 3 modules)
   TypeScript: 0.191s avg (5 trials)
Incremental Savings vs Clean Builds:
   ReScript:  0.107s (1.4x faster)
   TypeScript: 0.034s (1.2x faster)
Clean Build Winner: TypeScript (0.137s faster, 1.6x faster)
Incremental Build Winner: TypeScript (0.064s faster, 1.3x faster)
============================================================

Generally speaking, now the TypeScript numbers make a little bit more sense given that the incremental is a bit shorter given we are touching only one file.

Regarding compile time comparisons between the two compilers, this is highly dependent on the code and there is one thing that Rescript will always win on, which is that the type system is simpler and will have more predictable compile times as code size grows.

TypeScript’s type system is so complicated and powerful that you are bound to include libraries that will skyrocket your compile times as the project grows. This is of course a lot harder to prove with benchmarks, especially when doing the project in both rescript and typescript, because they cannot express the same things with the same type safety. They are very different when you go to the advanced parts of them.

My interpretation, these are great results because they are in the same order of magnitude as the new TypeScript compiler which has been engineered from scratch with performance in mind and with lots of lessons learned from all the previous compiler versions.

Hey thanks for the review, and for correcting my oversight! Appreciated!

It sounds like a benchmark for larger codebases for tsgo might be insightful.