Hacker News new | ask | show | jobs
by grahamjameson 697 days ago
Perhaps a middle-of-the-road approach would be to use inline C like LuaJIT's FFI does? For instance:

  new_clib("/system/lib64/liblog.so", "log")
  ffi.cdef[[int __android_log_print(int priority, const char *tag, const char *msg);]]
  ffi.log.__android_log_print(5, "TEST_TAG", "Hello from FFI")
I can't say I'm familiar with Bun, but I've used a similar syntax to the example you provided of the current Bun syntax when working with Frida (https://frida.re). I agree it leaves something to be desired and indeed it would be cool if Aro could do this in the future.
1 comments

LuaJIT spends about 2000 lines[1] on its C parser which even includes a limited expression evaluator, though not a preprocessor. My experience suggests explicit memory management could add half again that (LuaJIT’s piggybacks on its GC), and writing one is something like a month of work even if you know exactly what you’re doing (I didn’t), but in any case it’s not a monumental task.

[1] https://repo.or.cz/luajit-2.0.git/blob/HEAD:/src/lj_cparse.c