D vs Rust
bearophile via Digitalmars-d
digitalmars-d at puremagic.com
Sat Jan 30 12:48:01 PST 2016
Laeeth Isharc:
On Saturday, 30 January 2016 at 16:51:09 UTC, Laeeth Isharc wrote:
> I haven't used Ocaml, but was intrigued by it after seeing
> Yaron Minsky's talks. To what extent can pattern matching,
> strong types with invariants and other things Ocaml features be
> implemented idiomatically in D? Eg I know D has invariants,
> but that seems to be more a debug mode thing, and I am not sure
> if they are doing the same as what Minsky described in his talk.
Rust allows you to write very OCaML-like code, the main
difference is that you need to memory manage manually (and Rust
doesn't have a GIL).
D Algebraic isn't very good, and the D/Phobos pattern matching is
minimal, so to write compiler-like code in D you need a style
quite different from the OcaML/F#/SML/Haskell code. On the other
hand Rust is less flexible, sometimes even C-like for loops are
not handy to do in Rust.
The Servo browser and the Rustc compiler are two of the main
projects written in Rust, so sometimes Rust looks like a
browswer-driven language, and this means Rust developers
sometimes seem to not understand or not care that lot of people
have other different needs. There are several kinds of code that
D allows you to write quite better than Rust (generic application
code, script-like code, explorative scientific numerical code
(like ndslice), medium-integrity code, metaprogramming,
compile-time computations, template-level computations and
specializations, higher order template magic, and so on. In
general Rust seems a more specialized language).
> How productive do you find coding in Ada ?
In Ada you can be productive if you use it for the purposes it
was invented for, but most times you don't write that kind of
code.
I miss some Ada features, and I've missed the strictness of the
Ada compiler that catches lot of bugs, but for most things today
I prefer a more modern languages.
In Ada you need more time to write the code and make it run, but
later you save some debugging time, even compared to D. I like
languages that avoid me most common bugs, even if I need more
time to write it. To write Ada code you need to remember lot of
times, because Ada is a quite large language, but most things are
quite logical and straightforward, so learning Ada is just a
matter of having elephant's memory, you don't need to be smart.
Rust is a much smaller language, but you need to think more about
your code, otherwise it will never compile :-) D is more like
Python, you don't need lot of memory to use it, and the garbage
collector saves you lot of thinking (if you are writing small
programs).
I think D should relax and keep improving its strengths (like C++
interoperability), fix some of its holes (safety, GC-less
programming, fixing its contract-driven programming experience,
etc), improve its medium-integrity coding, and keep going on as
usual, slowly getting better. The Rust and D niches are
sufficiently different, there's minimal overlapping in their
purposes and niches.
Bye,
bearophile
More information about the Digitalmars-d
mailing list