I don’t think that casting a range of bits as some other arbitrary type “is a bug nobody sees coming”.

C++ compilers also warn you that this is likely an issue and will fail to compile if configured to do so. But it will let you do it if you really want to.

That’s why I love C++

  • UnfortunateShort@lemmy.world
    link
    fedilink
    English
    arrow-up
    24
    arrow-down
    3
    ·
    edit-2
    16 hours ago

    I used to love C++ until I learned Rust. Now I think it is obnoxious, because even if you write modern C++, without raw pointers, casting and the like, you will be constantly questioning whether you do stuff right. The spec is just way too complicated at this point and it can only get worse, unless they choose to break backwards compatibility and throw out the pre C++11 bullshit

    • mobotsar@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      13
      ·
      15 hours ago

      Depending on what I’m doing, sometimes rust will annoy me just as much. Often I’m doing something I know is definitely right, but I have to go through so much ceremony to get it to work in rust. The most commonly annoying example I can think of is trying to mutually borrow two distinct fields of a struct at the same time. You can’t do it. It’s the worst.

    • Zacryon@feddit.org
      link
      fedilink
      arrow-up
      1
      ·
      9 hours ago

      I suppose it’s a matter of experience and practise. The more you wotk with it the better you get. As usual with all things one can learn.

      • sexual_tomato@lemmy.dbzer0.com
        link
        fedilink
        arrow-up
        1
        ·
        4 hours ago

        The question becomes, then, if I spend 5 years learning and mastering C++ versus rust, which one is going to help me produce a better product in the end?