Rust and D

bearophile bearophileHUGS at lycos.com
Thu Sep 27 19:00:17 PDT 2012


 From the Reddit thread:

Walter:

> D has the @safe annotation, which prevents unsafe pointer 
> operations.

Rust has a statically enforced borrow/lend management system, and 
other things like memory regions, that make it smarter (and 
probably harder to use).

The Rust type system extends what can be made "safe". On such 
things the Rust type system looks more complex and refined than 
the D type system, so unless the Rust designers have done 
something very wrong (like adding lot of complexity for no gain), 
I expect such type system to give more back, that is not present 
in D.

-------------------------

Abscissa256:

> D has ADT: 
> http://dlang.org/phobos-prerelease/std_variant.html#Algebraic

Algebraic doesn't currently support recursion, and even when it 
does, "having ADTs" means having both a nice way to define them, 
and a good way to de-structure them. D doesn't have pattern 
matching, so the D usage of ADTs is less well supported and less 
good.

I think adding a full featured pattern matching in D is too much 
complex, but I think supporting structs in switch statements (and 
maybe also auto assignment to variables in such case structs) 
adds only a small amount of complexity while giving back a good 
amount of usefulness.

It was discussed a little here:
http://d.puremagic.com/issues/show_bug.cgi?id=596


> Also, D supports manual memory management.

But Rust is designed to work well without a GC, unlike D. Rust 
has several features that make it safer even when you are not 
using a GC. Rust also seems to appreciate stack allocation more 
than D. In D stack-allocated arrays are second class citizens in 
Phobos (and there are no VLAs like Ada, but I don't know if Rust 
has them), and seem generally underused. In D to allocate classes 
on the stack you can't use a native feature of the language, 
while in Rust it's a built-in, and doing this in Rust is safe 
enough.

Bye,
bearophile


More information about the Digitalmars-d mailing list