|
Based on my experience with Java JIT, and without detailed knowledge of Lua JIT, I think the JIT probably produces much less efficient code than the C compiler for the same "script". That's just the nature of JITs -- they don't have a lot of time to do their job, the user is waiting while they compile, so they must be **FAST**. I'd be very surprised if the Lua JIT produces code that's more efficient than what a C compiler produces at -O2 or even -O1. There's usually a 3X improvement for cpu-bound algorithms going from -O1 to -O4 so that means that highly optimized C code can be (at least) four times faster than an equivalent JIT-ed Lua program.
Add to that the need for the Lua JIT-ed program to support introspection and the overhead of the data types of Lua versus the much simpler data types that are primitives in C, and I wouldn't be surprised for specific programs to see compiled C code be 10x more efficient (both space and time-wise) than an equivalent Lua program when running on a JIT.
--JoeOn Sun, Aug 29, 2010 at 2:52 PM, Patrick McCavery <patrick@cakeandfile.com> wrote:
I know many many people are writing applications as a mix of Lua and C but I am wondering if this is becoming more unnecessary now that we have LuaJit, which is pretty bloody fast.
I know Lua can't be used in kernel space and that without C there would be few libraries, are there any other reasons why why LuaJit could not be used in place of C?
--Patrick