Stream: beginners

Topic: Understanding Platforms


view this post on Zulip Ryan Bates (Dec 11 2023 at 18:46):

I have a few questions on how platforms work. From my understanding a platform is the only way a Roc app can have external side effects. I like the concept and think tasks with backpassing are an ingenious solution to handling side effects in a functional way. However relying on a single platform seems limiting.

Is a rock app limited to one platform? What if I need to communicate with a database or external API, does the platform need to support that directly? What if I need PostgreSQL, MongoDB, Redis and Memcached all in one app? Having one platform match all of those requirements doesn't seem flexible.

view this post on Zulip Brendan Hansknecht (Dec 11 2023 at 18:48):

Some general reading is at roc-lang.org/platforms

view this post on Zulip Brendan Hansknecht (Dec 11 2023 at 18:50):

Quick answers to all of the questions:

Is a rock app limited to one platform?

yes.

What if I need to communicate with a database or external API, does the platform need to support that directly?

The hope is that the platforms can support a generic TCP and HTTP primitives and the rest can be built in roc. This will enable a lot of sharing.

What if I need PostgreSQL, MongoDB, Redis and Memcached all in one app?

There is already roc-pg that enables using Postgress just over TCP. the same could be done for all of those databases.

Having one platform match all of those requirements doesn't seem flexible.

I think for a number of use cases it will be common to just build a custom platform for the application. Maybe start with something more generic, but tune it to the specific extras of a use case.

view this post on Zulip Richard Feldman (Dec 11 2023 at 18:52):

there's a design (currently being implemented) for how to have platform-agnostic effects!

view this post on Zulip Ryan Bates (Dec 11 2023 at 18:53):

Thanks for the replies, glad to know this is addressed. :smiley:

view this post on Zulip Eelco Hoekema (Dec 11 2023 at 21:22):

Where can we find roc-pg?

view this post on Zulip Eelco Hoekema (Dec 11 2023 at 21:24):

nvm: https://github.com/agu-z/roc-pg


Last updated: Jul 06 2025 at 12:14 UTC