GopherLua: VM and Compiler for Lua in Go
github.com
github.com
I'd be interested if someone were to benchmark it against GopherLua.
This situation may change as 5.3 adds many nice changes.
For example, it appears to use the same opcodes and the main VM loop looks very similar:
http://www.lua.org/source/5.1/lvm.c.html
https://github.com/yuin/gopher-lua/blob/master/vm.go
It's interesting because the Go source appears to be annotating certain patterns with comments where the C version uses a macro. Compare the C version:
case OP_LOADK: {
setobj2s(L, ra, KBx(i));
With the Go version: case OP_LOADK:
Bx = int(inst & 0x3ffff) //GETBX
reg.Set(RA, cf.Fn.Proto.Constants[Bx])The problem is, if the author has based their code on this library, they seem not to have credited it (At least, I couldn't find it on my cursory look at the file headers).
And no, it shouldn't be any faster than luajit (what can really :)
I've noticed that Go seems to be fairly popular for emulators / simple VMs as well. I'm currently working on a SID emulator in Go, and I'm finding it quite fun! (unfortunately, it means that I then need to write a proof of concept synth-like API to the SID, then a proof of concept sequencer to control the synth...)
Damn rabbit holes.