Can D "prevents segfaults, and guarantees thread safety"?
Adam D. Ruppe via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Feb 22 20:38:38 PST 2016
On Tuesday, 23 February 2016 at 04:28:14 UTC, mahdi wrote:
> A selling point of Rust language is that it "prevents
> segfaults, and guarantees thread safety". Is there a library in
> D language which provides same features?
The core d runtime (including the garbage collector) does such
things.
GC, when used pervasively, eliminates use-after-free bugs. Array
bounds checking eliminates buffer overflow bugs. Automatic
initialization of variables covers random pointers that way.
Those are the sources of most security problems in C code (though
not most segfaults - null is still there, but null usually isn't
a security problem on desktop and server hardware (idk about
phones)).
.net, Java, D, javascript, python, the list goes on, these
languages all do pretty good jobs at taking care of this class of
bug. It isn't something unique to Rust. (though garbage
collection is typically a major part of the standard solution,
and Rust does that differently, that's why it is interesting, not
that it solves these problems, but that it does it a bit
differently than the accepted mainstream solution.)
Thread safety is a bit trickier but D's use of default
thread-local data tries to attack it too.
The problem with D's solution is too many people recommend
turning them off in the name of performance benchmarks :(
More information about the Digitalmars-d-learn
mailing list