Basically, would you rather want everything in a class/module/struct/whatever to be inaccessible by anything else unless you give a keyword saying it’s public (like Rust) or have everything accessible unless you make it private (like Ruby and Crystal)? Why?

Also, what do you think of languages that make you write public or private for every member, or ones that inherit the default state from whatever the parent member is?

  • @blank_sl8
    link
    -52 years ago

    Private members should not exist. A language or framework should never prevent you from doing something, just discourage it (eg, by prefixing the name with an underscore)

    • Ephera
      link
      52 years ago

      The point is not to actually prevent you from accessing that member. Most member accesses are within your own code, so you can just edit that private member to be public.

      But by performing this edit, you document that someone is accessing that value from the outside and therefore changing its value can have unexpected consequences.

      This isn’t the case for libraries, because you can’t edit that code quite as easily, but at least personally, I’ve seldomly had enough confidence to just access random values in a library, and you can usually side-step these ‘protections’ by e.g. reflection, if you truly need access.

    • @ttmrichter
      link
      52 years ago

      This kind of attitude is precisely why software is in such a crap state.