Stream: beginners

Topic: Can Roc be used as a scripting language for another program?


view this post on Zulip Katie And (Jul 18 2024 at 23:01):

I'm looking for a language to use as a scripting language for a plugin system for a project of mine. No language so far has provided what I want it to have, and someone suggested Roc, so I am considering it right now. What do all of you think? Should I use it for this purpose? Is that possible?

view this post on Zulip Luke Boswell (Jul 18 2024 at 23:16):

I think roc is great for scripting. I've been using it a lot. What kind of scripts are you wanting to write?

view this post on Zulip Luke Boswell (Jul 18 2024 at 23:17):

If you'd like to see an example of a script in roc using basic-cli for example, checkout this build script which we use to build basic-cli iteself.

view this post on Zulip Katie And (Jul 18 2024 at 23:20):

Sorry, I realized that in editing my message trying to be clearer about what I mean, I completely deleted what I actually meant.

I'm making a program, and I want it to have plugin support. I'm looking for a programming language to use for this

view this post on Zulip Katie And (Jul 18 2024 at 23:20):

Is roc a good choice for this?

view this post on Zulip Luke Boswell (Jul 18 2024 at 23:23):

I also think roc is a good choice for this too :smiley:

view this post on Zulip Luke Boswell (Jul 18 2024 at 23:24):

There's a few others who are also keen on using roc in this way. Lot's of different options for how to do it today, depending on a few trade-offs.

view this post on Zulip Luke Boswell (Jul 18 2024 at 23:28):

For example you might want to;

view this post on Zulip Katie And (Jul 18 2024 at 23:42):

I really am entering areas beyond my expertise here wow. I suppose it's always good to learn new things. Do you know what I should look into to get started with doing this in Rust?

view this post on Zulip Luke Boswell (Jul 18 2024 at 23:55):

Minor plug for my template repository https://github.com/lukewilliamboswell/roc-platform-template-rust

view this post on Zulip Luke Boswell (Jul 18 2024 at 23:55):

I'd start by getting set up and familiar with the basics of making a platform. Try adding effects or different features.

view this post on Zulip Luke Boswell (Jul 18 2024 at 23:56):

It's a fairly deep rabbit hole :sweat_smile: I've been learning new things for quite some time, but folks here have always been very helpful and taught me a lot about low level things.

view this post on Zulip Katie And (Jul 18 2024 at 23:58):

Certainly looks deep huh!

view this post on Zulip Katie And (Jul 18 2024 at 23:58):

I guess I should start by asking what a platform is

view this post on Zulip Katie And (Jul 19 2024 at 00:00):

Is it like... a library that provides functionality to the language?

view this post on Zulip Brendan Hansknecht (Jul 19 2024 at 00:01):

Your program would be a platform. It is the underlying program that actually executes and gives all io primitives to roc

view this post on Zulip Katie And (Jul 19 2024 at 00:01):

i see

view this post on Zulip Katie And (Jul 19 2024 at 00:01):

that's interesting

view this post on Zulip Katie And (Jul 19 2024 at 00:02):

i see why you're saying it's good for plugins, if it works like this

view this post on Zulip Brendan Hansknecht (Jul 19 2024 at 00:02):

Should I use it for this purpose?

Roc is usable for this today, but it definitely is not easy to use like this currently. Platform development while not super hard is not easy either. So 100% doable, but expect to spend time debugging and tailoring to your needs.

view this post on Zulip Brendan Hansknecht (Jul 19 2024 at 00:02):

Of course, many people here are willing to help out and guide

view this post on Zulip Katie And (Jul 19 2024 at 00:05):

At this point, making my own language is among my other options, so spending time debugging and tailoring is an upside compared to that haha. I do wanna make sure that Roc is a good choice for me, so I'm gonna spend some more time checking it out before i commit to spending weeks trying to implement it for my program

view this post on Zulip Brendan Hansknecht (Jul 19 2024 at 00:06):

Specifically, dynamically loading different roc applications at runtime is more complex.

How most platforms work today, they are statically linked with the roc app to generate a single executable. So that is what most examples (like basic-cli and basic-webserver).

That said, once the api is built out, using via a shared library isn't all that much harder. In a language like rust, you would delegate to the roc to compile the app into a shared library (probably with command). Then you would use libloading to load that shared library. Finally, you would just be calling into the roc app.


Last updated: Jul 06 2025 at 12:14 UTC