Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: VB.NET, C#, OR C++ (Read 1804 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

VB.NET, C#, OR C++

QUOTE FROM http://dotnetjunkies.com/WebLog/darrell.no.../07/07/382.aspx

Quote
If you really want to get into truly advanced features and squeeze every last bit of power out of .NET, then you'd want to look at C++ and the managed extensions for .NET. Otherwise, in the grand scheme of things, it just doesn't matter one way or the other.


Does this mean that c++ is still the best, compared to vb.net and c#?  Im not talking about any other language, i.e. assembly (00110011010) etc

VB.NET, C#, OR C++

Reply #1
In this case "best" is a very ambiguous and difficult term.

If speaking in the context of .NET framework, where Managed C++ code is compiled into MSIL instead of native code, I'd say that Managed C++ has very little advantage over VB.NET and C#. Dealing with unmanaged C/C++ code is easier though.

In general terms however, C++ code can be compiled to native code, which can be faster than JITted (MSIL) code on certain circumstances. With C++ it's possible to do some extreme performance tuning (for instance via templatized code, inlined functions and inline assembler) that is not possible directly with VB.NET or C#.  I think this is what the article you quoted is referring to.

If operating within .NET framework, Managed C++ can be used to optimize critical parts of the application. It can also be used to interface with legacy C/C++ code.

Also, plain (non-.NET) C++ programs are easier to distribute since they don't require the .NET Framework runtime. But this is also valid for C, VB, Delphi, D, Obj-C and so on and so on. In theory, C++ is also very portable, much more so than .NET applications.

A simple answer to "is C++ better than C#, VB.NET etc" is impossible to give. Generally the heavy-duty "C++ optimizations" can be done in .NET environment, either by using Managed C++ or by calling native code from DLL's via P/Invoke. C# and VB.NET are a lot cleaner and nicer languages than C++, and they are also a lot easier to learn throughly.

I leave you with a blatantly obvious, low-SNR answer: C++ is optimal for certain tasks and unoptimal for others. So are C#, VB.NET, Java, Python etc. Programming languages are tools. You should choose the right tool for the job.

Edit:

Given the current situation in computer hardware and CPU architecture, "optimization" is becoming an increasingly difficult concept. The old C-style *q++ = *p++ tricks just won't work anymore. So, I'd say that is totally possible to write extremely efficient code with C#/MSIL, in some cases it's even faster than well-written compiled C++ code.

So, where does that put C/C++ to? To where they belong, operating systems, embedded systems and obscure platforms