Saturday, May 3, 2008

C++/CLI vs C# (1)

Worked at analyzing the benefits of implementing NaroCAD with C# versus the C++/CLI implementation.

Didn't obtain any clear conclusion yet. Until now the conclusions are the following:

1. The C++/CLI implementation has the advantage that it can mix unmanaged and managed code with ease (on the other side this can be seen as an disadvantage if not used with care), the P/Invoke layer/maybe marshaling can be avoided for speed critical code areas, a wrapper can be probably avoided if not needed or if it affects the speed,

2. Couldn't measure yet the performance cost of using a C# wrapper around the OpenCascade code and the impact that this wrapper might have on NaroCAD. From the two C# wrappers that I tried until now the conclusions are the following:
- tried the wrapper from Sofa.de, implemented using P/Invoke. Succeeded to implement easily the MakeBottle code into the C# project provided by OpenCascade. The main problem here is that the wrapper doesn't cover the AIS packages and OCAF, couldn't make some display performance tests. Using this wrapper will need some additional work to wrap the packages that are not covered. Looked also at the Cadability.Net sample application provided by Sofa and it seems that for drawing they are using some ACIS plugins, probably this explains the missing packages and their license costs,
- tried the wrapper from Jonathan Hill. Couldn't make it work for VS2005, some OpenCASCADEX.dll registration fails. It would be interesting to analyze it because I saw in some forum posts that he might not use P/Invoke as wrapping method.

Looked at some QuakeII port to .Net: http://www.codeproject.com/KB/mcpp/quake2.aspx. They claim that the managed version performs 85% as fast as the native version, the speed is good and the testers didn't notice the difference between the two versions. This performance might be acceptable considering the advantages of using .Net.


I will continue analyzing this problem and see what the final conclusion is.

No comments: