RE: SWIG C#

Posted by Martin Champness on
URL: http://quantlib.414.s1.nabble.com/SWIG-C-tp4138p4139.html

Hi Dominic,
        Thanks for the information. I can understand your frustration with creating a managed C++ wrapper, as I have been attempting this recently. My C++ is very rusty though.

        BTW, do you know when the planned release is for the next version of quantlib? The SWIG created wrapper sounds like a promising way to go. Just wondered if you have any comments on the performance or robustness?

Thanks,
Martin


-----Original Message-----
From: dominic.thuillier [mailto:[hidden email]]
Sent: Saturday, October 15, 2005 3:49 AM
To: Martin Champness
Cc: [hidden email]
Subject: RE: [Quantlib-users] SWIG C#

Hi,

As Luigi mentioned, I made the changes to the QuantLib Swig interface files
in order to generate C# wrappers.
Hence in the next version of QuantLib, all the APIs exported to
Python/Ruby/... will also be available in C#.

I rewrote the Bermudan swaption example, which will be included in the
release. It seems to run fine. I have not tackled the other examples, since
I was primarily interested in swaption valuation.

Overall it was surprisingly easy to do : only some minor changes in the way
enums are mapped, a renaming of "params" and "Array" since they are C#
keywords, and other minor things. SWIG is really a fantastic tool, and the
QL interface files were clean and simple enough to incorporate C# mapping.

I worked 2 years ago on the mapping of a complex C++ library to .Net. We
tried real hard (with the help of .Net experts) to use Microsoft's IJW ("It
Just Works") functionality to map in a c++ managed manner the library. It
turned out to be very difficult, if not impossible. It was partly due to the
complexity and design of the legacy C++ library, but the bottom line is that
I did not fancy to live the same experience with QuantLib! Now maybe things
have evolved well and matured, and it may have become simpler!

IMHO, the advantages/drawbacks of the 2 solutions are :

SWIG/C# :
Advantage : uses same interfaces file and technology to map from C++ to
multiple languages at the same time.
Drawback : Difficult to extend the library by inheritance.

Managed C++ (Less sure about this...) :
Advantage : probably faster, since less interop
Drawback : a lot of manual work, only to target the .Net platform...


Cheers,
Dominic.
________________________________________
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Martin
Champness
Sent: vendredi 14 octobre 2005 13:14
To: [hidden email]
Subject: [Quantlib-users] SWIG C#

Hi,

Just wondered if anyone has attempted to use swig to create a C# wrapper for
quantlib? How robust was the solution? And what were the problems
encountered?

I am also interested in peoples opinion on how it would compare to writing a
hand crafted managed c++ wrapper which could then be called from C#.
Obviously, the manual coding of the C++ would take longer but it may offer
benefits in terms of performance as you can design fat interfaces to avoid
excessive interop.

Thanks,
Martin

Martin Champness
TRG Management Singapore PTE LTD
#25-03 Centennial Tower
3 Temasek Avenue
Singapore 039190
 
DID: (65) 6826 1816