← Blog

I built a JavaScript engine

Over the course of three months, I built a JavaScript engine; I can say without a doubt those several months were an absolute whirlwind. At the start of the project, it felt as if I were staring up towards the summit of a mountain encased in fog, impenetrably dense, but looming in a way that its shape, in a general sort of way, was visible from my vantage.

I started out with hubris, as I'm sure everyone who attempts such a feat does; with the certain expectation of success, but more so I wanted to learn more about what such a project requires, the most persistent difficulties to be encountered, and what I could stand to gain from it. Few people set out to build a JS engine; fewer still think of such a task in any way other than building a toy to learn from; and fewer who set out to build a real engine ever finish it — much can be said about what finishing a JS engine even means.

But I did it. I built an engine that passes over 99.9% of test262. At the time of this writing, that seems to be rarefied air. Having done a bit of looking, I'm unsure if it has ever been done before.

Test262 is not the measure of a JS engine, but rather a prerequisite to everything a JS engine can do after it is correct. I could go on and on about the minutiae here, but you can find that from better sources elsewhere. And hardly do I think I could contribute much to that conversation, as low-level systems programmers elsewhere could.

Perhaps the only thing of value that I could contribute is a perspective that comes from without of the community that deals in JS engines. And honestly, because I have devoted my personal blog to be first manually written on a pad with pen, I will save myself the hand labor.

Instead, this post is the introduction to a vision for building computational systems from the metaphysics of systems themselves. I have heard of a big push toward "first principles" in the development community. But I've heard strikingly little about what that means when it is said — in fact, when these principles are mentioned and I investigate them further, these principles seem rather downstream.

I don't want to only convey hubris, or be insolently hand wavy to what folks call "first principles", nor come off as someone who thinks little about what he doesn't know. And in fact, the more I read and listen to engineers working in the bowels of low level systems (that must never break), the more I respect their battle-won reasoning and methods.

But I wish to no longer deal with the practical reality of engineering, and instead entertain philosophy. This is the point that matters. I didn't build a JS engine by thinking like an engineer. I did it by thinking as a philosopher.

And this is where "first principles" are meant to be challenged and proved by the fire of metaphysics. So I invite you to reason not as an engineer, but as a metaphysician. Here we will deal with eternal things, because metaphysics cannot be right or wrong as something you can prove. Rather, they are either known or unknown. You can either dance with them, or you can prance about without a partner while you spin out into ethereal space.

I cannot prove to you the metaphysics that affords me deep intuitive understanding of computational systems. Rather, I can only name these dancing partners and then show you the moves you can do with them.

For the time being, this is what this blog will be for.

Also, I want to end this initial post with a huge dose of epistemic humility. When you think you know something, you don't. When you discover something true, you are never the first person to it. When you find a method that works, it doesn't mean it is true. The distance between "craft" and "law of nature" is profound and perhaps incalculable.

With that said, you can explore my JS engine here. It also is a Node-compatible runtime and includes a sound type language, an ORM, and two independent implementations of SQLite and Postgres.

See more at: https://cruft.sh