Unofficial Hacker News companion — get notified on comment replies, and more.

Roc version 0.1.0, eight years in the making (opens external site)

485 points by DrDeadCrash 3 days ago | rtfeldman.com | 134 comments on HN | Vote on HN (opens Hacker News) |

View full thread · View on Hacker News

Comment thread (15)

  1. 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.

    Replies (5)
    1. 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

      Replies (1)
      1. 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...
        Replies (2)
        1. >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 :)

        2. > I think my main point is that to use roc for anything I need to know roc and a second language.

          You can't: print("Hello") without a kernel, drivers and libc - doesn't mean python or ruby are useless languages.

    2. 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

    3. 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? :)

      Replies (1)
      1. 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.

        Replies (1)
        1. 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

          Replies (1)
          1. 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.

            Replies (3)
            1. >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

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

              Exactly. At some point, your pure FP code has to hand off a description of some effect (open this file, make this network request, write to std out), otherwise all it can do is maybe heat up your computer.

            3. Most if not all of programming languages you have used recently can't run without a C "platform", ie most of them ultimately link to the C stdlib.
    4. 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.

    5. AFAIK there's two things.

      1. The platform defines what effects your code can run. For certain use cases, it makes sense to have some but not the other. For example, a terminal app, a GUI, and a webserver need different primitives. Same with powering a UI for a smart fridge VS embedding into a text editor.

      2. Most high level languages "drop down" to systems languages like C/C++ already, for example, Python.

      > Might as well just use those languages to finish it off.

      Different languages give you different things. Most people wouldn't want to write their entire app in C, for all the obvious reasons. Think about the Apache web server approach - it's a fast server written at the systems level, but passes the final piece off to whatever language you want. You can use a higher level language here for your business logic, without sacrificing all the speed.

      At the end of the day, everything has to drop down to assembly to make a syscall, but that doesn't mean you want to write your whole app in assembly.