| |
| Posted by Jonathan M Davis in reply to Sebastian Nibisz | PermalinkReply |
|
Jonathan M Davis
Posted in reply to Sebastian Nibisz
| On Saturday, July 6, 2024 5:07:32 AM MDT Sebastian Nibisz via Digitalmars-d wrote:
> On Saturday, 6 July 2024 at 00:21:32 UTC, Walter Bright wrote:
> > On 7/5/2024 12:42 PM, Steven Schveighoffer wrote:
> >> Yes, I'm aware. I purposely did not apply `@safe`. D is not a memory safe language, you have to request it.
> >
> > D is memory safe if you type in "safe:" and use the gc.
> >
> > https://dlang.org/spec/memory-safe-d.html
>
> Seriously? Any language is safe in this case, you just need to write safe code.
The point is that D provides checks for memory safety if you choose to enable them. It requires using @safe to explicitly say that you want a piece of code to have those checks done, so the checks are not on by default, but it _does_ provide such checks, whereas a language like C/C++ does not. D has also been designed in a way to try to eliminate a lot of the undefined and unsafe behaviors that you have to be careful to avoid in C/C++. Barring compiler bugs or the programmer screwing up with @trusted, @safe code in D is guaranteed to be memory safe, whereas in C/C++, the language is not designed to avoid memory safety issues, and it's entirely up to the programmer to use the language in a way that doesn't have memory safety problems.
Making @safe the default for D would have the benefit of making it so that you get those memory safety checks by default, but it doesn't actually make the language itself safer. It has the same tools either way.
- Jonathan M Davis
|