I've been thinking about the various JavaScript engines out there and how they handle ECMAScript. It seems like most of them don't strictly follow the spec; they just aim to get the job done in their own unique ways. For instance, there's `engine262`, which mirrors the spec closely but is designed to be straightforward and easy to understand. My question is: if someone were to implement ECMAScript exactly as defined, creating individual functions for every abstract operation and maintaining the internal structures as specified, would it necessarily be slow? If it's not feasible to create a fast implementation this way, does anyone know of resources that provide guidance on building an efficient ES engine? Maybe even a revised version of the spec that focuses on performance? That could be interesting!
1 Answer
That's a great question! It's tricky because most JS engines, like V8, don't adhere strictly to the spec—they are actually much more complex than the requirements laid out in the spec. They utilize a variety of internal structures which makes them faster than a literal implementation would be. So a naive, spec-compliant engine would likely not perform well due to these complexities.
Interesting! So, it sounds like the spec isn't really meant to be taken as the final word for implementations? Seems like it needs some interpretation to be practical.