D vs Go in real life
Chris Cain
clcain at uncg.edu
Sat Nov 30 13:19:14 PST 2013
On Friday, 29 November 2013 at 16:15:10 UTC, Chris wrote:
> I agree that D, too, can be a bit confusing. I sometimes have
> problems with AA declarations.
>
> Example:
>
> string[string][string] hm; // What am I?
>
> But I don't think it's the reading direction.
Actually it is. D is pretty good about being consistently read
backwards (which, as you can tell, is a tiny bit awkward, hence
why I think "the other way" is better).
hm is an associative array mapping string to another associative
array mapping string to string.
Pseudocode:
hm [string][string]string;
How about something *ridiculous* in right-to-left reading:
rofl *[string][]*bool;
Try to read that before seeing what's below:
-----
rofl is a pointer to an associative array mapping strings to
arrays of pointers to bools. Very simple and very intuitive.
After reading a few things like that you become very comfortable
with it.
> I wonder why you would want the variable name first.
It's really irrelevant either way, but it "reads out loud" much
better in my experience
> For my liking Go code looks too cluttered (pointing out the
> obvious). But I guess it's just the way you're "brought up"
> with a language. Maybe I'm a dinosaur.
I'm not suggesting Go got it perfectly. I've seen a lot of
languages that have cleaner declarations, IMO. To be honest, Go
looks kind of cluttered in my eyes too. But the right-to-left
reading order is something I'm a very strong proponent of. I'm
fine with D, however, since you can usually reliably read it
backwards. C, however, is a horrific mess.
More information about the Digitalmars-d
mailing list