i understand the new code to be using zig, i want to use iroh with roc, iroh is a rust library. how feasible is using roc from rust at this point? I'm guessing you would use ffi against the c bindings? I'm also guessing it might be easier to make c bindings for a rust lib and then call those from roc, does that seem like the right way to go about it? I figure calling rust from zig will be easier since the roc compiler has its own processes and expects zig.
Roc has no FFI, so to integrate Roc with any language, you would need to write a Roc platform in that language. Platforms can be in any language, so the Zig rewrite of the compiler won't affect this. The platform is compiled and linked with a Roc app, then the combined platform+app will run the host code (e.g. some Rust code that uses iroh) and call your Roc code.
Someone else will come along and explain this better than me and guide you to resources on writing a platform. :sweat_smile:
+1 to what Hannes said. Here's a resource to learn more: https://www.roc-lang.org/platforms
Platforms isn't the easiest thing to get into right now as most contributions are made toward moving the language itself forward first. However, if you're up for some experimentation and tinkering you'll have fun :)
An easy way to get started is to extend an existing platform like basic-cli or basic-webserver. Perhaps you just need to add a few dependencies and functions in there and you're done?
The new compiler will change the language, and how platforms are built, so if you go into it expecting changes along the line you'll be fine :)
Roc has no FFI
A better way to word this might be that all FFI in roc is controlled by the platform. By default, this tends to mean that to expose something via FFI is to extend a platform or create a new one.
A platform technically could expose raw bindings to libFFI. If it did so, it would enable roc apps to have total control for FFI to any library.
I don't know enough about iroh to give any concrete suggestions here though.
thank you both :slight_smile: I'll play with it and see how it goes
something I had trouble with before, and I don't know probably this was the old compiler but maybe true with either-- I understand the part of platform that I would add, is there an interface or documentation for the list of roc_ functions a platform would need to work? I made a list at one point by looking at old cli/webserver code. Is that the full list? Are there optional functions? This is more theoretical ensuring I fully understand how it works, in practice I'm going to take one of the existing and make it look how I want for now.
I don't think we have it officially written down somewhere (and the api changes between the old and the new compiler). This should be the full list of required functions: https://github.com/roc-lang/roc/blob/824c243d06a820babcbeb85e97c94c0cbfca5c9e/test/int/platform/host.zig#L105-L110 (this is in the new compiler setup).
Thank you!!
Something else I had noticed, and I'm hoping you can confirm or clarify--
The docs split out platform and app, but then digging a bit deeper it seems what you're referring to as platform, is in fact, host/platform, or as I've recently taken to calling it, host plus platform. ;-)
Back in July I tried to map out how all this works and ended up with a diagram that makes me feel a little like Charlie ranting about Pepe Silvia.
I'm sure that this diagram isn't right and maybe was focused on the older compiler.
I guess my question is, how do you see the role of host in roc applications? Do you see this as distinct from platforms or so tightly ingrained where the host should exist for and be dedicated to just one platforms specific needs?
As I use the term, a platform is a host (code in some other langauge) + a roc api.
Last updated: Dec 21 2025 at 12:15 UTC