4 ms·
I really appreciate the engineering effort went into this "JavaScript interpreter" https://github.com/yt-dlp/yt-dlp/blob/2025.09.23/yt_dlp/jsinterp.py https://
by est 1y ago
I really appreciate the engineering effort went into this "JavaScript interpreter"
https://github.com/yt-dlp/yt-dlp/blob/2025.09.23/yt_dlp/jsinterp.py https://github.com/yt-dlp/yt-dlp/blob/2025.09.23/yt_dlp/jsin...
- stevage 1y agoheh, that's pretty cool.
- supriyo-biswas 1y agoHeh, now I wonder how much JavaScript it actually interprets and given that it’s < 1000 lines, whether it could be used towards an introductory course in compilers.
- kccqzy 1y agoObviously not. An introductory course would introduce concepts like lexers, parsers, AST, etc, instead of working on strings. Here are lines 431 through 433: if expr.startswith('new '): obj = expr[4:] if obj.startswith('Date('):
- deleted 1y ago[deleted]
- Too 1y agoThere’s a famous presentation by David Beazley where he implements a WASM interpreter in Python in under an hour. Highly recommended.
- bangaladore 1y agoBytecode interpreters are quite simple compared to the actual lexer / parser.
- LordShredda 1y agoI'm on mobile, this seems like an actual js interpreter that only does objects and arithmetic. Impressive that it went that far
- jollyllama 1y agoI wonder how long until it gets split off into its own project. For the time being, it could do with a lot more documentation. At least they've got some tests for it!
- CaptainOfCoit 1y ago> I wonder how long until it gets split off into its own project The submission is literally about them moving away from it in favor of Deno, so I think "never" probably gets pretty close.
- jollyllama 1y agoThanks for explaining - I didn't understand that this is what was being replaced.
- zahlman 1y agoAside from the fact that the point of the announcement is that they're dropping it entirely, this "interpreter" is a hack that definitely is nowhere near capable of interpreting arbitrary JS. For example, the only use of `new` it handles is for Date objects, which it does by balancing parens to deduce the arguments for the call, then treating the entire group of arguments as a string and applying regexes to that.
- sirbranedamuj 1y agoThis is the buried lede in this announcement for me - I had no idea they were already going to such lengths. It's really impressive!
- codedokode 1y agoI decided just to look at the code for a moment and discovered ChainMap in Python.
- ddtaylor 1y agoThis is excellent for some of my usages. I want to have my AI agents "fork" their context in some ways, this could be useful for that instead of juggling a tree of dictionaries.
- bjackman 1y agoHa, that's cool. I have implemented a crappy and probably broken version of this type before. Next time I won't have to!
- XnoiVeX 1y agoIt's a subset of Javascript. HN discussion here https://news.ycombinator.com/item?id=32794081 https://news.ycombinator.com/item?id=32794081
- ASalazarMX 1y agoThis is amazing, an old school but effective approach in this modern age. I was afraid they were going to embed a browser.
- extraduder_ire 1y agoThis description reminds me of program language wars excerpt I saw somewhere years ago about how c was obviously superior to Pascal, because with enough preprocessor macros you can compile any Pascal program in c. Followed by some hideous and humorous examples.
- 3abiton 1y agoThat was such a stroll through memory lane.
- Aurornis 1y agoThis is perfect for the problem they were solving. Really cool that they took it this far to avoid adding further overhead.
- jokoon 1y agoWait I thought they were running an entire browser engine
- ddtaylor 1y agoOver time they probably will require that. I believe YT still allows most of these things because of "legacy" apps, which they have been killing off bit by bit. I'm not sure if anyone is cataloging the oldest supported app, but most things like using YT from a slightly older game console don't work anymore. Basically any publicly known method that can sip video content with doing the least work and authentication will be a common point of attack for this.