Stream: beginners

Topic: What should a platform do?


view this post on Zulip Kasper Møller Andersen (May 19 2024 at 07:48):

I'm trying to wrap my head around platforms at the moment, and I roughly get the idea behind the IO handling (the platform handles IO when you want to execute a task). But at the same time, the platform also exposes the main interface to applications (so CLIs have a main which returns an exit code, web servers have different setups, and so on).

To me these two seem like they sometimes overlap, but many other times, I think I would want the IO primitives being separated from the application interface.

For example, the Kingfisher platform exposes both a particular main interface, while also handling network requests under the hood. This is intriguing, but I also have a feeling that this moves a lot of code into the platform, which could have been written in Roc. Essentially, the platform contains a bunch of code not related to handling IO, and such code could have benefitted from being written in Roc. But because it must live in the platform, it can't.

Another example would be if we said that, hypothetically, Elm was recreated 1-to-1 as a Roc platform. Say that I write a nice web app using that, and I figure I want to turn it into a desktop app. Now there might exist an Electron platform I could switch to, or a Tauri, Servo, or whatever platform that can render HTML. But wouldn't all those platforms essentially need to re-implement the framework (i.e. The Elm Architecture) on top of also handling IO, such that they can expose the same interface to my application?

I guess the underlying question is: can these frameworks be created independently of the platform? It seems to me that the platform is what dictates what IO is available across the entire application, so any framework that wants to control IO in some way must be written into the platform.

Am I understanding that right? And if so, has there been any discussion on breaking those two apart in some way?

view this post on Zulip Luke Boswell (May 19 2024 at 20:42):

I think you will find the Module Params design an interesting read https://docs.google.com/document/d/110MwQi7Dpo1Y69ECFXyyvDWzF4OYv1BLojIm08qDTvg/edit?usp=drivesdk

view this post on Zulip Luke Boswell (May 19 2024 at 20:42):

Agus has been working on that and it sounds like it's getting close. So hopefully we can start exploring the new design for platform independent modules etc.

view this post on Zulip Luke Boswell (May 19 2024 at 20:44):

This, and moving Task into the builtins, will enable a lot more to be moved into packages and the platforms can provide lower level primitives.

view this post on Zulip Kasper Møller Andersen (May 19 2024 at 21:38):

Gosh, that sure sounds like one sweet proposal! That answered all my questions, raised new ones, and then answered those to an awesome degree :heart_eyes:

view this post on Zulip Kasper Møller Andersen (May 19 2024 at 21:38):

Thanks!


Last updated: Jul 06 2025 at 12:14 UTC