Just where has this language gone wrong?

Chad J chadjoan at __spam.is.bad__gmail.com
Thu Jul 19 18:53:50 PDT 2012


On 07/19/2012 10:21 AM, Petr Janda wrote:
...
I think the other points have been adequately covered.
...
 > auto r = [5, 3, 5, 6, 8].sort.uniq.map!(x => x.to!string);
...
>
> I'm sorry I don't mean to be a criticizer, but it seems to me that D is
> trying to be a dynamic-like compiled language way too hard.
>

Everything in that snippet is statically (and probably strongly too?) 
typed at compile-time.

What's going on is a lot of type inference and syntax sugar that allows 
for very terse code.  You'll still get immediate compiler errors if you 
screw up the types and you try to treat "r" like it isn't a range of 
strings.  There won't be any bugs introduced in your programs due to 
breaches of type safety.  This is the beauty of it: the code is terse, 
does what it says it does, potentially very optimized, and also heavily 
verified at compile-time.  The anonymous function is even passed at 
compile-time for easy inlining (not sure how aggressively dmd handles 
that right now though).  It's hard to get that combo of (development 
speed)|(correctness)|(execution speed) in other places, in my 
not-so-humble opinion. ;)


More information about the Digitalmars-d mailing list