Blog post: What D got wrong

Russel Winder russel at winder.org.uk
Wed Dec 19 06:41:33 UTC 2018


On Wed, 2018-12-19 at 01:45 +0000, Neia Neutuladh via Digitalmars-d-announce
wrote:
> On Wed, 19 Dec 2018 01:04:24 +0000, Nathan S. wrote:
> > On Saturday, 15 December 2018 at 19:53:06 UTC, Atila Neves wrote:
> > > Not the case in Rust, not the case in how I write D. TBH it's not such
> > > a big deal because something has to be typed, I just default to const
> > > now anyway instead of auto. @safe and pure though...
> > 
> > I'd be interested in seeing some of that Rust code. My impression from
> > Clojure is that an all-immutable style requires leaning heavily on the
> > garbage collector and as far as I know Rust has none.

Rust is garbage collector free. This is why it is appealing to the C (and C++)
people who think garbage collectors are anathema.

Rust has let and let mut to introduce new bindings and variables respectively,
you have to type less for immutable, which his the right way round. If you
want mutability, you have to say so explicitly. Single assignment rocks. :-)  

> It is greatly simplified by automatic memory management. Rust doesn't have 
> a GC, but it has a complex ownership system instead, and that's the basis 
> of its memory management. When that's insufficient, you use reference 
> counting.

With Rust (as with most languages) you have to separate stack and heap
allocation. The Rust borrow checker carefully tracks all stack usage and
(caveat unsafe activity) will not compile code that has any memory problems
that the borrow checker can find. For the heap, Rust provides reference
counted pointers which work a lot better than the equivalents in C++:
std::shared_ptr and std::unique_ptr can be a right pain. Also of course,
unlike C++, Rust has very good support for multi-threading in the language and
the standard library, mostly built around std::Mutex. Rust integrates all this
with std::Option, std::Error, if let, and match in a way that makes dealing
with locks and RAII quite simple. C++ may have brought RAII to mainstream
programming, but it's support for multiple threads is still very weak comparedto D, Rust, Go, etc.  

[…]

--
Russel.
===========================================
Dr Russel Winder      t: +44 20 7585 2200
41 Buckmaster Road    m: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-announce/attachments/20181219/f02f3140/attachment.sig>


More information about the Digitalmars-d-announce mailing list