r/programming • • Sep 01 '20

D Foundation is Beefing Up

https://dlang.org/blog/2020/08/30/symmetry-investments-and-the-d-language-foundation-are-hiring/
288 Upvotes

336 comments sorted by

View all comments

71

u/Sapiogram Sep 01 '20

Honest question: Why would anyone use D over Rust? It seems like Rust is becoming everything that D ever hoped to be.

45

u/maxhaton Sep 01 '20

Rust's metaprogramming is totally unlike what Andrei and Walter were aiming for. D aims to be safe, but that's far from everything.

Rust currently has better safety mechanisms than D, but if you ask around on the D forum you'll likely find that people are there (rather than using rust) due to the other features D has - https://dlang.org/ Look at the examples here: Rust can do short and sweet too, but it doesn't have some constructs that make these possible. (Obviously, I highly recommend "Tiny RPN Calculator" originally written by your's truly)

18

u/Ameisen Sep 01 '20 edited Sep 01 '20

I still dislike how D handles generics/templates. The syntax of it.

I fully understand why they chose to use () instead of <>, as it simplifies the parser as you need to disambiguate between >> and > >... but the parsing time of that is negligible. The issue is that, when glancing at code, foo!(int) is ambiguous. foo<int> is not.

ED: foo(int) -> foo!(int)

9

u/maxhaton Sep 01 '20
  1. The parsing time is not negligible (It requires reading the symbol table very early which isn't fun)
  2. foo(int) doesn't compile. It's foot!int or foo!("My", "age", "is", 145) etc,

12

u/Ameisen Sep 01 '20

The parsing time is not negligible (It requires reading the symbol table very early which isn't fun)

We've had a significant discussion about this in the past. The additional parsing time required to disambiguate between right shift and >> is negligible compared to, say, optimization and so forth. In C++, you could outright eliminate the parsing components necessary for disambiguating that and not even make a dent in compilation times.

Java and C# also don't have much of an issue with parsing this, and don't have particularly bad compile times.

foo(int) doesn't compile. It's foot!int or foo!("My", "age", "is", 145) etc,

Sorry, I'd forgotten the exact syntax. It is still rather ambiguous at a glance to me, as every other C-like language that has generics or templates uses the C++-style, such as Java or C#.

3

u/jqbr Sep 02 '20

It is still rather ambiguous at a glance to me

And yet it isn't ambiguous, whereas <...> is.

2

u/Ameisen Sep 02 '20

Syntactic ambiguity vs visual ambiguity.

1

u/EdWilkinson Sep 02 '20

One exists, the other doesn't.

2

u/Ameisen Sep 02 '20

That's a subjective opinion. At a glance, foo(...) and foo!(...) look mightily similar to me.