I remember years before I was in debate with one of my friend who works on C++. The topic of discussion was ‘C# or C++ which is better‘. We had interesting hated argument with no conclusion! This was but obvious as both tools have there own advantages and disadvantages. The main advantage of using C# is to get better productivity. Reasons for better productivity using C#:
- Easy to learn & develop
- Automatic Memory Management using garbage collector
- Managed code
- Better 3rd party controls
- Huge .NET-Framework library
- Better Exception Handling
- LINQ, PLINQ and Generic support
- Dynamic Support
There are many more things to mention! Considering all these advantages, still few people wants to use C++ with 2 main reasons:
- Cross Platform
I am not going to discuss on Cross Platform at this stage but performance is main point to look at. C# may not perform as well when compared with native C++. C# has an intrusive garbage collector, reference tracking and other overheads with some of the framework services. The .NET framework alone has a big runtime footprint, and requires that several versions of the framework be installed. Now there is a way to get Productivity of C# with Power of C++ !!! Yes its true. Microsoft announce that .NET Native, now in developer preview, can provide both: C++ performance with the managed-code benefits of C#. Developer Preview can be downloaded from: http://msdn.microsoft.com/en-US/vstudio/dotnetnative .NET Native is a precompilation technology for building and deploying Windows Store apps. It compiles apps that are written in managed code (C#) and that target the .NET Framework to native code. Typically, apps that target the .NET Framework are compiled to intermediate language (IL). At run time, the just-in-time (JIT) compiler translates the IL to native code. In contrast, .NET Native compiles Windows Store apps directly to native code. For developers, this means:
- Your apps will provide the superior performance of native code.
- You can continue to program in C#.
- You can continue to take advantage of the resources provided by the .NET Framework, including its class library, automatic memory management and garbage collection, and exception handling.
For users of your apps, .NET Native offers these advantages:
- Fast execution times
- Consistently speedy startup times
- Low deployment and update costs
- Optimized app memory usage
To know more about how we can use .NET native you can visit: http://blogs.msdn.com/b/dotnet/archive/2014/04/02/announcing-net-native-preview.aspx Happy Coding! 🙂