Is D Dead?

Antonio antonio at abrevia.net
Wed Sep 15 15:51:11 UTC 2021


On Tuesday, 14 September 2021 at 18:03:32 UTC, Kenneth Dallmann 
wrote:

> There might be some potholes in the design of D.  I think if I 
> were to design
> something like D I would follow Rust's example for memory 
> management, and then
> add in GC as an optional feature.

One of the advantages of GC is the expressiveness of the language.

See this:

```d
T[] sorted(T)(T[] xs)
{
   return xs.length == 0 ? [] :
     xs[1..$].filter!(x=> x < xs[0]).array.sorted ~
     xs[0..1] ~
     xs[1..$].filter!(x=> x >= xs[0]).array.sorted;
}
void main()
{
     [ 3, 1, 2, 4, 0 ].sorted.writeln;
}

```

You simply can't write this kind of "one expression" syntax with 
Rust... If you try, you still end up with a mental sprain:

```Rust
fn sorted(xs:Vec<f64>)->Vec<f64> {
     return match xs.len() {
         0 => Vec::<f64>::new(),
         _ =>
             sorted( 
xs[1..].iter().filter(|&x|x<=&xs[0]).map(|&x|x).collect() 
).iter().
             chain( iter::once(&xs[0]) ).
             chain( sorted( 
xs[1..].iter().filter(|&x|x>&xs[0]).map(|&x|x).collect() ).iter() 
).
             map(|&x|x).collect(),
     }
}
```

D expressiveness is great...  Rust has not this capability




More information about the Digitalmars-d mailing list