Hacker News new | ask | show | jobs
by randomstringxyz 268 days ago
All of those languages have a lot of freedom, you just ("just") need to reach into the FFI to do it. Lua, which is the only one I have used extensively, is the most literal definition of scripting. It's designed to be written in conjunction with C. Even languages like Haskell with a gigantic runtime still expect you to put in some C for hot paths.
1 comments

FFI scares me if I am being honest and that is why I always try to think of a language which can do a lot of things themselves without having to reach for FFI thinking its going to be my last resort most of the time.

So that was my perspective when I had written up my comment.

What are some really good languages for FFI? Lua as you suggest?

I have always had this notion that FFI is really hard and so firstly I would like to ask if that's really true and secondly is there a langauge which can make it easy to work with FFI the most? Like do you suggest lua for something?

PUC Lua is supposedly a bit of a pain for ffi, but I havent tried it myself. Luajit is some kind of crazy magic. You can (almost) just copy and paste the c header file into the ffi.cdef function and then start using c functions as if they were lua functions.
The LuaJIT ffi module has been ported to PUC Lua [0] (and abandoned and forked dozens of times), and it works pretty well in my experience.

[0]: https://github.com/dibyendumajumdar/ravi-ffi

FFI is harder if the target lib doesn't have a C interface.

I feel I'm forced to reach for FFI if I want to do anything graphical e.g Wayland or OpenGL. Otherwise it's optional