0:00
/
0:00
Transcript

ep9 v8: Initial implementation of optional chaining ⛓️‍💥

A quick tour through compiler design to see how v8 implemented optional chaining in Javascript

Modern Javascript has been steadily evolving, and in 2020 we saw the advent of optional chaining - a small but mighty language feature that found lightning quick adoption.

The syntax is simple - const errorMessage = res.body.error?.message

Once a spec for a language feature is agreed upon, how exactly does it get implemented? For NodeJS, Deno, and modern Chrome-powered browsers, we look to Google’s v8 Javascript engine for a ~250 LoC implementation.

This commit is essentially a quick tour through compiler design - v8’s scanners, tokens, parsers, ASTs, and bytecode generation all get small adjustments to make room for Token::QUESTION_PERIOD.

Thanks for reading Commit History! Subscribe for free to receive new posts and support my work.

Links references:

Discussion about this video