r/javascript 10d ago

AskJS [AskJS] Building a SpiderMonkey-based JavaScript runtime to learn JS internals — what APIs are still missing from JS runtimes?

Over the last few months, an experimental JavaScript runtime has been in development, built on top of Mozilla's SpiderMonkey, as a way to dig into how JavaScript engines and runtimes work internally.

One thing that stands out while building it is the separation between the JavaScript engine and the runtime.

JavaScript (more formally, ECMAScript) is just a language specification. Engines like V8, JavaScriptCore, and SpiderMonkey execute JavaScript, but they don't define things like:

  • setTimeout()
  • setInterval()
  • fetch()
  • console
  • Workers
  • File system APIs
  • Process APIs

Those come from the runtime built around the engine.

That raises a question worth putting to the community.

Most modern runtimes are built around APIs that have evolved over many years. Browsers expose Web APIs, while server runtimes expose things like file systems, networking, streams, and processes.

If JavaScript were being designed today, without worrying about backwards compatibility — what APIs should every JavaScript runtime have by default?

For example:

  • Better concurrency primitives?
  • Structured task scheduling?
  • Actor-style APIs?
  • Built-in channels?
  • First-class cancellation?
  • Better binary data APIs?
  • A different file system API?
  • Better networking primitives?
  • New async abstractions?
  • Something completely different?

Are there APIs in use today that feel outdated? Are there APIs that should never have existed? Or APIs from other languages worth having in JavaScript runtimes?

Not necessarily about browser APIs specifically — more about what an ideal JavaScript runtime would look like if designed from scratch today.

Different perspectives are welcome from anyone who's worked with Node.js, Deno, Bun, browsers, or other languages.

The project is open source — link in comments for anyone interested in following along

0 Upvotes

4 comments sorted by

2

u/Deep_Wear_51 8d ago

SpiderMonkey is a solid choice if you need a JS runtime that isn't V8. Mozilla's been maintaining it for decades and it handles embedding well. What's the use case?

1

u/freeguy2101 7d ago

I'm building a JavaScript runtime called Forge using SpiderMonkey. Mostly as a learning project to understand runtime internals from the ground up, but the long-term goal is a standalone runtime with its own event loop, timers, native APIs, and more