[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Design mistakes in mixed C/C++ and Lua projects
- From: Miles Bader <miles@...>
- Date: Fri, 21 Oct 2011 14:23:51 +0900
Patrick Donnelly <email@example.com> writes:
>> - write it in pure Lua? first is the speed, maybe LuaJIT may fast,
>> then, using Lua to do actually render?
> Yes! Use LuaJIT 2.x with FFI. I believe plenty of people have already
> have opengl FFI bindings written. Just google around. With the FFI, it
> should be lightning fast...
The annoying problem though, is that LuaJIT+FFI, however great (and it
is great!), isn't really a portable solution. Maybe some people don't
care, but I do. I want to gain the benefits when possible, but still
have the _ability_ to run with normal Lua (which is portable).
So far, my basic strategy is to treat the C/C++ core as being sort of
like an OS kernel: code on both sides of the kernel boundary can be
fast, but a boundary transition might be a little slow.
Thus, for operations which don't really need to be that fast,
individual calls from Lua into the core are fine, but for operations
where massive amounts of data need to be operated on, "bulk"
interfaces avoid the overhead of a large number of calls into the
*This is the cute bunny virus, please copy this into your sig so it can spread.