Presentation is loading. Please wait.

Presentation is loading. Please wait.

Why C++? Isn’t C# enough? Kate Gregory Gregory Consulting.

Similar presentations


Presentation on theme: "Why C++? Isn’t C# enough? Kate Gregory Gregory Consulting."— Presentation transcript:

1 Why C++? Isn’t C# enough? Kate Gregory Gregory Consulting

2 What C++ has that others don’t Can generate native code C++ interop – the fastest and easiest Templates and generics Deterministic destruction Optimized MSIL PGO for native and managed code.NET Linking

3 Deterministic Destruction Nested “using”s in C# are hard to read { using(SqlConnection conn = new SqlConnection(connString) ) { // work with the connection in some way using(SqlCommand cmd = new SqlCommand(queryString, conn) ) { // work with the command }

4 Deterministic Destruction Automatic scope is easier C++ destructor maps to CLR “Dispose” Both directions Less code, more control { SqlConnection conn(connString); // work with the connection in some way SqlCommand cmd(queryString, %conn); // work with the command // don’t call Dispose or Close }

5 Managed Code Optimizations Compiler optimizes MSIL Even when generating verifiable code Some optimizations supported on MSIL Inlining Loop unrolling Loop invariant code motion Common subexpression elimination Copy propagation Expression optimizations Whole program optimization now supported for /clr code

6 Compile with /GL Source Object files Profile Guided Optimization Object files Link with /LTCG:PGI Instrumented Image Profile data Object files Link with /LTCG:PGO Optimized Image ` Instrumented Image Scenarios Output Profile data

7 Using Other Languages Visual C++ allows you to include code from multiple languages in a single file assembly a.cpp c.cs C++Compiler EXE C++ Code C# Code a.obj c.netmoduleC#Compiler C++Linker D:\>cl /c /clr a.cpp D:\>csc /t:module c.cs

8 C++  CLR C++ Features Deterministic cleanup, destructors Templates Native types Multiple inheritance STL, generic algorithms Pointer/pointee distinction Copy construction, assignment CLR Features Garbage collection, finalizers Generics Reference and value types InterfacesVerifiabilitySecurity Properties, delegates, events


Download ppt "Why C++? Isn’t C# enough? Kate Gregory Gregory Consulting."

Similar presentations


Ads by Google