Stream: beginners

Topic: What is the point of the 'glue'?


view this post on Zulip cgatdv (Jan 09 2024 at 19:37):

I'm a little conceptually confused on the glue files you can find for rust and zig. These files let the platform call other zig and rust code and use it within the roc program? Or is it allowing the roc platform to be called as if it were rust / zig code?

view this post on Zulip Brendan Hansknecht (Jan 09 2024 at 19:39):

glue is made to make platform development easier

view this post on Zulip Brendan Hansknecht (Jan 09 2024 at 19:39):

A platform can be written in any language.

view this post on Zulip Brendan Hansknecht (Jan 09 2024 at 19:39):

Rust is currently the most supported.

view this post on Zulip Brendan Hansknecht (Jan 09 2024 at 19:39):

glue will generate rust/zig/etc bindings that a platform can use to interact with a roc app

view this post on Zulip cgatdv (Jan 09 2024 at 19:42):

Gotcha, so the platform runs the Roc code. The bindings allow I/O between a rust program and the platform itself, correct?

view this post on Zulip Brendan Hansknecht (Jan 09 2024 at 20:01):

The rust program is the platform.

view this post on Zulip Brendan Hansknecht (Jan 09 2024 at 20:06):

I'll try to be a bit more specific:

A Roc program is split into two core pieces: a platform and an application.
The application is just pure roc code and libraries. This is what a user writes.
The platform is split into two more pieces: the host and the roc api.

The host can be written in any language that can talk C FFI. It uses C FFI to interact with the roc api.

So the full picture is:
host -> c ffi -> roc api -> application

glue generates the c ffi part for various languages.

view this post on Zulip cgatdv (Jan 09 2024 at 20:16):

Ahh, okay thank you! I realize I misunderstood how the platform worked. Appreciate it!

view this post on Zulip Brendan Hansknecht (Jan 09 2024 at 20:29):

general doc on platforms for reference: https://www.roc-lang.org/platforms


Last updated: Jul 06 2025 at 12:14 UTC