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

bearophile via Digitalmars-d digitalmars-d at puremagic.com
Fri Mar 13 14:20:18 PDT 2015


Walter Bright:

> On 3/13/2015 3:34 AM, bearophile wrote:
>> "Strict mode" is a D2 with immutable+ at safe+pure by default,

Thank you Walter for giving me an actual answer :-)


> Note that you can get this largely by starting a module with 
> the following:
>
>    immutable @safe pure:

"immutable" in my post was mostly referring to local variables, 
foreach variables and so on.


>> 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) {}



>> 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.


>> 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.


>> And I'd still like built-in tuple syntax in D.
>
> [... Just one more feature ...] is the road to hell.

It's one more feature, and probably if D will last ten more years 
other features will be added to D.
Built-in tuples have a mostly intuitive semantics, and they help 
de-clutter the code. So the language gets a little more complex, 
but the code becomes a little simpler.

Bye,
bearophile


More information about the Digitalmars-d mailing list