Memory Safe Programming
GB
gb_897 at gmail.com
Tue Aug 18 00:17:36 UTC 2026
On Monday, 17 August 2026 at 16:21:39 UTC, libxmoc wrote:
> On Sunday, 16 August 2026 at 08:50:38 UTC, GB wrote:
>> It's primarly about memory safety in C, but D gets a mention
>> in the Appendix I.
>>
>> But it raises the question: why isn't @safe not the default in
>> D?
>>
>> https://strawberry9.github.io/the-wrong-memory
>
> Memory safety is best when it is intentionally, forcing it
> everywhere by default usually achieves the opposite of its goal
> by adding unnecessary friction
>
> D shouldn't try to replicate Rust, its real strength is
> ipragmatism, giving the flexibility to opt into safety where it
> matters without imposing it where it doesn't
C: the programmer must maintain the invariant. The result?
See:
https://strawberry9.github.io/the-wrong-memory/Appendix_02.html
D safe subset: the programmer must stay within a subset whose
rules maintain the invariant.
A stronger design: the language's semantics make the invariant
unavoidable, except at explicitly identified escape boundaries.
'Safe by default' is not the same thing as 'safety is a language
property.'
C++ made the mistake of trying to have a 'safe subset' without
making the subset's invariants fundamental to the language
itself. Did D make the same mistake?
More information about the Digitalmars-d
mailing list