Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ vs C#, choice in terms of performance (VS2010) [closed]

Tags:

c++

c#

I am developing a tool that will be used for reading, processing and displaying data. I am confused about my choice between C++/C#. I have done C++ console programming only. No GUI or no C#.

I will be using VS2010 (compulsory).

I did a lot of reading on the web. I understand that when it comes to high performance, C++ is the best choice. I will list what I need:

  1. A GUI
  2. Reading files (one file is about 25 MB and a total of about 5000 images might be used at a time for further processing)
  3. Processing the data. Mathematical operations mainly.
  4. Display the data. These may be heavy data again. (~GBs). I am thinking of using OpenGL for this.

I started of with Windows Form Application under VC++. I made a GUI and it was rather quick. I had some issues in reading files. Most people around me are using MFC (dialog based). But they mainly work on firmware programming. They recommended I should develop in MFC. But I realized my productivity decreased.

Now its up to me what to use. So my questions is: For the tasks this tool supposed to perform, is it worth going to MFC or its better I move to C# (or C++ CLR). Time is not the biggest concern if I gain significant improvement in terms of performance.

This is the first part of development. Later, it needs to be expanded. Keeping that in mind, what is better for future prospects. (we might need to use CUDA for processing, if this information is useful.)

I hope I am clear. Kindly be gentle and ask further details, if needed.

EDITS:

Thanks for a clear responses. The data being read are binary images (25 MB~ -35 MB~ each). 1000s of images are stacked and processed (not all at once, but pixel by pixel). I have implemented it in MATLAB so I have a fair idea about the process. Mainly, statistical analysis and Fourier analysis will be done on the data. Finally a point cloud is generated. I am thinking of using a PCL (point cloud library which is in C++). These are not very big, since I am displaying in MATLAb right now. In future, files might get bigger so we are moving to C++/C# environment. Displayed data needs to have functionality such as selecting points, and displaying option to show properties/plots of that particular point etc. Graphics are not heavy to display, but more important is the ability to select a feature.

like image 490
Naresh Avatar asked Apr 16 '13 09:04

Naresh


1 Answers

C# and C++ will give almost similar performance unless you are talking of massive amount of data over long period of time. In most case, C++ could give you a few fraction of second over C#; so it's not really a great advantages in any daily application.

However, in cases where ultimate performance is absolutely critical, such as drivers or video games, the milliseconds gained and the manual memory control offered by C++ is an obvious advantage. For everything else, C# is generally easier and faster to write and debug. The managed code means you don't, most of the time, have to handle any memory allocation or deallocation. It is also my opinion that it gives much "cleaner" code file.

GUI in .NET is done in WinForms or WPF. Most would probably point you towards WPF as the obvious choice because it is a much... younger technology where one of the main advantage is being drawn over DirectX, which mean high end computer will draw interface much faster.

However, if you plan in displaying lot of custom information in, let's say 3D, you might find it much easier to code directly you request to DirectX/OpenGL. You can then use a wrapper such as SlimDX to make your life easier. But you should know that if you never handled this kind of code before, learning to code anything in DirectX or OpenGL oriented is really not an easy task. The shaders alone is a very special world.

If you can provide more complete information about the data being handle and the way you plan in displaying it, we can point you towards a more complete solution.

UPDATE:

My guess, in this case, is you won't find much difference in performance between C# and C++, even more if you are using a outside library for some of the computation. Both C# and C++ can use the same libraries. If the graphic computations were that heavy, most likely the best approach would be to transfer them to the GPU over DirectX/OpenGL, but that would only be if you think of having minutes or even hours of intensive computation. So it might be easier and faster to use C#.

like image 127
LightStriker Avatar answered Oct 20 '22 09:10

LightStriker