4 ms·
Quite a long time ago, 'interpreter' used to imply that you were making no passes over the code at all before executing it, and yes that means hoisted functions
by chrisseaton 6y ago
Quite a long time ago, 'interpreter' used to imply that you were making no passes over the code at all before executing it, and yes that means hoisted functions would be a problem. I think some shell interpreters still work this way today, and you can see this if you modify a shell script file on disk as it's running, they will actually pick up the changes as they keep reading the lines while executing.
But for many decades, that hasn't been what most people mean by 'interpreter'. What people consider to be a 'pure interpreter' today may still make multiple passes over the code before starting to execute. This is what early JavaScript interpreters did and how they handled hoisting and things.
These passes may include creating an alternate representation like a bytecode. That's where the line between compiling and interpreting gets blurred, as going to bytecode is to some extent compilation.
Major industrial 'interpreters' like Python and Ruby have compilation steps and then interpret a bytecode.
All these terms need to be understood in context, and there's quite a continuum between pure interpreter and static native-code compilation.
- derefr 6y ago> and you can see this if you modify a shell script file on disk as it's running, they will actually pick up the changes as they keep reading the lines while executing. Better yet—you can stream a script into bash, and each line will be executed as it's received over the pipe. In theory, one of those `curl ... | bash` stanzas could actually be talking to a little web-app backend that writes lines of script to the HTTP socket one at a time (maybe using Chunked transfer, but not necessarily), and waits for those individual lines to be executed; where some of those lines are expected to make other curl requests back to the same server; where those other requests in turn change backend state that the original script-streaming session can see; and that state further determines what lines of script get written to the HTTP socket. In other words, just by piping to bash, you're actually giving whatever's on the other end of the pipe an interactive shell on your computer, even without the script installing any separate CNC agent!
- saagarjha 6y agoSounds like a security nightmare :P