CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2011
    Posts
    2

    C++/CLI vs CSharp viz numerical code and cloud

    Hi,

    (forgive me if my knowledge managed code and cloud computing are lacking, my background is in building mathematical code in plain native C++ and I am new to managed code).

    I am embarking on a project which is finance-related. The core part of the project is mathematical/numerical in nature and is highly computationally intensive. Attached to this will be a number of user interfaces including an excel interface and a console application interface (possibly others). Usually, the user will be using an excel interface on Windows. However, I can see that the ability to deploy the analytics to a cloud could be of significant value to potential customers. My main concern is building compatible code. I have a number of concerns.

    (1) To deploy an application to a cloud all dynamically allocated memory must be allocated on a garbage-collected managed heap. (is this true?)

    (2) To fulfill (1), I need to use C++/CLI (or maybe C# or java)

    (3) If I used C++/CLI, then 3rd party libraries (eg boost) will not, in general, be limited to using the managed heap and render the application unusable on a cloud. Is there some kind of viable work around for using 3rd party libraries?

    (4) Even if I could avoid using 3rd party libraries or find a work-around for (3), is there some non-pathalogical way of structuring the code in C++ so that it compiles in linux under gcc (and intel) 'natively' and with all objects being managed under windows? (I can conceive of some hideous solution using #define's for all the __gc, and ^ syntax, but it would be really messy). I certainly like to compile C++ on linux too, for the warnings and valgrind if nothing else.

    (5) What is the performance hit of using C# (or java). From what I have read on the internet, well-written numerics in C# and java are comparable in speed to C++. However, these have tended to be small toy problems and my concern is that maybe C# and java can be more memory hungry which may slow down the numerics for serious mathematical problems.

    I have spent a couple of months on the project already and can see how to do virtually everything in plain native C++, however, compatability with cloud computing is a real concern to me and would be more than willing to rewrite in C sharp if I new that the performance hit was not too much (say, 30% or 40% slower) and that it would solve all the issues related to compatability with the cloud.

    All advice and correction of my misunderstandings are welcome. Can anyone see a workaround for doing everything in C++ (/CLI)? (I don't want to write my own date or smart pointer classes, so ability to use third party libraries like boost is more a less a necessity)

    Thanks in advance,

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: C++/CLI vs CSharp viz numerical code and cloud

    Quote Originally Posted by JeffMcJefferson View Post
    (3) If I used C++/CLI, then 3rd party libraries (eg boost) will not, in general, be limited to using the managed heap and render the application unusable on a cloud. Is there some kind of viable work around for using 3rd party libraries?
    Native libraries in a mixed-mode app will of course use the native heap. And as the managed code is limited to the managed heap OTOH, passing pointers between the two requires some extra effort, although C++/CLI may hide some part of that.

    If native C++ apps are incompatible with the cloud, mixed apps will probably be as well.

    (4) Even if I could avoid using 3rd party libraries or find a work-around for (3), is there some non-pathalogical way of structuring the code in C++ so that it compiles in linux under gcc (and intel) 'natively' and with all objects being managed under windows? (I can conceive of some hideous solution using #define's for all the __gc, and ^ syntax, but it would be really messy). I certainly like to compile C++ on linux too, for the warnings and valgrind if nothing else.
    Despite the similar name and look of the code, native C++ and C++/CLI are essentially distinct languages. You may be able to put together a program that works compiled to both managed and native code using a train load of macro magic, but that would require an absurdly high effort. If it can be done at all, it would at best make sense for small experimental toy apps, not for large-scale stuff.

    (I don't want to write my own date or smart pointer classes, so ability to use third party libraries like boost is more a less a necessity)
    C++/CLI apps have the entire .NET framework at their disposal, which might eliminate the need for 3rd-party libraries completely. But you must be aware that the app will be strictly MS-bound that way.

    Sorry I can't/don't want to say anything to your other questions, either because I don't have solid facts to found my opinion on and/or the topic is somewhat dogmatic. The performance comparison between native and managed code is one to which both reasons apply.

    I also do know practically nothing about cloud computing. Hopefully, others will come along and fill the gaps my post left behind.

    I am, BTW, one of the few who prefers C++/CLI over C# but that's completely anti-mainstream. Most developers will recommend to use C# if you want to go the .NET way and don't have the absolute requirement of integrating pre-existing native C++ code. And I must admit they have really good reasons for that recommendation.

    Ah, and... Welcome to CodeGuru!
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  3. #3
    Join Date
    Jan 2011
    Posts
    2

    Re: C++/CLI vs CSharp viz numerical code and cloud

    Hi Eri523,

    Thanks for the reply. What you said is in line with the conclusions I was coming to. I think if cloud computing turns out to be anything like what it is hyped to be then the consequences for C++ development are going to be big.

    Cheers

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured