I'm really intrigued by Roc and I decided to try to port a Rust 2d toy game I'm building to it by implementing a platform with the 'framework' code and putting my game logic in Roc such that an exposed main function configures the game window and sets an update function to be called during rendering.
I've started by trying to understand the basic-cli implementation, and there's two files: main.roc and main-glue.roc -- best I can tell there's layered abstraction happening here where main.roc is the user-facing platform code written entirely in Roc, which uses main-glue.roc which is itself another platform that actually links to Rust code implementations (types named Internal*).
How does main.roc know of main-glue.roc? Is this a conventional thing or is there a bit of linkage here I am missing?
BTW I've read https://www.roc-lang.org/platforms so far, any other required reading before embarking on this journey? :laughing:
main-glue.roc
is a workaround to get glue to generate correctly
Aand I would add that it doesn't generate correct rust, so I normally fix it up by hand and also only use some parts of it. We had some issues recently and a bunch of basic-cli was rewritten to not use the glue parts. Basically glue is still a WIP unfortunately.
https://github.com/roc-lang/basic-cli/tree/refactor-host
I would suggest checking out the implementation in this branch. It's laid out slightly differently to try and make it clearer the distinction between different parts.
Thanks folks, I'll give this a look!
Last updated: Jul 06 2025 at 12:14 UTC