[Aldor-l] [Axiom-developer] Re: exports and constants

Jacques Carette carette at mcmaster.ca
Tue Jul 25 10:59:05 EDT 2006


If you want a better experience with metaprogramming, I definitely 
recommend MetaOCaml (http://www.metaocaml.org).  Unlike Template 
Haskell, it is fully typed; TH only types the result of the generation, 
not the generator itself [though SimonPJ assures me they are working on 
that too].

Gabriel Dos Reis wrote:
> (On performance side, last month, a colleague of mine and I did some
> experiments by writing a small Computer Algebra library in Haskell 98
> and Generic Haskell.  Disappointingly, there is a slowdown factor
> between 7 and 10 when going from Haskell to Generic Haskell.  We don't
> know yet which part can be credited to the maturity of the compiler
> and which part is inherent to the approach.  Anyway, it was an
> interesting experience). 
>   
Is this experiment available?  I would be quite interested in looking at 
the details.

<ShamelessPlugWarning>
Getting efficiency from meta-programs seems to be quite difficult, and 
even more so in a typeful system.  Enough has been said about C++ 
template programming to assure everyone that a) it is hard, and b) it's 
not *really* typed.  But it *is* possible to get both genericity and 
efficiency.  As a side effect, one can also get much better code 
organization as well!  See the paper
"Multi-stage programming with functors and monads: eliminating 
abstraction overhead from generic code" by Carette & Kiselyov
(paper, code, tests, etc at http://www.cas.mcmaster.ca/~carette/metamonads/)
published at GPCE05 (http://dx.doi.org/10.1007/11561347_18)
as well as  http://metaocaml.org/examples/gausselim/
which contains all the extras for an earlier paper published (later!) in
Science of Computer Programming 
(http://dx.doi.org/10.1016/j.scico.2005.10.012).

You will see, especially in the GPCE05 work, code organization which is 
explicitly influenced by Axiom/Aldor.  The principal reason that this 
work was done in MetaOCaml was that a) the type system is completely 
described (and proven to 'work') in published papers and b) the compiler 
sources are open [which was needed, not just nice-to-have].

Our basic thesis is that, given the right infrastructure, you can 
structure code like it ought to be structured (which is already what 
Axiom/Aldor strives for) and, without relying on the cleverness of 
compiler writers, get optimal efficiency.  For linear algebra, this 
works.  In separate work, it was shown that this works for FFT as well.  
We are currently extending the work to handle (numeric) solving of LODEs.
</ShamelessPlugWarning>

Jacques

PS: MetaOCaml has no introspection features at _all_, by design.  No 
'has' of anything like it.  That makes things extra-challenging, yet 
still feasible, which was not clear at all when the work was begun.



More information about the Aldor-l mailing list