How should a programming noob interpret this? Be impressed at what was achieved here? Be concerned about security implications using the tool? Something else entirely?
YouTube-dl has an interpreter for a subset of JavaScript in 870 lines of Python
131–140 of 166 posts
Re: YouTube-dl has an interpreter for a subset of JavaScript in 870 lines of Python
#132Earlier quoted context omitted.
I would be horrified if this grew much further. It's perfectly fine for its current scope, but the architecture would not scale at all to a full interpreter without essentially starting from scratch.
How much does it need to "scale"? It just has to be fast and correct enough for the a CLI to work.
This interpreter is built around matching specific Regex patterns and then immediately executing hard-coded behaviors with a few slots for parameters. It's missing a whole lot of the skeletal structure that would be necessary to "scale" it up to support a generally useful subset of JS, much less the entire language. Without the necessary structure, it would be a buggy mess that's impossible to maintain, and you can't just take the existing code and structure it better: it's built on the wrong foundation. That's what I mean when I say it won't scale.
That's not a judgement against the team that wrote it! It meets their needs fine, and choosing a minimal solution is great engineering that takes a lot of guts in the current software culture. I like what they've done here. Just don't take it and try to scale it up into a full JS runtime.
Re: YouTube-dl has an interpreter for a subset of JavaScript in 870 lines of Python
#133Earlier quoted context omitted.
Agreed. If you only know this from someone else's observation, you should link the observation.
That is against HN guidelines: "Please submit the original source. If a post reports on something found on another site, submit the latter." - https://news.ycombinator.com/newsguidelines.html
Instead we could be considering if we're meant to read the Twitter conversation as well, or sharing a laugh about the link in the tweet author's bio. Or maybe the sharer didn't feel comfortable enough seeming like they made the claim but still wanted to share it because it's kind of cool.
AFAIK there's no junior HN mod of the year award.
Re: YouTube-dl has an interpreter for a subset of JavaScript in 870 lines of Python
#134Earlier quoted context omitted.
Agreed. If you only know this from someone else's observation, you should link the observation.
That is against HN guidelines: "Please submit the original source. If a post reports on something found on another site, submit the latter." - https://news.ycombinator.com/newsguidelines.html
Re: YouTube-dl has an interpreter for a subset of JavaScript in 870 lines of Python
#135Anyone who has ever pulled a website from a script knows the pain that is Javascript. Normally you want to just get some text and work out the API actions but a lot of sites use horribly obfuscated Javascript -- either because that's what modern web development is (lolz) -- or because its part of their 'security.' That means if you want to write browser-based bots properly -- you ought to use a browser. There are spe…
You probably have to emulate some of the DOM, but you can interact directly with whatever obfuscated/packed scripts in a more lightweight and secure way than driving an entire browser.
Re: YouTube-dl has an interpreter for a subset of JavaScript in 870 lines of Python
#136Anyone who has ever pulled a website from a script knows the pain that is Javascript. Normally you want to just get some text and work out the API actions but a lot of sites use horribly obfuscated Javascript -- either because that's what modern web development is (lolz) -- or because its part of their 'security.' That means if you want to write browser-based bots properly -- you ought to use a browser. There are spe…
Re: YouTube-dl has an interpreter for a subset of JavaScript in 870 lines of Python
#137Re: YouTube-dl has an interpreter for a subset of JavaScript in 870 lines of Python
#138Earlier quoted context omitted.
I would be horrified if this grew much further. It's perfectly fine for its current scope, but the architecture would not scale at all to a full interpreter without essentially starting from scratch.
Yeah, at some point you have to question if it's worth spending time maintaining a quirky, error-prone, ever-growing mini-JS interpreter, or just adding a dependency on v8 or node or something. And then you don't have to worry about supporting new scripts, as they'll just always work.
Re: YouTube-dl has an interpreter for a subset of JavaScript in 870 lines of Python
#139Nowadays "javascript" refers to the scriptable, grotesquely and absurdely complex and massive web engines, aka google financed blink and geeko, then apple financed webkit, that with their SDK. The currently obfuscated javascript media players will try to break yt-dlp by leveraging the complexity and size of those scripted web engines. They will make them out of reach to small teamns or individuals and it is even "bet…
> quickjs from M. Bellard and friends Is the M key next to the F key on your particular keyboard by chance? Because I've always called him "Fabrice." https://en.wikipedia.org/wiki/Fabrice_Bellard
Re: YouTube-dl has an interpreter for a subset of JavaScript in 870 lines of Python
#140Nowadays "javascript" refers to the scriptable, grotesquely and absurdely complex and massive web engines, aka google financed blink and geeko, then apple financed webkit, that with their SDK. The currently obfuscated javascript media players will try to break yt-dlp by leveraging the complexity and size of those scripted web engines. They will make them out of reach to small teamns or individuals and it is even "bet…
> quickjs from M. Bellard and friends Is the M key next to the F key on your particular keyboard by chance? Because I've always called him "Fabrice." https://en.wikipedia.org/wiki/Fabrice_Bellard