• xmunk
    link
    fedilink
    arrow-up
    52
    ·
    1 year ago

    C++ the good parts exclusively uses on stack allocation and passing by const reference without ever introducing pointers.

    You know this to be true.

      • Dudewitbow@lemmy.zip
        link
        fedilink
        arrow-up
        16
        arrow-down
        1
        ·
        1 year ago

        Because its essential for application use where memory management becomes extremely vital, usually due to the rom or memory to be extremely linited in size. Worrying about memory management (something C++ makes mandatory) is something not all programmers need to care about, but having automated memory mangement is also what causes bloat that comes with modern applications, due to bad programming practices of not caring about it.

          • Dudewitbow@lemmy.zip
            link
            fedilink
            arrow-up
            1
            ·
            edit-2
            1 year ago

            When you ever call new/malloc, its mandatory(dynamic allocation). For general programming, the size is usually decided at compilation.

            Yes destructors will unallocate the memory, but the process of writing the destructor is part of the task of memory management

            It becomes madness if you attempt to call dynamic memory outside of a class and its destructor, and hopefully the dev actually remembers to release said memory when their done.

      • xmunk
        link
        fedilink
        arrow-up
        11
        ·
        1 year ago

        I tried to get that reference, but MemoryAccessOutOfBounds.

      • xmunk
        link
        fedilink
        arrow-up
        3
        arrow-down
        1
        ·
        1 year ago

        Also Qt basically forces you into this mode… and yea, it is a better way.

    • marcos@lemmy.world
      link
      fedilink
      arrow-up
      4
      ·
      1 year ago

      Only integral unsigned numbers, no reference taking at all, no side-effect operators…