Safety, undefined behavior, @safe, @trusted

Walter Bright newshound1 at digitalmars.com
Sat Nov 7 17:24:51 PST 2009


grauzone wrote:
> Because the bytecode language is much smaller than a high level language 
> like D, it's easier for Java.

I don't agree that has anything to do with it. The VM is compiled down 
to the same old CPU instructions that D is compiled to. What matters is 
the semantics.

> Also, Java was planned to be safe right 
> from the beginning, while SafeD is a rather unnatural feature added on 
> the top of a complex existing language. To make it safe, you need to 
> forbid a set of features, which inconveniences the programmer and will 
> possibly reduce code efficiency. I'm not even opposed to the idea of 
> SafeD, I'm just worrying that forcing all D code to adhere to SafeD by 
> default will cause more trouble than gain.

Only time will tell, of course, but D has a lot of inherently safe 
constructs (such as length-delimited arrays) that obviate most of the 
need for manipulating pointers.

C++ users have also discovered that if they stick to writing in certain 
ways and using the STL, their programs are memory safe. The problem with 
C++ is, once again, this is by convention and is not checkable by the 
compiler.



More information about the Digitalmars-d mailing list