4 ms·
Reading the issue comments, I still don't quite get why this is the case. Anybody with a better handle on PL theory and/or JS internals care to ELI5?
by whoisburbansky 6y ago
Reading the issue comments, I still don't quite get why this is the case. Anybody with a better handle on PL theory and/or JS internals care to ELI5?
- saagarjha 6y agoPerhaps the linked, seemingly related WebKit bug may be interesting? https://bugs.webkit.org/show_bug.cgi?id=199866 https://bugs.webkit.org/show_bug.cgi?id=199866
- whoisburbansky 6y agoTLDR seems like var isn't scope-bound, but let is, and actually calculating the scope for let statements is what's causing the slowdown?
- morelisp 6y agoDamn you Olin Shivers!
- winstonewert 6y agowild speculation: let/const is implemented by creating a new scope with every let or const declaration. Looking up variable then ends up tracing linearly through all of these scopes. Bundlers end up creating a huge number of let/const and thereby scopes. Then every variable reference ends up scanning through this huge linear list of scopes to find the variable it refers to.
- brundolf 6y agoWhy would there be a whole new scope for every declaration, instead of just each block? To prevent access within the block but before the declaration?
- nightcracker 6y agoProbably was simplest to implement, and then not looked at again.
- winstonewert 6y agoYes, I think creating a new scope for every let/const would be the simplest (but not very efficient) way to accomplishing that.