Unofficial Hacker News client - receive Push Notifications on replies.

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

296 points by DrDeadCrash 5 hours ago | rtfeldman.com | 54 comments on HN | Vote on HN (opens Hacker News)

Comments (54)

  1. I'm the developer behind the screenwriting software mentioned in the post.

    Roc has been so pleasant to use considered it's still so early.

    I've read elsewhere a comment by Richard where he said that naive programming in Roc should result in fast code. That is very true. I basically enforce software design and architecture that allow for speed, and I don't have to worry about finagling the language into running fast.

    It's very well thought out.

    As a result Bliss Writer is correct and stable software, even in beta. I have a large suite of E2E tests that spin up a real TUI and they almost never fail.

    Who knew you could have the correctness of FP and speed.

  2. Congratulations. Lots in there for a 0.1! I hope Roc gathers serious momentum.
  3. Roc seems to have a pretty good version of error handling I've seen so far: https://roc-lang.org/docs/main/langref/errors/

    Basically you can handle the errors you want to handle and propagate everything else upstream because the error value is a union of all propagated errors. In other (typed) languages you either need to handle all errors or map the different types into a single one.

    Replies (2)
    1. Have a look at the eros crate for rust. It implements a convenient error set mechanism mostly without macros
    2. No recovery / restarts though.
  4. Unrelated to Rocq (https://rocq-prover.org/), formerly named Coq.
    Replies (1)
    1. This is kind of unfortunate for Roc because they were using the name first. But Rocq is a much bigger project so the mindshare is with them.
      Replies (1)
      1. On the other hand, seems to me like theorem provers that aren’t called ”Lean” are having a pretty rough go of it as well.
        Replies (1)
        1. Hard to say. Lean has its moment right now in mathematics, but Rocq grows in verified software space thanks to early industrial success with a verified C compiler, OS kernel, etc. that received certifications for automotive. Iris - a Rocq framework for proving concurrent code - really blew up in recent years, too.

          And it’s not a Zero-sum game: multiple languages for theorem proving and software verification can blossom and grow the overall field together. To me it seems like Rocq, TLA+, and Lean have very bright future.

  5. Looks neat, it checks basically every box for desirable features from modern languages all in one. What about the age old question of function colouring? Whats the async story here, and between that and effectful functions, are you not setting yourself up for potentially 4 different colours? It seems like the effect functions would be likely to infect everything all the way up in a lot of different types of programs. But maybe there’s a more structural solution to that that I’m not aware of after just a glance.
    Replies (1)
    1. The short answer is that it's like Go - Roc's effectful functions can be "silently nonblocking," so they can have the runtime characteristics of async without having to label functions as async (or call them with await).

      That's why both Go and Roc are able to be competitive with languages that have async/await on webserver throughput benchmarks!

      Replies (1)
      1. Very interesting. In practice, I wonder if most platforms will end up implementing some kind of async data structure to represent a deferred result? How have platforms generally approached this so far?

        I think this question about how async/deferred results are handled will be a common one, and it was surprisingly hard to find any info about it in the docs. Maybe worth adding in a more obvious place?

        The Platform concept feels incredibly powerful, but it feels like the Roc API each platform creates will be core to the ergonomics of using the language. Might be helpful to include docs from some of the most common platforms you expect folks to use to understand the end-to-end picture. The Stdout examples were helpful but I'd be curious to see others with more complexity.

  6. Maybe I should check this out for Advent of Code this year, would be fun to compare against Haskell which I usually use.
    Replies (2)
    1. Awesome! There's an Advent of Code thread going on Roc Zulip with beginner advice that may be helpful:

      https://roc.zulipchat.com/#narrow/channel/358903-advent-of-c...

    2. Same! I was thinking this is perfectly timed for Advent of Code.
  7. create a new language but keeping the pipe characters, is a mystery to me
    Replies (1)
    1. I haven't been programming in Elm for a few years now (for unfortunate reasons), but I still use the pipe operators (and TEA).
  8. Why there are no managed typed effects? Only naming functions by convention
    Replies (1)
    1. Replies (1)
      1. I mean typed algebraic effects. They are not tracked in types. I don't see how you can define a custom effect, you have only pure and not pure functions, how to type a specific side effect?
  9. Briefly hoped this was https://roc-streaming.org/
  10. Reminds me a lot of Elixir actually, which I really enjoyed but was, in the end, not fast enough.

    The syntax looks friendly.

    Does it have multiple dispatch for functions based on arguments? I always loved how easy that was to do in Haskell and Erlang/Elixir, and missed it in languages like Clojure.

    Replies (1)
    1. >missed it in languages like Clojure

      I'm not sure about Haskell and Erlang/Elixir since I haven't used them much, but aren't multimethods the Clojure solution for this?

      Replies (1)
      1. Not really, what Haskell / Erlang offer is that you can do pattern matching in the function signature.

        So you can, say, have a definition for when the value of n is 0, n is 1, etc.

        This is a nice example in Haskell:

           compress :: Eq a => [a] -> [a]
           compress [] = []
           compress [x] = [x]
           compress (x:ys@(y:_))
             | x == y    = compress ys
             | otherwise = x : compress ys
        
        Basically it enables you to use recursion more elegantly because the pattern matching is folded into the function signature.
        Replies (2)
        1. So, for the sake of pedantry, in the programming language world "multiple dispatch" (and "[dynamic] dispatch" in general) typically refers to late binding - the function that's called is determined at runtime, and the caller doesn't actually need to know about the implementation being called.

          What Haskell is doing there is basically just a kind of syntactic sugar around a pattern match, which is (to a very rough approximation) basically a super-powerful switch. Like a switch, the compress function knows about all of the branches statically, even if at runtime it dynamically selects which branch to take based on the structure of its arguments. And the structure of its arguments is "closed": it knows at compile-time all the different forms they can take.

          Haskell achieves dynamic dispatch through typeclasses, and it can do multiple dispatch with the MultiParamTypeClasses extension. With these a caller doesn't need to know about the implementation it's invoking, and it doesn't need to know in advance anything about the possible values of its arguments beyond that they have an implementation that can be used - typeclasses are open, you can always define new implementations without updating every caller that uses them.

          Replies (1)
          1. I agree with that, I tried to look for the correct term to describe this but the best thing I could find was multiple dispatch.

            It's not just Haskell, though. Like I said, Erlang/Elixer also support this, and it enables writing some really elegant code.

        2. I think you can do this in Clojure:

            (defn greet
              ([] "Hello!")
              ([name] (str "Hello, " name "!"))
              ([name title] (str "Hello, " title " " name "!")))
          
          Which one could argue is cleaner for multiple arguments, but you can't pattern match on arguments themselves this way (but you can using multimethod)
  11. The timing of this is interesting to me. I have always been a fan of Elm.

    I have been building an app platform on top of Rust for a few months, and have run into a series of problems and I sometimes wish I could use something more purely functional such as this. It offers a lot of guarantees that I want such as memory safety and side-effect-free code, and have had to try and build myself (probably poorly) in my own thing.

    I am also glad to see to see that this language has addressed native code in a more robust way than Elm https://www.roc-lang.org/docs/main/langref/platforms/

    Looking forward to trying this out and congrats to Evan and team on the release

    Replies (1)
    1. > Looking forward to trying this out and congrats to Evan and team on the release

      You probably meant "congrats to Richard" who is Roc's BDFN (Benevolent Dictator for Now) https://www.roc-lang.org/bdfn

      I'm pretty sure the BDFL of elm did not contribute to Roc.

  12. I'm still pretty upset about Elm, and I'm not sure if that means I should avoid Roc or give Roc a try.
    Replies (1)
    1. I guess it would depend why you're upset?

      If it's the personality cult, the banning, the gaslighting, and the double standards? Then I would be hesitant about Roc since Feldman was doing a lot of the gaslighting and double standards.

      If it was that it was that it's super dead, then Roc looks more promising. By a lot.

      Replies (1)
      1. Pretty bold claims, so, citation needed
        Replies (3)
        1. The trick with banning and deleting comments is that you get rid of the evidence.
        2. For those of us who witnessed that mess, no citation is necessary. I wish Roc all the best, but I’m not touching anything that comes from the people in Elm’s inner circle anymore. At least not until it has been made unmistakably and credibly clear that a change in mindset has taken place.

          The downvotes speak for themselves! :-D

        3. https://lukeplant.me.uk/blog/posts/why-im-leaving-elm/ is a long one. https://news.ycombinator.com/item?id=34746161 has a few stories https://news.ycombinator.com/item?id=22823074 https://news.ycombinator.com/item?id=48804546 https://news.ycombinator.com/item?id=17843149

          There's more, you can just google "elm cult".

          I was personally banned without warning by a rule they made up to specifically target me after the fact. A rule which 100% applies to Feldman, but he was in the inner circle so obviously that rule didn't apply to him. It's still the only rule they explicitly have written down actually.

  13. rich is a nice guy. language makers called rich are nice people.

    elm is where I learnt functional programming - concepts were easier to grasp for someone like me compared to oop.

    sadly now with llms the art of programming languages might be forgotten since llms now write all the code n review it :(

    Replies (2)
    1. > sadly now with llms the art of programming languages might be forgotten since llms now write all the code

      I've noticed that e.g. people who were JS devs before LLMs continue writing code in JS. Or Python in Python, and so on.

      My experience with LLMs has been there's a vast difference between driving an LLM in a context you're familiar with, and an unfamiliar context. -- I can get an LLM to give me something pretty good if I know what to ask for, but I can only get an LLM to give me something okay-ish if I'm unfamiliar.

      I tend to think programming languages & arguments will continue to matter just as much.

      > [and LLMs do all the] review it :(

      "LLMs are so strong that you won't need to read the code" I think this still allows that there should still be value in reading code.

      I tend to think: an LLM is going to work more efficiently when the codebase is well organised compared to if it's disorganised.

      I think that's more likely than, for example, "LLMs will be so good at coding, but only in a way that they produce unreadable spaghetti code that you can't understand". -- Surely if LLMs are so proficient at coding that you don't need to read the code, the LLM can also make the code easy to understand.

    2. more like the art of programming languages for humans has less focus. I certainly see an uptick in work on programming languages for AI/agents.
  14. Kind of love the fact that Roc is fast,memory safe and compiles really fast.

    This sort of combination is probably gonna take some developers. I have definitely heard of rust's compile time speed being a bottleneck in many aspects.

    I want to know how to build cross-platform (preferably android,iOS as well with the normal linux,macOS and windows)applications with roc.

    I just want something where I can easily and fastly iterate upon creating cross-platform applications. Waiting for rust to finish was a real issue that I sort of observed during one of my tinkering experiments.

    Another thing that I am thinking right now is one Hackernews comment[0] that I had seen sometime ago which talked about having an android application (I think written in python), and they can basically change the code live and it will automatically reflect. I imagine that if roc is fast-enough, some sort of live development system could also be created.

    Overall, I think that if AI can rewrite code or start writing code from scratch in almost any language good enough, then there are lots of experiments which can be conducted at scale which previously were not so feasible. Though one might ask what's the point as to the rewrite, I think that some of the features roc provides could be interesting to many sort of projects.

    Also the language just looks elegant to me and more approachable than rust and C/C++ (from my first glance), so kudos for making a fast (functional) language which looks like something that I want to use myself!

    [0]: https://news.ycombinator.com/item?id=50678306

    Replies (1)
    1. > I want to know how to build cross-platform (preferably android,iOS as well with the normal linux,macOS and windows) applications with roc.

      This is mediated by the Roc platform (i.e. app framework) and as for mechanics it works the same way the platform host language would work. I do have a Roc GUI platform written in Rust running on mac and android but it's built using just the OS drawing/input APIs and not using the rest of the platform's GUI stack so in practice they work closer to web apps with native performance/overhead. I've leaned into this so the apps are Elm Architecture, the styling is very similar to Tailwind, and things are generally web-app shaped. The LLMs are pretty good at web apps so the process of bringing up a new app is pretty straightforward.

  15. morphic teams papers https://morphic-lang.org/publications.html in case people are curious about roc influences
  16. 1. Do LLMs write it well?

    2. What are the suggested substitutes for OOP idioms like interfaces?

  17. I've been following Roc quite closely while I build (EYG lang) another functional language for my own use. I'm super impressed with the performance results they share. I thought that would be a distraction while developing. And maybe it was as it took 8 years. I don't love the result of purity tracking rather than a full effect system. I was quite enamored with proper effect tracking and have labeled effects in EYG. I think my holiday hacking might have to be try something real in Roc and see if I learn to love this approach to effects
  18. There is a special place in my heart for people who work on hard software tech such as programming languages. Especially in times of AI and slopification.
    Replies (2)
    1. In some ways it’s never been a better time to launch a new programming language. LLMs make adoption much more about developer preferences than familiarity. LLMs can help with the learning curve of new language paradigms. And they greatly de-risk the long term costs of picking the wrong language given their facility with rewriting.

      I think new languages have more freedom than ever to be bold and take risks. We are not nearly so confined by culture or technical debt as we used to be and freedom to experiment has probably never been better.

      Replies (1)
      1. Why would you care about which language you're using if you don't care to get familiar with it?
        Replies (2)
        1. What if you DO care but you couldn’t get the thumbs up from the team before because “what if we end up having to rewrite?”

          I’m saying the opportunity cost of trying new languages has never been lower.

        2. the language, and the ecosystem of tooling and packages, you choose for a project will have a massive influence on the outcome.

          all languages excel at something to the detriment of something else, no language can be good at everything.

          the language also defines the terms for which you can reason about a problem.

          even if you're not writing it, you're (hopefully) still reading it.

          There's a good reason we're not writing web servers in assembly or SQL.

          Replies (1)
          1. And this language has more mature tooling and a larger base of packages? And while I avoid LLMs unless I'm paid a shitload of money to deal with them, it's obvious none of my coworkers read their generated code; as LLMs get better, this obviously expands.
    2. This is, by now, fully being written by AI. If you're not interested in slop, you may want to look elsewhere.
  19. Sad this is probably one of the last projects we’ll see that are handcrafted and made with love instead of machines…
    Replies (1)
    1. Nah, there are still dozens of us still making things by hand because we enjoy it!

      I imagine there is a similar corollary where hobbyist woodworking didn't go away with the advent of assembly-line manufacturing.

  20. I have been keeping an eye on this language. Maybe it's time to dive into it and give it a proper try. Any recommendations for good learning resources?
  21. Been following Roc for awhile and really love a lot of the concepts (like Platforms). Got a bit nervous they were losing the thread when they went for a big rewrite, but it looks like it’s panning out!