Rust vs Dlang
Andrej Mitrovic
andrej.mitrovich at gmail.com
Sat Mar 16 08:14:15 PDT 2013
On 3/16/13, Suliman <evermind at live.ru> wrote:
> Hi folks! I had wrote small article about Rust vs D. I hope that
> you will like it!
>
> http://versusit.org/rust-vs-d
>
This code:
```
In D a similar code would look as follows:
void main() {
for (int i = 0; i < 10; i++) {
writeln("Hello");
}
}
```
Should really be:
```
foreach (i; 0 .. 10)
writeln("Hello");
```
It avoids the common mistake of using a signed 32-bit type for indexing.
This:
```
void main() {
foreach (i, val; taskPool.parallel(new int[10]))
{
writeln("Hello:", i);
}
}
```
Also very very wrong, you don't have to allocate, use iota:
void main()
{
foreach (i, val; taskPool.parallel((iota(0, 10)))
{
writeln("Hello:", i);
}
}
Also your example code seems to embed some strange hidden Unicode
characters (Error: unsupported char 0xfeff) which make copy-pasting
and running the examples not work.
Anyway I don't agree with the conclusions, this is barely scratching
the surface of either language.
More information about the Digitalmars-d-announce
mailing list