lukego / blog

Luke Gorrie's blog
565 stars 11 forks source link

Tracing JIT and guitar looper pedals #34

Open lukego opened 5 years ago

lukego commented 5 years ago

Fight me:

Programming with a tracing JIT is just like playing guitar with a looper pedal.

First check out this (amazing) guitar performance with a looper pedal on YouTube though.

Initially the looper is blank and it can't produce any sound. The performer has to record the music in discrete pieces, starting with the beat and working up. The performance of each piece is completely free and dynamic the first time, but then it is completely static afterwards. Gradually enough pieces are recorded and combined that the looper can play the whole piece by simply replaying samples.

Initially the VM has no traces and can't run any machine code. The bytecode program has to record the algorithms in discrete pieces, starting with the inner loops and working up. The execution of each piece is completely free and dynamic the first time - types, branches, functions - and then completely static subsequently. Gradually enough code fragments are recorded and combined that the VM can run the whole program by simply replaying fragments of machine code.

Playing guitar for a looper pedal is a specific skill that one has to learn, and so is writing programs for a tracing JIT. Some aspects are familiar and some are different. Some things are easier and some are harder. You have to familiarise yourself with the strengths and limitations and work with them. You can't do justice to dynamic performers like Iggy Pop or branchy algorithms like hashtable lookups using these tools, and that is just how it is.

The real problem is that while YouTube is full of tutorials on playing guitar with a looper pedal there does not seem to be much material about writing programs with a tracing JIT. This has to change!

See also epic twitter thread.

(Disclaimer: I'm neither a guitarist nor an expert on Iggy Pop.)

Shados commented 5 years ago

That's an interesting analogy, but it sounds more like the VM is the guitar player. Which makes the programmer someone attempting to write... not a song, but a collection of discrete pieces, and a guide on how to compose them live?

Additionally, if you're a fan of live looping, Dub Fx does some great stuff.