Stream: ideas

Topic: nested platforms?


view this post on Zulip Sky Rose (May 05 2023 at 05:05):

I've been wondering: Is it possible to write a platform in roc, providing a subset of the features of the parent platform?

I see a couple use cases:

  1. Sandboxing. Suppose you have a full featured platform, and want to provide a way to write apps that use a safe subset, enforced with the strength of roc platforms.

    - Example a. A university programming class is taught in roc. The students submit homework as roc apps. They could do it on some official cli-app platform, but the grader instead has the students submit their work as apps on a custom cli-sandbox platform so she can run their submissions safely.
    - Example b. A game includes a powerful modding system as a roc platform. They also publish a nested platform for cosmetic-only mods that the child platform guarantees don't affect gameplay, so they can be safely allowed in competitive game modes.

  2. Better interfaces / frameworks. Example: Some roc-browser platform exists that is a thin layer on top of browser APIs. Someone makes a child platform based on it that gives an easy-to-use API for a Single Page App framework, like The Elm Architecture, so app developers can use that instead of making raw browser API calls. Though maybe this could be done with a library instead of a platform.

One hurdle I see is memory management. You need to be able to allocate memory in order to write a platform, but roc programs have automatic memory management. Could the alloc implementation written in roc just create a big array?

view this post on Zulip Brendan Hansknecht (May 05 2023 at 05:15):

Interesting idea. I would assume that if we enabled this, you probably wouldn't be able to affect roc_* functions (used for memory management among other things). Those would stay as the ones specified by the original platform. Instead, you would import the platform just like a regular roc app, but instead of defining an app, you would be re-exporting it with a new API.

This definitely could be possible. Would essentially just require packages that can depend on and re-export platforms. Would need to add extra constraints such that it could require a function much like platforms currently do.

I'm not exactly sure the ergonomics/tradeoffs of doing this in roc vs telling people to just modify the rust CLI platform, but this does sound like a nice use case.

view this post on Zulip Brendan Hansknecht (May 05 2023 at 05:16):

Aside: maybe we should move this to #ideas

view this post on Zulip Sky Rose (May 06 2023 at 15:11):

I don't have permission to move topics, so if it belongs in #ideas, someone with permission will have to move it.

view this post on Zulip Notification Bot (May 06 2023 at 15:24):

This topic was moved here from #beginners > nested platforms? by Anton.


Last updated: Jun 16 2026 at 16:19 UTC