• balsoft@lemmy.ml
    link
    fedilink
    English
    arrow-up
    1
    ·
    5 hours ago

    I agree that they fit different niches! My point was that with modern CPU architectures, imperative languages make it much easier to write fast&efficient code just because the hardware was pretty much engineered with C in mind. IMHO Rust offers the best of both worlds when it comes to systems/low-level dev.

      • balsoft@lemmy.ml
        link
        fedilink
        English
        arrow-up
        1
        ·
        edit-2
        2 hours ago

        Modern C compilers are a fascinating blend of functional and imperative, that’s true; and I didn’t say that C is “close to how the modern architectures work”. However, mainstream modern architectures are almost always engineered with C in mind primarily, and this is also acknowledged in the article you’ve linked. Rust, having a lot of similarities to C in terms of its underlying memory model, calling conventions, and control flow primitives, can often benefit from those hardware patterns and optimizations in a way that’s more difficult to replicate with a functional language (especially so given most of them are GC-d due to their memory model). The closest I’ve seen in terms of easy-to-write-quick-code is OCaml, but even there the fast paths are often written in a very much imperative style. Idris2 also seems promising if they manage to get a GC-less mode working. Maybe also Roc, but I’ve not taken a look at it yet.

        Note that I write all of this as someone spending a lot of their work time programming in a functional language (Haskell), with Rust being mostly for hobby stuff. It just always surprises me how much easier it is to write fast code in Rust, and yet also how much of my Haskell intuition was applicable when I was learning it.

        • ☆ Yσɠƚԋσʂ ☆@lemmy.mlOP
          link
          fedilink
          arrow-up
          1
          ·
          1 hour ago

          Typically this is true, but it’s certainly possible to get comparable performance with functional style. Carp, which I linked above, basically uses the same approach to memory management as Rust. It doesn’t rely on GC.

          I also find that for most cases it really doesn’t matter all that much unless you’re in a specific domain like writing drivers, making a game engine, etc. Computers are plenty fast nowadays, and ergonomics tend to be more important than raw performance.