3 ms·
I agree that it has a bunch of novel ideas, but I wouldn't list the register-based VM and table optimizations among them; register-based VMs go back to the 1950
by kragen 18y ago
I agree that it has a bunch of novel ideas, but I wouldn't list the register-based VM and table optimizations among them; register-based VMs go back to the 1950s, depending on how you want to count, and using different representations for tables used as arrays and tables used as hashes (that's what you mean by "table optimizations", right?) is pretty unsurprising. I'm not saying it isn't a great engineering achievement; I never would have predicted that those things would have been worth the cost in Lua's context, and they were, brilliantly so.
I would instead list their one-pass-compiler implementation of flat closures and their approach to continuations, and especially integrating continuations with C code calling back into Lua.
I second the recommendation of the paper. I also think their paper on LPEG is worth reading for anyone who is considering using regular expressions or yacc or ANTLR for anything: http://www.inf.puc-rio.br/~roberto/docs/peg.pdf http://www.inf.puc-rio.br/~roberto/docs/peg.pdf
- silentbicycle 18y agoTo my understanding, stack-based VMs are more common than register-based VMs, and the Lua VM is noteworthy for being both well-implemented and small enough to read. Then again, it looks like you're quite a bit ahead of me in reading about VMs. I just found this in your "blog thing" yesterday: http://www.bentwookie.org/blog/kragen-tol/2007-September/000871.html http://www.bentwookie.org/blog/kragen-tol/2007-September/000... You've got a lot of good links. :) By "table optimizations", I meant the way it behaves as both a dict and a table, depending on how it is used, and how much they get out of using those throughout the language. (I wrote the above in a hurry before catching the bus, and knew I had missed better examples, but it came to mind from the _Implementation_ paper.)
- kragen 18y agoYes, I agree that stack-based VMs are more common than register-based VMs, and it was an unusual decision on the part of the Lua folks to choose a register-based VM, particularly given their emphasis on implementation simplicity. And it appears to have paid off, which is pretty cool! I'm glad you've enjoyed the various links. I meant the way it behaves as both a dict and a table You mean, a dict and an array? I'm not sure I agree with their decision to unify those structures, but it does seem not to have cost them much implementation complexity or performance.
- silentbicycle 18y agoOops. Dict and an array, yes. Also, Lua had a stack-based VM until Lua 5.0.