News for hackers. Stuff that matters.
Re:Ask HN: Why do you make class members private? by blacksoil on Monday July 25, 2022 @02:37PM (#32228949)
-To hide implementation details from users of the library. We don't want to unnecessarily expose functions -Reduce the amount tests, as the private functions wouldn't have to be explicitly tested
Re:Ask HN: Why do you make class members private? by moffkalast on Monday July 25, 2022 @02:39PM (#32228980)
It probably also lets the compiler do more optimizations than it otherwise would've, but that's just a guess and largely compiler dependent.

Outside of library usage though? Mostly counterproductive in my experience.