upvote
Platforms serve roughly the same role as a framework in another language with the difference being that a Roc platform must provide all side effects and therefore tends to include things that would be standard library elsewhere. In one of his talks, Richard mentioned that a starting point for the language design was typed, functional Lua and that motivation shows up in the platform concept.

The main advantage it provides is restrictions. Roc cannot perform any side effects outside the ones provided by the platform and has no provision for unsafe behavior. This allows for very aggressive inlining at the language level which winds up being pretty close to what I've done with macros and compile time programming in other languages. In terms of system design, you can know that the app code can't break the abstraction boundary and design accordingly. I made an experimental web platform that had full and automatic cache invalidation which worked off a combination of sqlx-style compile time inspection of queries combined with SQLite's security hook callbacks and I never would have done the design without having to deal with platform design. Neither of these are doable if the entire thing is in Rust.

reply
Platforms are what give you all of the effectful functions you need. It could be a "webserver platform" which lets you answer web requests and talk to a database, or it could be a "TUI platform" which lets you read keyboard input etc. Without a platform you'd just have pure functions, because unlike many other languages, Roc doesn't offer any effectful functions in its std lib. My mind was blown when I realized that! :'D

Another way to look at it is a practical comparison: JavaScript is a language, but it needs to run on something. If you run it in the browser, you get access to browser APIs. If you run it on the server with Node/Deno/Bun you get different APIs that are useful for web servers. In that scenario, the browser or Node/Deno/Bun is the platform.

The example above isn't apples-to-apples, but it's a good way to visualize the difference!

Does that help? :)

reply
Somewhat, but it's the fact it doesn't really cut it. Because this could be similar to say the java VM, except the VM has a much bigger scope than a roc platform.

To me it just seems like roc can't function without other languages to make them useful.

Please don't take this on a bad way I'm just unable to describe it better.

reply
Yeah, I mean, that's just factually true! No harm in that :)

Roc needs a platform written in another language, but you as a Roc author don't have to read or write that language. You don't even need to know which language a platform is written in.

Someone else (like me!) writes a platform, shares it, and you use it. That means you get whatever platform you want: maybe with the concurrency of Go? Or the performance of Zig? Or the memory safety of Rust? And the platform can give you access to their entire ecosystem. All that with no effort on your part, and you get to read and write only Roc. Sweet deal, right? ;D

reply
Yeah I don't know, there's a lot of trust there though. It just feels weird to me that roc can't run without something written in another language. How do you debug it is the fault lies in the platform, written in a language you don't know? It also seems to say purely functional languages can't do much without a none functional layer. Maybe I'm still not understanding.

Maybe it's just something I need to get used to.

Thanks for taking the time to explain though. If you're the guy that created the joy web framework (platform?) for roc, then I watched and enjoyed your talk about it.

reply
>It also seems to say purely functional languages can't do much without a none functional layer.

Well, you could write your platform in a functional language :) What it is saying is that separating pure vs. effectful/impure comes with some nice benefits, and we're seeing that in the platforms concept. I think if you try it you may see it differently :)

>If you're the guy that created the joy web framework (platform?) for roc, then I watched and enjoyed your talk about it.

Yeah, that's me! Thank you so much! PS. I call it a "framework" just because it spans more than one platform. Not really an important :P

reply
My understanding is the idea is that Roc is safer/more pleasant to use than the language you'd right the platform is. Also you could just use someone else's platform.

Someone in this thread described it an app framework that provides the IO primitives.

I have not used Roc at all just my impression of what's going on

reply
With a platform, your application code remains pure functional, while a minimal imperative shell can be understood and maintained separately

Using zig or rust or something you lose the roc specific features of a high performance pure functional language

Much better than FFI where usage is not tracked in the type system

reply
I think my main point is that to use roc for anything I need to know roc and a second language. Or import the functionality written in that secondary language. I'm aware that you do this with other languages, pandas and numpy aren't written in python, I really just don't get why rocs way is better...
reply
>I think my main point is that to use roc for anything I need to know roc and a second language

You could just pick up Roc, pick a platform, and start writing Roc right away without knowing any other language :) There are already a number of platforms to use for CLI apps, web servers, web apps, native GUIs etc.

However, if you want to write your own platform you can. That's a great power to be able to reach for if you want to but it's not typical.

Going back to the JavaScript example: most JS developers just pick a platform, like Bun, and start writing JS. In the same way, you'd pick a Roc platform and start writing Roc.

Sure, if Bun wasn't good enough the JS dev may write their own platform (Bum? :P), and then they'd need a second language. That's the same thing you could do in Roc if you wanted a custom platform :)

reply