D vs Rust

Ola Fosheim Grøstad via Digitalmars-d digitalmars-d at puremagic.com
Sun Jan 31 11:05:38 PST 2016


On Sunday, 31 January 2016 at 18:32:12 UTC, Xinok wrote:
> He likely means that, in general, D code has fewer bugs than 
> C++11 code.

Which is a questionable claim. If we are going to compare we have 
to compare performance vs proficiency vs risk of making mistake 
vs tooling vs X factors.

You certainly can write very high risk code in both C++ and D 
trying to get the highest possible performance.

> * Certain types of implicit casts are not allowed in D where 
> the original value may be lost, e.g. int to short.

Except D has modular arithmetics for integers and a very heavy 
handed cast operator. In my own C++ code I use a cast function 
that asserts value ranges in debug builds. So no, I am not 
accepting this.

> * Functions MUST return a value in D or at least throw an error.

?

> * D has far less "undefined behavior" than C++.

And static analysis tooling that reports on some of it, but I 
have never actually experienced any problems related to 
"undefined behaviour" in my own code.

> * safe, pure, transitive const/immutable, thread-local by 
> default, etc.

Thread local globals may or may not cause bugs. Depends on what 
you expect, but it is primarily a syntax issue.

Pure does not effect reliability.

Transitive const may offer some better reliability, except in the 
situations where you can't use it because you need head const. 
Which is what I usually need...

> This and much more makes D far more "reliable" than C++.

No, it does not make D anything in particular. It is just a claim.

Having a GC makes D more reliable, but we can make a similar list 
for D without GC vs C++, or C++ with a boehm collector and static 
analyzers vs D.

The problem is most C++ projects are not suitable for a GC. I 
only know of one FOSS project that use a GC with C++: Inkscape.



More information about the Digitalmars-d mailing list