• jas0n@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    5 months ago

    Maybe I’m wrong, but aren’t move semantics mostly to aid with smart pointers and move constructors an optimization to avoid copy constructors? Neither of which exist in c.

    I’m not sure what collection type you’re referring to, but most c programmers would probably agree that polymorphism isn’t a good thing.

    • porgamrer@programming.dev
      link
      fedilink
      arrow-up
      2
      ·
      5 months ago

      That’s what std::move does, and you’re right that it’s quite an ugly hack to deal with C++ legacy mistakes that C doesn’t have.

      I say move semantics to refer to the broader concept, which exists to make manual memory management safer and easier to get right. It’s also a core feature of Rust.

      Also I’m talking about parametric polymorphism, not subtype polymorphism. So I mean things like lists, queues and maps which can be specialised for the element type. That’s what I can’t imagine living without.

      • jas0n@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        5 months ago

        Hahaha. I knew I was wrong about the polymorphism there. You used big words and I’m a grug c programmer =]

        We use those generic containers in c as well. Just, that we roll our own.

        Move semantics in the general idea of ownership I can see more of a use for.

        I would just emphasize that manual memory management really isn’t nearly as scary as it’s made out to be. So, it’s frustrating to see the ridiculous lengths people go to to avoid it at the expense of everything else.

        • porgamrer@programming.dev
          link
          fedilink
          arrow-up
          1
          ·
          5 months ago

          I definitely agree on the last point. Personally I like languages where I can get the compiler to check a lot more of my reasoning, but I still want to be able to use all the memory management techniques that people use in C.

          I remember Jonathan Blow did a fairly rambling stream of consciousness talk on his criticisms of Rust, and it was largely written off as “old man yells at clouds”, but I tried to make sense of what he was saying and eventually realised he had a lot of good points.

          I think it was this one: https://m.youtube.com/watch?v=4t1K66dMhWk