Rue: Higher level than Rust, lower level than Go

(rue-lang.dev)

68 points | by ingve 3 hours ago

9 comments

  • killingtime74 2 hours ago
    I always thought of Go as low level and Rust as high level. Go has a lot of verbosity as a "better C" with GC. Rust has low level control but many functional inspired abstractions. Just try writing iteration or error handling in either one to see.
    • gpm 1 hour ago
      I wonder if it's useful to think of this as go is low type-system-complexity and rust is high type-system-complexity. Where type system complexity entails a tradeoff between the complexity of the language and how powerful the language is in allowing you to define abstractions.

      As an independent axis from close to the underlying machine/far away from the underlying machine (whether virtual like wasm or real like a systemv x86_64 abi), which describes how closely the language lets you interact with the environment it runs in/how much it abstracts that environment away in order to provide abstractions.

      Rust lives in high type system complexity and close to the underlying machine environment. Go is low type system complexity and (relative to rust) far from the underlying machine.

      • steveklabnik 14 minutes ago
        I think this is insightful! I'm going to ponder it, thank you. I think it may gesture towards what I'm trying to get at.
    • steveklabnik 2 hours ago
      Rue author here, yeah I'm not the hugest fan of "low level vs high level" framing myself, because there are multiple valid ways of interpreting it. As you yourself demonstrate!

      As some of the larger design decisions come into place, I'll find a better way of describing it. Mostly, I am not really trying to compete with C/C++/Rust on speed, but I'm not going to add a GC either. So I'm somewhere in there.

      • written-beyond 1 hour ago
        How very so humble of you to not mention being one of the primary authors behind TRPL book. Steve you're a gem to the world of computing. Always considered you the J. Kenji of the Rust world. Seems like a great project let's see where it goes!
        • steveklabnik 1 hour ago
          That is a very kind thing to say, I admire him quite a bit. Thank you!
      • manaskarekar 1 hour ago
        Since it's framed as 'in between' Rust and Go, is it trying to target an intersection of both languages' use-cases?
        • steveklabnik 1 hour ago
          I don't think you'd want to write an operating system in Rue. I may not include an "unsafe" concept, and will probably require a runtime. So that's some areas where Rust will make more sense.

          As for Go... I dunno. Go has a strong vision around concurrency, and I just don't have one yet. We'll see.

      • killingtime74 45 minutes ago
        Wow didn't realise it was you who was the author. I learnt a lot about Rust from your writings.
    • josephg 46 minutes ago
      Yep. This was the biggest thing that turned me off Go. I ported the same little program (some text based operational transform code) to a bunch of languages - JS (+ typescript), C, rust, Go, python, etc. Then compared the experience. How were they to use? How long did the programs end up being? How fast did they run?

      I did C and typescript first. At the time, my C implementation ran about 20x faster than typescript. But the typescript code was only 2/3rds as many lines and much easier to code up. (JS & TS have gotten much faster since then thanks to improvements in V8).

      Rust was the best of all worlds - the code was small, simple and easy to code up like typescript. And it ran just as fast as C. Go was the worst - it was annoying to program (due to a lack of enums). It was horribly verbose. And it still ran slower than rust and C at runtime.

      I understand why Go exists. But I can't think of any reason I'd ever use it.

      • wswin 27 minutes ago
        Rust gets harder with codebase size, because of borrow checker. Not to mention most of the communication libraries decided to be async only, which adds another layer of complexity.
        • gpm 14 minutes ago
          I strongly disagree with this take. The borrow checker, and rust in general, keeps reasoning extremely local. It's one of the languages where I've found that difficulty grows the least with codebase size, not the most.

          The borrow checker does make some tasks more complex, without a doubt, because it makes it difficult to express something that might be natural in C (things including self referential data structures, for instance). But the extra complexity is generally well scoped to one small component that runs into a constraint, not to the project at large. You work around the constraint locally, and you end up with a public (to the component) API which is as well defined and as clean (and often better defined and cleaner because rust forces you to do so).

      • andrewmcwatters 32 minutes ago
        [dead]
    • batisteo 1 hour ago
      C was designed as a high level language and stayed so for decades
  • lifis 59 minutes ago
    All the Rue code in the manual seems to also be valid Rust code, except for the @-prefixed intrinsics
    • steveklabnik 54 minutes ago
      Yes, I started off with the idea that Rue's syntax would be a strict subset of Rust's.

      I may eventually diverge from this, but I like Rust's syntax overall, and I don't want to bikeshed syntax right now, I want to work on semantics + compiler internals. The core syntax of Rust is good enough right now.

      • emerent 33 minutes ago
        How is it a subset then if it has the @-prefix? Wait, does Rust's grammar still have the @ and ~ sigils from the pre 1.0 times for pointers?
        • steveklabnik 17 minutes ago
          It started off that way, but didn't (and won't) remain that way.

          I'm using @ for intrinsics because that's how Zig does it and I like it for similar reasons to how Rust uses ! for macros.

  • andsoitis 3 hours ago
    > Memory Safe

    > No garbage collector, no manual memory management. A work in progress, though.

    I couldn't find an explanation in the docs or elsewhere how Rue approaches this.

    If not GC, is it via:

    a) ARC

    b) Ownership (ala Rust)

    c) some other way?

    • steveklabnik 2 hours ago
      I am playing around with this! I'm mostly interested in something in the space of linear types + mutable value semantics.
      • jasonwatkinspdx 23 minutes ago
        You might find one of my late brother's research interests relevant: https://www.cs.princeton.edu/~dpw/papers/space.pdf
        • steveklabnik 15 minutes ago
          Thank you for the link! I'll check it out for sure.

          (And sorry to hear about your brother's passing.)

      • oulipo2 1 hour ago
        So linear type + mutable value would be quite close to Rust, right?
        • steveklabnik 1 hour ago
          Rust has affine types, not linear. It also doesn't have mutable value semantics, it uses references, lifetimes, and borrowing.
          • EnPissant 1 hour ago
            I've never seen any significant difference in linear vs affine types.

            To me it just seems like Rust has Linear types, and the compiler just inserts some code to destroy your values for you if you don't do it yourself.

            I guess the only difference is that linear types can _force_ you to manually consume a value (not necessarily via drop)? Is that what you are going for?

            • steveklabnik 1 hour ago
              Affine types are "may use" and linear types are "must use," yeah. That is, linear types are stronger.

              See https://faultlore.com/blah/linear-rust/ for a (now pretty old but still pretty relevant, I think) exploration into what linear types would mean for Rust.

      • echelon 2 hours ago
        Nice! I see you're one of (if not the primary) contributor!

        Do you see this as a prototype language, or as something that might evolve into something production grade? What space do you see it fitting into, if so?

        You've been such a huge presence in the Rust space. What lessons do you think Rue will take, and where will it depart?

        I see compile times as a feature - that's certainly nice to see.

        • steveklabnik 2 hours ago
          This is a project between me and Claude, so yeah :)

          It's a fun project for me right now. I want to just explore compiler writing. I'm not 100% sure where it will lead, and if anyone will care or not where it ends up. But it's primarily for me.

          I've described it as "higher than Rust, lower than Go" because I don't want this to be a GC'd language, but I want to focus on ergonomics and compile times. A lot of Rust's design is about being competitive with C and C++, I think by giving up that ultra-performance oriented space, I can make a language that's significantly simpler, but still plenty fast and nice to use.

          We'll see.

          • echelon 22 minutes ago
            Love it! I think that's a nice target.

            Have fun! :)

  • jameskilton 2 hours ago
    Probably best to link to the repo itself, this is not meant to be used yet. https://github.com/rue-language/rue
  • coffeeaddict1 1 hour ago
    How does this differ from Hylo [0]?

    [0] https://hylo-lang.org

    • steveklabnik 1 hour ago
      I am very interested in Hylo! I think they're playing in similar spaces. I'd like to explore mutable value semantics for Rue.

      One huge difference is that Hylo is using LLVM, whereas I'm implementing my own backends. Another is that Hylo seems to know what they want to do with concurrency, whereas I really do not at all right now.

      I think Hylo takes a lot of inspiration from Swift, whereas I take more inspiration from Rust. Swift and Rust are already very similar. So maybe Hylo and Rue will end up like this: sister languages. Or maybe they'll end up differently. I'm not sure! I'm just playing around right now.

  • frizlab 1 hour ago
    How does this compare to Swift?
    • steveklabnik 59 minutes ago
      I don't plan on implementing ARC, I don't think. I do think Swift/Hylo mutable value semantics is a neat idea that I do want to play around with.
  • norir 2 hours ago
    I wince every time I see naive recursive fibonacci as a code example. It is a major turnoff because it hints at a lack of experience with tail call optimization, which I consider a must have for a serious language.
    • stouset 2 hours ago
      Would someone please explain to me why TCO—seemingly alone amongst the gajillions of optimization passes performed by modern compilers—is so singularly important to some people?
      • oersted 2 hours ago
        For people that like functional style and using recursion for everything, TCO is a must. Otherwise there’s no way around imperative loops if you want decent performance and not having to worry about the stack limit.

        Perhaps calling it an “optimization” is misleading. Certainly it makes code faster, but more importantly it’s syntax sugar to translate recursion into loops.

      • Rusky 2 hours ago
        TCO is less of an optimization (which are typically best-effort on the part of the compiler) and more of an actual semantic change that expands the set of valid programs. It's like a new control flow construct that lives alongside `while` loops.
      • aaronblohowiak 2 hours ago
        functional programming background / SICP ?
    • steveklabnik 2 hours ago
      I only have basic constant folding yet in terms of optimizations, but I'm very aware of TCO. I haven't decided if I want to require an annotation to guarantee it like Rust is going to.
    • airstrike 1 hour ago
      "Well you can judge the whole world on the sparkle that you think it lacks.

      Yes, you can stare into the abyss, but it's staring right back"

  • oulipo2 1 hour ago
    Interesting, for me the "between Rust and Go" would be a nice fit for Swift or Zig. I've always quite liked the language design of Swift, it's bad that it didn't really take off that much
    • vips7L 1 minute ago
      Checkout Borgo: https://github.com/borgo-lang/borgo

      I also find that D is good between language. You can do high level or low level whenever you need it.

    • steveklabnik 1 hour ago
      One thing working on this project has already done is give me more appreciation for a lot of Zig's design.

      Zig really aims to be great at things I don't imagine Rue being useful for, though. But there's lots of good stuff there.

      And lots of respect to Swift as well, it and Hylo are also major inspiration for me here.