Braden Wong

Reimplementing JavaScript Means Reimplementing the Mistakes

You get to start from scratch, then have to make sure all the weird behavior still works.

I have so much respect for anybody building a new JavaScript engine. You have the opportunity to start completely from scratch. You could look at all the weird things JavaScript does and say, okay, let’s not do that again.

But if you want existing JavaScript to actually run, you have to do random shit like make sure typeof null returns "object". You have to implement the double-equals operator, with all its type coercion.

You can’t just decide, oh, we’re not supporting that. If you leave out double equals, you’re going to break a shit ton of libraries. You have to make sure your implementation passes the tests for the expected behavior, even when the expected behavior is the thing you wish you could get rid of.

And that just feels so sad. You have the opportunity to start from scratch and avoid all the mistakes, but instead you have to reimplement them again.