It kind of only exists for legacy reasons, and, if they could delete it, they totally would, but, you know, history.
Again, you choose. Then, next up, you type git init, and you're kind of a bit lost where to even start. You might look at it using the script life cycle, so, like, first you pass the script. Obviously, you need to start with the parser, and then you need something that runs your script, and then you build the run time at the end. That's not really true.
You can basically start anywhere. Thanks to a lot of JS tooling, like formatters and linters, we have standalone parser libraries that you can just take, and then you get a quick start, or you just write your AST from hand in the beginning. That's something we did in the engine I worked on. And then later on, you can add the parser, and you already have something after that implemented, and it all fits together nicely. On the run-time side, again, that is huge, at least if you choose to implement all of it, so just pick whatever you want. It could be the classic string number, boolean prototype, or something more exciting like type arrays, or proxies, just start wherever you want. That is fine.
Then, obviously, you need to have a specification, known as ECMA 262. It's very complete, which is great. Nowadays, not a lot is unspecified. It largely looks like this, so you get a pseudo code that you can roughly translate into your own code. That might not seem like a whole lot of fun, but you still get to do a bunch of custom stuff like optimizations. This is really just focusing on the correctness and behavior. Then you need some tests, obviously. After you've implemented some stuff, you need to make sure it works correctly, handles all the edge cases.
Great news, you get 50,000 tests for free which are maintained next to the specification, so it's an actual official thing. It's a requirement nowadays for everything that goes into the language that it has new tests added to the test suite. Many new features are known to be fully tested. There's this wonderful website called test262.fyi that tracks the results of all the engines out there, and updates them every day, so you can see very detailed which engine implements which thing how well. I find personally that having a graph that shows you it goes up over time is very good for motivation.
More generally, you can obviously learn a huge amount of stuff if you do this. Things about how parsers work, interpreters, if you do bytecode engine code generation, if you want to do a JIT even, some native code, certain optimizations. For me, a huge thing was a better understanding of JavaScript itself, so, like, once you implement it, you really, really understand how things work under the hood. A few low-level concepts, and then one of my favorites is you get exposed to standards, so these new features don't appear out of nowhere, and you kind of get to interact with the people who add new things to JavaScript, and you can even get involved. It's all on GitHub.
Now, I do this. I'm a delegate for Bloomberg, but I started out as an invited expert in TC39, just like the standards body, and they reached out one day and thought, like, this is cool what you work on, do you want to get involved? And then lastly, here's a list of a few projects that you should definitely check out if this sounds interesting to you. These all do this for fun, like they don't aim to compete with V8, and all these big engines, they just do it for fun, so there's a few of them. Definitely check that out.
And that is that. If you have any questions, please find me afterwards or online. Thanks.
Comments