I don't really get the application/platform thing. I've read the docs and asked AI to explain it but I'm still not clear on really what they are or the point. Platforms just seem to mean using another programming language to do the hard bits. Might as well just use those languages to finish it off.
I'd love to understand the point.
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? :)
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
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
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.