lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I saw this posted on HackerNews:

Besides being generally cool and impressive, I noticed that
the speed of its x86 emulation comes largely from TypedArrays,
which is a recent JavaScript library that lets you treat a byte
array as an array of eg. 32-bit integers, floats, etc.  You can
create different views into the array so that eg. you can write
three floats and then three bytes.  The array elements don't
have to be homogenous.

To my eye this looks like a very small subset of LuaJIT's FFI.
It doesn't let you call C functions or do a lot of the advanced
things that the FFI supports.  But one thing it *does* have
going for it is memory safety -- it performs bounds-checking
which prevents memory corruption.

I was wondering if it might make sense to offer an equivalent
library for LuaJIT.  This library could offer a lot of the efficiency
benefits of FFI (like for numerical computations) without giving
up memory safety.  But "FFI" probably isn't the right name for it
since it wouldn't let you call C functions.