Blog post: What D got wrong

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Dec 13 17:07:58 UTC 2018


On Thu, Dec 13, 2018 at 10:29:10AM +0000, RazvanN via Digitalmars-d-announce wrote:
[...]
> D and Rust are competing to get the C/C++/Java/Python market share. In
> order to do that they should make it simple for developers to convert
> to the new language. Due to its design, Rust is insanely hard to
> master, which on the long run I think will kill the language despite
> of the advantages it offers.  On the other side, consider die hard C
> fans: they are willing to accept the possibility of a buffer overflow
> simply because they want more power. Do you honestly think that they
> will ever take D into account if @safe and immutable data will be the
> default?

Why not?  You can opt out. It's not as though you're forced to use
immutable everything and nothing but, like in a pure functional
language.  Just tack on @system or mutable when you need to.

Some people balk at the idea of `mutable` being sprinkled everywhere in
their code, but that's really just a minor syntactic issue. There's
already precedent for using `val` and `var` -- it couldn't get easier to
type than that. The syntax is not a real problem.


[...]
> > It would be if the change weren't accompanied by adding `impure` and
> > some sort of mutable auto. @system already exists. It's a question
> > of opting out (like with variable initialisation) instead of opting
> > in.
> 
> It still is, because the user is imposed to work in certain conditions
> that some might not want to.

No, there's always the option of opting out. There's no imposition. It's
not like Java where everything must be a class, no matter what. You can
write @system code or mutable variables to your heart's content.

The idea is to *default* to @safe so that when the programmer doesn't
really care either way, the default behaviour gives you memory safety.
Or default to immutable, so that unless the programmer consciously wants
to mutate state, he'll get the benefit of being warned about any
unintended mutation. Plus optimization benefits for variables that don't
need to be mutable.  But defaults are called defaults because they're
there to be overridden.


T

-- 
LINUX = Lousy Interface for Nefarious Unix Xenophobes.


More information about the Digitalmars-d-announce mailing list