A few notes on choosing between Go and D for a quick project

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sat Mar 14 22:06:02 PDT 2015

On 3/13/2015 2:20 PM, bearophile wrote:
>>> something like a "var" keyword to denote mutable values,
>> Transitive const may make this problematic.
> I don't understand, but perhaps you misunderstood me. I am talking about
> variables. In strict mode they are constant by default. This means in this code
> both x and y are immutable:
> auto x = 10;
> foreach (y; 0 .. 10) {}
> So in strict mode if you want them mutable you need a new keyword like "var":
> var x = 10;
> foreach (var y; 0 .. 10) {}


     mutable int* p;
     int* q = p;

q cannot be made immutable. But q can be made const.

>>> static full tracking of memory ownership,
>> Makes the language significantly more complex.
> You are probably right. But it also gives good things back to a system language.
> In the last years I've seen that taking twice the time to write my code is a
> good deal if later I can avoid wasting stressful hours searching and fixing
> bugs. So now I am willing to pay a high price up front when I code to avoid some
> bugs later. I have friends that have taken a look at Rust and have dismissed it
> for being too much fussy and hard to get code to compile (despite probably with
> practice the Rust rules should become quite simpler to follow), but Rust looks
> like the right language for me and I'd like the same qualities in the language
> that I like more (D). So in the end I don't know what's the best solution for D.

Rust has indeed done a good job selling people on the complexity of their 
annotation system. But I think starting with 'return ref' and D's ability to do 
inference we're actually in good shape with a far simpler system.

>>> less implicit casts (because now we have the safe int(x) sytnax),
>> I think D does very well with implicit casts.
> I am not sure of that. Implicit casts cause some troubles, you can see this if
> you program for a while in a language with no or with very little implicit casts
> like Haskell, and F#.
> In D we have some implicit casts also because the "cast(int)x" syntax is
> dangerous. But now we can write safe casts with the "int(x)" syntax, so there's
> less need of naked implicit casts.

Again, too many casts can cause bugs.

I have used languages that did not have implicit casting (Pascal) and didn't 
have a positive experience with it. It didn't detect a single actual bug, and 
managed to be quite annoying.

Value Range Propagation is a big win.

More information about the Digitalmars-d mailing list