Stream: beginners

Topic: Does Roc have any database clients yet?


view this post on Zulip Shawn (Jan 29 2024 at 20:31):

How do we store/query data when using Roc?

view this post on Zulip Brendan Hansknecht (Jan 29 2024 at 20:33):

roc-pg is the only existing database driver

view this post on Zulip Brendan Hansknecht (Jan 29 2024 at 20:33):

Though people have also used the sqlite cli via sub processes

view this post on Zulip witoldsz (Mar 08 2024 at 12:44):

I am wondering what would be easier: to create native database connectors, like roc-pg or to use something like libpg wrappers or some ready to use C/C++ connectors?

view this post on Zulip Anton (Mar 08 2024 at 13:03):

We recently included sqlite in basic-webserver, that may be the most convenient way.

view this post on Zulip Luke Boswell (Mar 08 2024 at 20:16):

Forking a platform and wrapping another library is probably the easiest to get started.

here is an example of the sqlite on action. I like this example for how I parse the rows and handle errors.

view this post on Zulip witoldsz (Mar 11 2024 at 12:01):

Forking a platform looks like a workaround, or is it The Way®™?

view this post on Zulip Richard Feldman (Mar 11 2024 at 12:05):

for something like this, I'd say:

view this post on Zulip Richard Feldman (Mar 11 2024 at 12:06):

so it really depends on what your goals are - get the application working quickly, or make an investment in the ecosystem? Either is totally reasonable, depending on your priorities! :smiley:

view this post on Zulip witoldsz (Mar 11 2024 at 14:16):

Is there any long-term plan for a 3rd option which would not require forking a platform and also not having to implement an integration from scratch? I don't know what would that be, like a… plugin for a platform?

view this post on Zulip Richard Feldman (Mar 11 2024 at 15:36):

in the specific case of a database client, I think the optimal long-term plan is to implement them in Roc like how roc-pg does it

view this post on Zulip Richard Feldman (Mar 11 2024 at 15:37):

it's the simplest, the safest, and the most portable

view this post on Zulip Richard Feldman (Mar 11 2024 at 15:37):

the only downside is that it has to actually be implemented :big_smile:

view this post on Zulip Richard Feldman (Mar 11 2024 at 15:38):

which is why it's the best long-term but maybe not in the immediate term depending on what you're building!

view this post on Zulip witoldsz (Mar 11 2024 at 16:04):

Implementing is not the hard part. The hard part is to keep it up to date and follow all the new features. It might be a real problem for Roc – I can see how much a problem it's sometimes in languages with much larger community like F#, where implementing a PG library is just a thin wrapper around Dotnet/C# and even though it lags behind very often.

As I said, implementing something like a full featured database (or RabbitMQ) driver is seems like the easy part, the long-term maintenance is hell, because very often the founder is no longer paying attention.

At the end of a day, a F# team can take a desperate measure and just switch to a C# library. For Roc, the equivalent would be to switch to C/C++/Rust/Zig/whatever C-like and go from there instead.

view this post on Zulip Richard Feldman (Mar 11 2024 at 16:11):

I don't think we should take it as a given that in the long term Roc's community will be small; in fact, I assume the opposite :big_smile:

view this post on Zulip Richard Feldman (Mar 11 2024 at 16:12):

I appreciate that database clients are not simple projects, but I don't think that changes the fact that it's simplest, safest, and most portable to do it in Roc

view this post on Zulip Richard Feldman (Mar 11 2024 at 16:15):

the most popular C# pg client is 100% C#, and the most popular Java pg client is 100% Java.

view this post on Zulip Richard Feldman (Mar 11 2024 at 16:16):

same for Go

view this post on Zulip Richard Feldman (Mar 11 2024 at 16:17):

maybe there was a time when these were C wrappers (C# and Java were both small communities once, too, and certainly Go is smaller than either) but clearly it's realistic to implement database clients without wrapping existing drivers in other languages, and I think when we're talking about the long term we should plan for doing what's best! :smiley:


Last updated: Jul 06 2025 at 12:14 UTC