Login  Register

Re: Templates

Posted by Luigi Ballabio-3 on Dec 20, 2000; 10:09am
URL: http://quantlib.414.s1.nabble.com/Re-Quantlib-dev-Linux-Port-tp1617p1625.html

Hi Bernd (and all the others),

At 03:26 PM 12/19/00 -0500, you wrote:

>Hi Luigi,
>         We have all read the text books and now about the
>conceptual advanges of templates.

Ok, I'll keep it shorter next time :)

>What I am concerned about is
>
>a) performance hit

This is a pro for templates.

>b) significant bloat

And this is a con. They cancel out in my opinion.

>c) considerable porting headaches.

This should be less of a problem as time goes by and compilers improve.
We're talking standard C++ after all... and anyway, I'm afraid the
headaches will be more on the Win side - I'm told g++ is well ahead of
other competitors as far as compliance goes. However: I'm aware of the
problem, and of the fact the compilers won't uniform for a while. But I
don't think there is an infinite number of possibilities to mess things up
- I mean, I think we'll have a relatively small number of generic
techniques to fix porting problems, so that it shouldn't be hard to master
them.

>d) diminished transparence as only few understand templates well
>     enough.
>
>         These issues must be weight against the beauty of
>programming using templates. In the end I tend to decide to
>do what is best for the user, and not what is most convenient
>for the programmer. I am particularly concerned by d), as it is
>hard enough to find people who know how to write pricers, it is
>even harder to find those who also are well versed in C++ and
>templates. The use of templates  will raise the barriers of entry
>amoung students, academics and practitioners alike.

I agree. But as I said: there's only half of the framework in place now.
The outer layer will be a base class (let us say Model) from which
FiniteDifferenceModel inherits. Pricers will be written in terms of the
Model interface, which means that one can use either our finite difference
framework and benefit from it if he can, or write his own model class
inherited from Model without using templates. You're free to choose what
techniques to use: the power and complexity of templates, or the ease of
dynamic polymorphism. The _complete_ framework will accept either one.

I am aware that this is the second mail in which I call to my rescue this
supposed complete framework which nobody ever saw. Well, I must admit I
didn't see it either :) Unfortunately we have a few deadlines at the
moment, so that I don't have much time to set it up. However, I hope I did
make the basic idea clear, so that it can be taken into account.

Thanks again for your patience,

                         Luigi