Is public by default an unsafe default?
NotYouAgain
NotYouAgain at gmail.com
Thu May 2 23:56:19 UTC 2024
On Thursday, 2 May 2024 at 19:49:40 UTC, Sergey wrote:
> On Wednesday, 1 May 2024 at 23:38:05 UTC, NotYouAgain wrote:
>> C++, C#, and Rust are private by default, and I thoroughly
>> enjoy using them.
>
> Did this help them to be protected from atackers?
> Do you have this kind of information?
a private attribute provides a mechanism for a type to be
type-safe. Static assumptions can then be made and enforced by
the compiler.
private is clearly a good thing in that context. I don't think
one can argue it is a bad thing, in that context.
private by default is a good thing also. Your already developing
your type in a type-safe manner from the get-go. Again, I don't
think one can argue that is a bad thing, in this context.
unless of course, type-safety is not your thing ...it certainly
is not in C (a language that D so strongly aligns itself to).
But in large, industrial-strength applications being worked on by
multiple teams, I guarantee that enforcment of a type-safe
language becomes a strategic decision (i.e. it's not decided on
whether programmers like type safe programming, or not).
So yes, private and private-by-default are matters related to
type-safety, and type-safety are matters to safe use of software.
So is public by default an unsafe default? Well in the context of
the above, of course it is.
More information about the Digitalmars-d
mailing list