Comment

Comment by logicchains

If D manages to implement sound borrowing checking this will be huge! Brings it a step closer to matching Rust's feature list.

- Zero-cost abstractions: Yes!

- Move semantics: Yes!

- Guaranteed memory safety: Yes! (in code marked with the appropriate annotations)

- Threads without data races: Yes!

- Trait-based generics: No!

- Pattern matching: No! (Although like C++, in can be done as a library: https://code.dlang.org/packages/sumtype)

- Type inference: Yes! (Plus unlike Rust, you can also mark function return types auto, and let them be inferred too).

- Minimal runtime: Yes! (the GC could be disabled if using exclusively borrow-checked code)

- Efficient C bindings: Yes!

D also brings some features of its own to the table that Rust doesn't yet match.

- Higher-kinded types (template template params): it's possible to implement Haskell-style monads etc. in D, if for some reason you felt the need.

- Pure functions: these allow you to statically guarantee that a piece of code doesn't perform any IO and is a completely deterministic function of its inputs. This makes reasoning about a large codebase much easier, compared to Rust where there's no way to statically guarantee a function isn't doing any IO.

- Fast compile times: the reference DMD compiler is almost as fast as the Go compiler, at least for code that doesn't do a bunch of compile-time calculation.

- Compile-time compute: Rust now has constfn, but that still only supports a limited subset of the language. D allows almost the entire language to be used at compile time.

- Variadic templates: Something C++ users might miss when coming to Rust, they allow for the creation of things like tensors of arbitrary dimension (myTensor<6, 3, 2, 5, 6, 20>) on which operations are checked at compile time to ensure sizes are compatible (so it's a compiler error if you try to multiply two tensors of the wrong size or wrong number of dimensions).

parent logicchains 7 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton