Teaches important virtual machine topics like interpretation, optimization and JIT-compilation. We'll use the Brainf**k language and build simple VMs in Python and, finally, a machine code JIT-compiler in C++ using GNU Lightning.
Link to code:
Virtual machines are everywhere! While they power most modern programming languages, they also show up in unexpected places like: Network packet filters, regular expression engines and all your big name games.
A virtual machine is a piece of software that executes really simple instructions, just like a CPU. Steve Jobs said it best: "It takes these really simple-minded instructions – 'Go fetch a number, add it to this one, put the result there' – but if you execute them at a rate of, say, 1 million per second, the results appear to be magic."
In this talk we'll uncover some of their mystery by building a dead simple machine, from scratch, using Python. You'll get a glimpse of what happens under the hood of VMs like the JVM and CLR, and you'll learn enough so that you can go home and build your own VM!
Near the end of the talk we'll also briefly touch on subjects like bytecode optimization, JIT-compilation and discuss usage applications.
Images of the 6502 CPU were taken from http://www.visual6502.org