Rant after trying Rust a bit
ponce via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jul 22 23:46:12 PDT 2015
I've not used Rust, but don't plan to.
On Wednesday, 22 July 2015 at 18:47:33 UTC, simendsjo wrote:
> While code.dlang.org has 530 packages, crates.io has 2610
> packages,
I think this tells something foremost about the size of the
community. More people leads to more code.
> Traits
> ------
> I think the ability to express an interface without buying into
> inheritance is the right move. The alternative in D is
> specifying the behavior as a template and verifying the
> contract in a unittest for the type.
Traits can't do Design by Introspection aka compile-time duck.
C++ can on the other hand.
> Algebraic data types
> --------------------
> Haven't looked into `Algebraic!`, so I won't start bashing D
> here :) But given the lack of pattern matching, I doubt it will
> be as pretty as Rust.
You can pattern-match with visit.
> Macros
> ------
> I haven't written more than extremely simple macros in Rust,
> but having macros that is possible for tools to understand is a
> win. Templates and string mixins is often used for this
> purpose, but trying to build tools when string mixins exists is
> probably extremely hard. If D had hygenic macros, I expect
> several features could be expressed with this instead of string
> mixins, making tooling easier to implement.
There is a difference though: Rust forces macros on you on the
get go, while in D string mixing are quite a rare occurence
thanks to other meta things and don't have a weird separate
syntax. Regular templates + tuple foreach + static if is just
easier to debug.
> Borrowing
> ---------
> This is probably the big thing that makes Rust really
> different. Everything is a resource, and resources have an
> owner and a lifetime. As a part of this, you can either have
> multiple aliases with read-only references, or a single
> reference with a writeable reference. I won't say I have a lot
> of experience with this, but it seems like it's not an
> extremely unergonomic trade-off. I cannot even remotely imagine
> the amount of possible compiler optimizations possible with
> this feature.
The problem I see with this is that it is exactly like C++ scoped
ownership except enforced. Even in Rust meeting they said they
were converging on C++. It remotely feels like the same language
to me.
I've worked in fully scoped ownership codebases, it's very nice
and consistent, and you don't feel like you would need anything
else while doing it. You must train everyone to do it. Enforcing
it in the language? I'm not sure about this. There are time where
you debug and you have to comment stuff out wildly.
Also if you are going to replace C++, it is a given to at least
compile faster, make solve problem #1.
More information about the Digitalmars-d
mailing list