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?

  • @sacredbirdman
    link
    3
    edit-2
    2 years ago

    And here’s one that defaults to nothing but involves less typing:

    public:
        F1()
        F2()
    private:
        H1()
        H2()
        H3()
        H4()
        H5()
        H6()
        H7()
        H8()
        H9()
    

    It’s quite easy to awk public functions from that too.

    • @ttmrichter
      link
      12 years ago

      That’s not bad, but for the fact that the part that tells you which is public and which is private is long-removed from the declaration/definition. I wouldn’t hate this, but it’s not my favourite. Personally I just don’t really grok any “characters typed” arguments. If you’re doing software right you read a whole lot more often than write, and anything that makes reading easier is better, IMO.

      • @sacredbirdman
        link
        12 years ago

        I’m a bit confused… I thought you just said that your second example involved more typing. Anyway, I don’t care much for that characters typed argument either… but I do care about readability and “noisy” syntax or repetition tends to make reading/skimming harder.

        • @ttmrichter
          link
          12 years ago

          Oh, that’s because I saw other responses that were already talking the typing shibboleth. I should have made that clearer. My bad.