News for hackers. Stuff that matters.
Re:GopherLua: VM and Compiler for Lua in Go by nsjph on Saturday February 21, 2015 @11:56AM (#9086015)
On a similar note, there's a clojure-like (syntax) embeddable VM called glisp: https://github.com/zhemao/glisp. I've been tinkering with it to add dynamic plugins to some golang programs.

I'd be interested if someone were to benchmark it against GopherLua.

Re:GopherLua: VM and Compiler for Lua in Go by kibwen on Saturday February 21, 2015 @12:01PM (#9086037)
Interesting that it implements Lua 5.1 rather than any of the newer versions. Is it because LuaJIT implements 5.1, thereby making that the de facto canonical language version?
Re:GopherLua: VM and Compiler for Lua in Go by trynumber9 on Saturday February 21, 2015 @03:38PM (#9086811)
Lua 5.1 is the most widely used. LuaJIT is a big factor. But changing existing code to use the 5.2 API is not worth the few changes 5.2 offered. The 5.1 API has the most libraries. Many existing code bases try to stay compatible with 5.1.

This situation may change as 5.3 adds many nice changes.

Re:GopherLua: VM and Compiler for Lua in Go by haberman on Saturday February 21, 2015 @01:07PM (#9086257)
From a quick glance at the source, it looks like this may be a port of the existing Lua VM for C into Go.

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])
Re:GopherLua: VM and Compiler for Lua in Go by SixSigma on Sunday February 22, 2015 @03:58AM (#9088773)
And what a useless comment GETBX is.
Re:GopherLua: VM and Compiler for Lua in Go by Intermernet on Sunday February 22, 2015 @04:02AM (#9088782)
This in itself isn't a bad thing. When I'm porting code, I try to start with a proven code-base and port from there, while iterating the code to make it more idiomatic (e.g. "case OP_LOADK" is not idiomatic Go).

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).

Re:GopherLua: VM and Compiler for Lua in Go by lclarkmichalek on Saturday February 21, 2015 @12:06PM (#9086059)
Well it certainly beats javascript on the fibonacci benchmark, clearly this is the language of the future.
Re:GopherLua: VM and Compiler for Lua in Go by blt on Saturday February 21, 2015 @12:34PM (#9086153)
Stupidest benchmark ever. Tests nothing but procedure call speed.
Re:GopherLua: VM and Compiler for Lua in Go by munificent on Saturday February 21, 2015 @02:00PM (#9086452)
Procedure call speed does matter.
Re:GopherLua: VM and Compiler for Lua in Go by fit2rule on Saturday February 21, 2015 @12:40PM (#9086166)
Still though, Lua kicks JS' ass ..
Re:GopherLua: VM and Compiler for Lua in Go by m0sia on Sunday February 22, 2015 @08:00AM (#9089228)
Is it any way better/faster than luajit or vanilla lua? I can't understand why people are so excited about it.
Re:GopherLua: VM and Compiler for Lua in Go by sztanpet on Sunday February 22, 2015 @08:34PM (#9092100)
The excitement is because Lua is a very nice little language with the explicit goal of being embedded into programs, so when a pure-go port of the language appears that is not just bindings to the C version it is warmly welcomed.

And no, it shouldn't be any faster than luajit (what can really :)

Re:GopherLua: VM and Compiler for Lua in Go by andrewchambers on Sunday February 22, 2015 @09:14PM (#9092206)
Its just an extension language for go programs, The advantage is that is uses the go garbage collector, and can interop with Go code nicely.
Re:GopherLua: VM and Compiler for Lua in Go by giancarlostoro on Saturday February 21, 2015 @02:37PM (#9086569)
Been waiting for someone to make languages in Go to see the results
Re:GopherLua: VM and Compiler for Lua in Go by ndrscr on Saturday February 21, 2015 @10:01PM (#9088014)
Re:GopherLua: VM and Compiler for Lua in Go by Intermernet on Sunday February 22, 2015 @04:08AM (#9088800)
That's a brilliant comment!

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.