Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For one thing, you don't have to use this module with C. Any language that supports exporting C-compatible functions will do – there's C++ of course, but also Rust, Go, D, Nim, and many many others.


LuaJIT also supports C-functions. It's FFI [0] will allow you to declare any C-compatible function or data structure, and then use it in normal Lua code.

[0] https://luajit.org/ext_ffi.html


Why would you ever opt to go thru Lua in this case?


It's well supported, well maintained, and around for the foreseeable future. (OpenResty)

The language implementation is fast, and allows you to tap into any C-compatible library.

The question isn't why you would go through Lua, but why you would choose something with less support?


This doesn't seem to support actually exporting C-compatible functions.


Create some Lua code that runs within C? Rather than just passing and converting to C values when needed?

That's the role of the C API [0]. But usually you'd just be passing C up to Lua to bind it together.

[0] https://luajit.org/ext_c_api.html


it's complicated




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: