D component programming is a joke (Was: Re: Component programming)

Andre Artus andre.artus at gmail.com
Sat Aug 3 06:35:54 PDT 2013


On Thursday, 1 August 2013 at 22:45:10 UTC, bearophile wrote:
> Walter Bright:
>
>> But consider that optimizers are built to optimize typical 
>> code patterns. Component programming is fairly non-existent in 
>> C and C++, and is new in D. Hence, optimizers are not set up 
>> to deal with those patterns (yet).
>
> I agree.
>
> GHC also works with a LLVM back-end, so those optimizations are 
> done in some kind of middle-end.
>
> Probably a silly idea: perhaps we can collect some money, like 
> 1000-2000 dollars, to pay for a 3 day long course for Walter 
> (total about 15 hours) about such matters.

Who's giving the course and where will it be held?

'Modern Compiler Design' by D. Grune, et al. & 'Compiler Design - 
Analysis and Transformation' by H. Seidl, et al. discusses some 
basic optimizations for functional programs. But I'm pretty sure 
Walter is already familiar with these.

Taking an example from Ali's book "P' in D":

import std.stdio;
import std.algorithm;
void main()
{
   auto values = [ 1, 2, 3, 4, 5 ];
   writeln(values
     .map!(a => a * 10)
     .map!(a => a / 3)
     .filter!(a => !(a % 2)));
}

As stated this implies 3 separate traversals of the list (or 
array to be specific) which is what a naïve implementation would 
do. But all three operations can run on the same traversal. Given 
that all three operations are monotonic functions (preserving the 
order and cardinality of the set, i.e. 1-1 mapping) they are also 
inherently parallelizable (i.e. amenable to auto vectorization or 
loop unrolling).





More information about the Digitalmars-d mailing list