as title. is there a Foreign Function Interface (FFI)?
No
Roc is completely pure except for platform interactions
The platform theoretically could expose generic ffi (though it would be a bit of a hassle)
Brendan Hansknecht said:
The platform theoretically could expose generic ffi (though it would be a bit of a hassle)
Ain't Plattforms FFI's?
Can i load multiple platforms, for example from Rust?
Jonas said:
Ain't Plattforms FFI's?
Kinda, but not in the same way that most people think of FFI, like Python has C FFI where you can write arbitrary C code and just call it from Python, but it's not obvious to me how to achieve FFI like that in Roc (but I trust Brendan when he says it's possible :sweat_smile:)
Can i load multiple platforms, for example from Rust?
A roc app depends on exactly one platform. That platform can be written in anything that can speak C FFI. So platforms are a form of FFI. They are just really restricted. If you use the roc-wasm4 platform, you can't send a web request. You can't print to the console except for debug logging. You have extreme limitation. As a roc app, there is no escape hatch. You are just stuck with the limitations that the platform exposes.
When folks ask if roc has FFI, they generally are thinking of python style C FFI. At any point in a python app, I can call any C code that I want. It is completely unrestricted. Roc does not have this form of FFI. So I think it is best to say that roc does not have FFI. Otherwise you just confuse folks.
we have a FAQ entry on this! :smiley:
https://www.roc-lang.org/faq#multiple-platforms
(it's a very frequently asked question!)
Ah yeah. I should remember to just link the faw for some of these
Last updated: Dec 21 2025 at 12:15 UTC