Is public by default an unsafe default?

Steven Schveighoffer schveiguy at gmail.com
Wed May 1 14:33:42 UTC 2024


On Wednesday, 1 May 2024 at 11:52:30 UTC, NotYouAgain wrote:

> Question 1 - is 'public by default' a sensible default for a 
> language that is aiming to be safe by default?

Yes, it's sensible.

People most of the time want to use the things they write by 
default, and so having members be public by default is what 
people would expect.

It becomes an annoyance for the developer in languages when you 
forget the "public" equivalent, and have to go back and add it. 
I've experienced this a lot with Angular/Typescript.

I can understand the counterpoint, that you may want to start 
from a point of view of exposing the least amount of "set in 
stone" API. But not everyone is on that ship.

I don't see how public by default affects memory safety.

-Steve


More information about the Digitalmars-d mailing list