Stream: beginners

Topic: ✔ platform 101


view this post on Zulip Vincenzo Palazzo (vincenzopalazzo) (Dec 02 2022 at 00:15):

Hey I was looking to understand how the platform works but I'm not able to find the docs https://www.roc-lang.org/tutorial there is any other page where it is explained?

view this post on Zulip Brendan Hansknecht (Dec 02 2022 at 00:37):

In which sense: How to make a platform/under the hood details? The api a specific platform exposes to Roc developers? other?

view this post on Zulip Luke Boswell (Dec 02 2022 at 07:38):

There are a couple of super simplified diagrams in the crates README which may help.

view this post on Zulip Vincenzo Palazzo (vincenzopalazzo) (Dec 02 2022 at 08:55):

Luke Boswell said:

There are a couple of super simplified diagrams in the crates README which may help.

Thanks!

view this post on Zulip Vincenzo Palazzo (vincenzopalazzo) (Dec 02 2022 at 08:57):

Brendan Hansknecht said:

In which sense: How to make a platform/under the hood details? The api a specific platform exposes to Roc developers? other?

Sorry for the general question, I would like to know what is a platform (a way to interact with a peace of software written in another language?) and also how it works and it is implemented.

I think all what you ask for ahha

view this post on Zulip Brendan Hansknecht (Dec 02 2022 at 19:50):

So I'll try to give a summary here. Platforms are currently pretty scarcely documented and mostly developed by looking at existing platforms. They just have been a changing target and tooling is still being built up. Hopefully soonish we will have roc glue working well enought that this stabilizes, but not quite yet.

view this post on Zulip Brendan Hansknecht (Dec 02 2022 at 19:55):

For starters, Roc is essentially a sandboxed language. By itself, roc can not interact with the system. It is completely pure and has no side effects.

The platform is ultimately the program that calls into Roc and essentially works as a runtime for each Roc application. A platform is made of 2 parts:

view this post on Zulip Brendan Hansknecht (Dec 02 2022 at 19:58):

When it comes to actual execution. Roc essentially returns a chain of tasks to the platform. The platform then executes the tasks. When the Roc app has to actually run an effect, it tells that to the platform and the platform executes the effect. Then the platform runs a continuation in roc with any data from the effect (like a read line from standard in).

view this post on Zulip Brendan Hansknecht (Dec 02 2022 at 19:58):

This separation is how we keep roc a completely pure language without a giant runtime. A platform can basically be seen as a thin language runtime. Though they are likely to be very targeted and more like a framework in other languages.

view this post on Zulip Brendan Hansknecht (Dec 02 2022 at 20:00):

If you want to look at a platform, I would definitely advise looking at any of the platforms in the examples folder. Of course something like hello world will be simpler while the cli app is more full featured.

view this post on Zulip Brendan Hansknecht (Dec 02 2022 at 20:00):

When it comes to final executable generation. It is easy to think of it as the roc app compiles to a library and then the platform compiles into an executable that use the library.

view this post on Zulip Brendan Hansknecht (Dec 02 2022 at 20:01):

Hopefully that is a decent base explanation. Feel free to ask any questions you have or areas you would like to be delved into more.

view this post on Zulip Anton (Dec 03 2022 at 08:20):

Thanks for explaining this @Brendan Hansknecht. I also saved this to the roc wiki.

view this post on Zulip Vincenzo Palazzo (vincenzopalazzo) (Dec 04 2022 at 21:06):

Brendan Hansknecht said:

For starters, Roc is essentially a sandboxed language. By itself, roc can not interact with the system. It is completely pure and has no side effects.

The platform is ultimately the program that calls into Roc and essentially works as a runtime for each Roc application. A platform is made of 2 parts:

ok I was courius about this runtime stuff because I think this bring a lot of frash ari inside the functional ecosystem. I did stop to use functional language becase interact with anything was painful, but with roc looks like that it is just a platform call.

Ok lets see if I can use them in the advent of code :)

view this post on Zulip Vincenzo Palazzo (vincenzopalazzo) (Dec 04 2022 at 21:06):

thanks for the good explaination

view this post on Zulip Notification Bot (Dec 04 2022 at 21:07):

Vincenzo Palazzo (vincenzopalazzo) has marked this topic as resolved.


Last updated: Jul 06 2025 at 12:14 UTC