Clay language

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Dec 27 22:28:20 PST 2010


On 12/28/10 12:09 AM, bearophile wrote:
> Andrei:
>
>> FWIW I just posted a response to a question asking for a comparison
>> between Clay and D2.
>>
>> http://www.reddit.com/r/programming/comments/es2jx/clay_programming_language_wiki/
>
> Just few comments:
>
>> The docs offer very little on Clay's module system (which is rock solid in D2).
>
> D2 module system may be fixed, but currently it's not even bread-solid.
>
> The Clay syntax for imports is more similar to what I have desired for D (but that () syntax is not so good):
>
>    import foo.bar; // Imports module foo.bar as a qualified path
>    // use "foo.bar.bas" to access foo.bar member bas
>    import foo.bar as bar; // Imports module foo.bar with alias bar
>    // use "bar.bas" to access foo.bar member bas
>    import foo.bar.(bas); // Imports member bas from module foo.bar
>    // use "bas" to access foo.bar member bas
>    import foo.bar.(bas as fooBarBas) // Imports member bas with alias fooBarBas
>    import foo.bar.*; // Imports all members from module foo.bar
>
> I don't know about Modula3 module system, I will search info about it.
>
>
>> Clay mentions multiple dispatch as a major feature. Based on extensive experience in the topic I believe that that's a waste of time. Modern C++ Design has an extensive chapter on multiple dispatch, and I can vouch next to nobody uses it in the real world. Sure, it's nice to have, but its actual applicability is limited to shape collision testing and a few toy examples.<
>
> I think double dispatch is enough, it cover most cases and keeps both
> compiler complexity low enough. If you put double dispatch with a
> nice syntax in D then maybe people will use it. There are many things
> that people in other languages use that C++ programmers don't use
> because using it in C++ is ugly, a pain, unsafe, etc. The visitor
> pattern is used enough in Java (Scala too was designed to solve this
> problem).

This is... out there. I can't stop wondering - on what basis do you make 
such infinitely confident assertions? Have you worked on any large scale 
C++ system, or on a C++ system of any scale for that matter? Have you 
built one or more systems in whatever language in which multiple 
dispatch was an enabling feature?

A competent C++ programmer will use a pattern such as Visitor or double 
dispatch if needed. Double dispatch is not ugly in C++ (as Modern C++ 
Design has shown ten years ago), and even if it were, people who need it 
would still use it. Also, Visitor looks and acts at least as good in C++ 
(compared to e.g. Java) with the help of templates and macros.

Speaking from direct experience: although double dispatch as implemented 
in Modern C++ Design was (and probably still is) best of the breed, 
based on the feedback I got (better said, I didn't get), I can 
confidently say people seldom need it. There were major bugs in the 
implementation that lasted for seven years before anyone noticed them. 
In contrast, bugs in virtually all other chapters of the book were very 
quick to show up. This is because people needed the other patterns, but 
didn't need double dispatch.

Please, bearophile, if you are looking for a New Year's resolution, vow 
to stop feigning more competence than you have. You are plenty good, we 
all appreciate you, but please stick with what you actually know, which 
is a lot. I'm sorry but it would be a full-time job for me or anyone to 
debunk the occasional enormity you write, so I must resort to being 
frank just this once. Hope you understand. Thank you.


Andrei


More information about the Digitalmars-d mailing list