Hi there !
On the train yesterday, I decided to reimplement all the core parts of Rubyk (a real-time signal processing tool,
http://rubyk.org) in Lua for the following reasons:
I want to remove mutex (==> going single threaded with zeroMQ to spawn many processes).
I am tired of spending time dealing with reinventing a dynamic type system, garbage collection and such in C++. I want to focus on the real features of Rubyk: network transparency, code reuse through prototypes, remote code upload, etc.
Anyway, I still want my thing to be very fast, especially on small embedded hardware.
I did some tests to implement the patching support (outlet, inlet, connections) in Lua with two different approaches:
1. pure closures (no self in objet nor inlet/outlet)
100'000 objects:
100.2 Mb
1'000'000 times an operation involving inlet/outlet
0.9 s
2. metatable (self)
100'000 objects:
40.3 Mb
1'000'000 times an operation involving inlet/outlet
1.32 s
From these two considerations, it is very hard to decide (I prefer the closure for the public/private interface). But then I looked at the benchmarks with LuaJit2 (
http://lua-users.org/wiki/ObjectBenchmarkTests) and with this compiler, the speed is the same but nothing is said about memory usage.
Any advice regarding solution "1" or "2" would be greatly appreciated, knowing that embedding is important (we do not always have tons of RAM).
Gaspard