Re: C binding strategy

  • From: Justin Cormack <justin@xxxxxxxxxxxxxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Thu, 16 Aug 2012 08:42:44 +0100

On Thu, Aug 16, 2012 at 8:12 AM, Francisco Tolmasky <tolmasky@xxxxxxxxx> wrote:
> Oh, I should have mentioned this: I am deploying on iOS so the fact that
> jit-ing won't be an issue may change the answer(s) to this question.

In general, tables are native Lua structures, so C access is less
efficient, while ffi structures are effectively native to both C and
Luajit, So in general you will get the best performance using ffi
structures if you need to talk to C. However it is less efficient to
call C than just use Lua for small stuff that can be inlined, eg
adding two points, and I think most people only use C where there are
existing libraries they want to use, rather than writing significant
new C code for a project (as a guess).

Without the JIT you lose the advantage of compiling and inlining but
the calls to C are also much slower. But actually accessing ffi
structures in Lua and C should not be penalized at all I believe. The
interpreter is still fast, so I am not sure it will change the
strategy you use drastically.

Justin

Other related posts: