Hacker News new | past | comments | ask | show | jobs | submit login

It'd be great if people used FFI, or the standard built-in equivalent, Fiddle, but they generally don't, so it doesn't really practically solve the problem at the moment. I think there's something like half a billion lines of C extension code using the traditional API out there.

However, note that the FFI isn't really applicable with one very common use-case of C extensions anyway - increased performance through reaching through abstractions. See fast_blank for example. Can you reimplement that effectively using a cross-platform FFI? I'm not sure you can.

The FFI also adds a bit of runtime overhead for each call, which you may not want.




Only support extensions in Wasm? Change build tooling (I don't Ruby, I am sure it has an equivalent) so that setup.py builds the C extension into a Wasm module.

Or grab the fn that the FFI points to and lightly decompile and inline into the interpreter?

Compile the typed subset of dynamic language of the day into Wasm and inline that into the interpreter?

I am sure something here is the Holy Grail of native-ish extension mechanism.


GraalPython and TruffleRuby are trying this exact idea, but with LLVM bitcode rather than WASM.




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

Search: