Just where has this language gone wrong?

Alex Rønne Petersen alex at lycus.org
Thu Jul 19 07:50:16 PDT 2012


On 19-07-2012 16:21, Petr Janda wrote:
> Hi,
>
> I'm an occasional lurker on the D forums just to see where the language
> is going,but I'm a little puzzled. In another thread I found this code
>
> auto r = [5, 3, 5, 6, 8].sort.uniq.map!(x => x.to!string);
>
> I don't understand whats going on here. Int array is getting sorted,
> then Uniqued, then what? What type is x? What kind of operator is =>,
> why is x.to!string allowed template specialization should say
> x.to!(string), which leads me to think that there are multiple syntaxes
> for things(why I hate dynamic languages, love compiled)
>
> On another note, (copied from wikipedia)
>
> foreach(item; set) {
>    // do something to item
> }
>
> what's with the lax syntax being allowed? Shouldn't it be at least
> specified "auto item"?
>
> 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.
>

No, it's just trying to make the developer's life easier.

What you see here is uniform function call syntax (UFCS), type 
inference, array literals, etc. These are all more or less standard 
features of modern statically typed languages. See ML, C#, Scala, F#, 
Rust, ...

And please, don't use a title like "what has gone wrong with this 
language?" if you're not sure how half of the features work. I don't 
blame you for not understanding, but dlang.org has plenty of 
documentation on these things (and TDPL certainly, too). Don't expect to 
know exactly what some piece of code from an arbitrary language does 
without knowing that language first.

I suspect that you have a C++ background. If this is not accurate, 
ignore the rest. But if it is accurate, my plea to you is: Learn other 
languages. C++ has next to no innovative language features (even C++11's 
take on lambdas is an abomination) and encourages defensive programming 
to the point where it's ridiculous (I mean, no default initialization of 
variables? In 2012?).

-- 
Alex Rønne Petersen
alex at lycus.org
http://lycus.org


More information about the Digitalmars-d mailing list