Marketing of D - article topic ideas?

Nick Sabalausky a at a.a
Mon Jun 7 11:19:39 PDT 2010


"Andrei Alexandrescu" <SeeWebsiteForEmail at erdani.org> wrote in message 
news:hujc46$v49$1 at digitalmars.com...
> On 06/07/2010 12:57 PM, "Jérôme M. Berger" wrote:
>> dsimcha wrote:
>>> == Quote from Walter Bright (newshound1 at digitalmars.com)'s article
>>>> D is an extremely powerful language, but when I read complaints and 
>>>> sighs about
>>>> other languages, few seem to know that these problems are solved with 
>>>> D.
>>>> Essentially, we have a marketing problem.
>>>> One great way to address it is by writing articles about various 
>>>> aspects of D
>>>> and how they solve problems, like
>>>>
>>> http://www.reddit.com/r/programming/comments/cb14j/compiletime_function_execution_in_d/
>>>>    which was well received on reddit.
>>>> Anyone have good ideas on topics for D articles? And anyone want to 
>>>> stand up and
>>>> write an article?
>>>> They don't have to be comprehensive articles (though of course those 
>>>> are
>>>> better), even blog entries will do.
>>>
>>> This probably won't be replied to because I'm starting a new sub-thread 
>>> in a
>>> mature discussion, but I wonder if we could write about the advantages 
>>> and
>>> disadvantages of duck typing vs. static typing, comparing Python vs. 
>>> Java at
>>> first, then bring D into the picture to show how, to a greater extent 
>>> than C++
>>> templates or C#/Java generics, it solves may of the problems of static 
>>> typing
>>> without introducing the pitfalls of duck typing.
>>>
>>> Here's a simple example of something that would be awkward to impossible 
>>> to do
>>> efficiently in any other language:
>>>
>>> /**Finds the largest element present in any of the ranges passed in.\
>>>   */
>>> CommonType!(staticMap!(ElementType, T)) largestElement(T...)(T args) {
>>>      // Quick and dirty impl ignoring error checking:
>>>      typeof(return) ret = args[0].front();
>>>
>>>      foreach(arg; args) {
>>>          foreach(elem; arg) {
>>>              ret = max(elem, ret);
>>>          }
>>>      }
>>>
>>>      return ret;
>>> }
>>>
>>> Do this in C++ ->  FAIL because there are no variadics.  (Yes, C++1x 
>>> will have
>>> them, but I might die of old age by the time C++1x exists.)
>>>
>>> Do this in any dynamic language ->  FAIL because looping is so slow that 
>>> you might
>>> die of old age before it executes.  Besides, who wants to do 
>>> computationally
>>> intensive, multithreaded work in a dynamic language?
>>>
>> In python: max (map (max, args)) should have reasonable
>> performances and is *much* more elegant...
>
> I very much doubt that.
>
> Andrei

It might be faster than using nested loops in Python. But yea, seems 
unlikely it would compare to the D version.

Plus, can't you still do something like this? (I may not have this exactly 
right)

CommonType!(staticMap!(ElementType, T)) largestElement(T...)(T args)
{
    static assert( !is(typeof(return) == void) );

    return max( map!max(args) );
}

Assuming, of course, a 'max' that works on a range, which would be easy 
enough to do. Probably something like:

T max(T range)
{
    return reduce!ordinaryMax(range);
    // Or
    return reduce!"a>b?a:b"(range);
}

-------------------------------
Not sent from an iPhone.




More information about the Digitalmars-d mailing list