Rock Hard: C++ Evolving

Slides:



Advertisements
Similar presentations
Writing Modern C++ Marc Grégoire Software Architect April 3 rd 2012.
Advertisements

What's new in Microsoft Visual C Preview
Introduction to Programming Lecture 39. Copy Constructor.
CSE 332: C++ memory management idioms C++ Memory Management Idioms Idioms are reusable design techniques in a language –We’ll look at 4 important ones.
Tips, Tricks, and Techniques for Building Killer Silverlight Apps Jeff Prosise
Build-Deploy-Test with Visual Studio Lab Management 2010 Pieter Gheysens Visual Studio ALM MVP – Sparkles User Group Lead VISUG (
Array out of Bounds Normally bounds are unchecked for execution efficiency.
HTML5 That’s what you need to know today Ingo Rammer, thinktecture
C#.NET C# language. C# A modern, general-purpose object-oriented language Part of the.NET family of languages ECMA standard Based on C and C++
& Silverlight, Windows Phone 7, Windows Azure, jQuery, OData and RIA Services. Shaken, not stirred. Kevin
Switching on the cloud for Silverlight MSDN Live Meeting Gill Cleeren Microsoft Regional Director – Silverlight MVP Ordina Belgium.
Best Practices in Virtualizing RDS and VDI: THE Virtual Reality Check Ruben
Parallel Programming in.NET 4.0 Tasks and Threading Ingo Rammer, thinktecture
Total Workstation Lockdown: Your Action Plan Jeremy Moskowitz, Group Policy MVP Chief Propeller-Head: GPanswers.com Founder: PolicyPak Software (policypak.com)
NuGet in Depth Making Open Source Suck Less at Microsoft Scott Hanselman
Parallel Programming in.NET 4.0 Tasks and Threading Ingo Rammer, thinktecture
CSE 332: C++ memory management idioms C++ Memory Management Idioms Idioms are reusable design techniques in a language –We’ll look at 4 important ones.
CS212: Object Oriented Analysis and Design Lecture 10: Copy constructor.
LINQ, Take Two Realizing the LINQ to Everything Dream Bart J.F. De Smet blogs.bartdesmet.net/bart
Pointers and Dynamic Memory Allocation Copyright Kip Irvine 2003, all rights reserved. Revised 10/28/2003.
Migration and Deployment of Office 2010 Steffen Krause Senior Technical Evangelist Microsoft Deutschland GmbH
Windows Azure for IT Pros Kurt CLAEYS (TSP Windows Azure, Microsoft EMEA)
Dynamic Binding Implementation Object-Oriented Programming Spring
Forthcoming SQL Azure Services: SQL Azure Data Sync & SQL Azure Reporting Mark Scurrell Lead Program Manager Microsoft.
Developing SaaS Applications with the Windows Azure Platform Vittorio Bertocci
Introduction to C# Anders Hejlsberg Distinguished Engineer Developer Division Microsoft Corporation.
Service Manager 2010 Real Life Example: The coffee workflow Mike Resseler & Alexandre Verkinderen Infront Consulting Group.
Building Robust, Maintainable Coded UI Tests with Visual Studio 2010 Brian Keller Sr. Technical Evangelist – Visual Studio ALM
Troubleshooting Group Policy Jeremy Moskowitz, Group Policy MVP Chief Propeller-Head: GPanswers.com Founder: PolicyPak Software (policypak.com) Twitter:
 Review building a complete linked list  List traversal in main ( )  List traversal using a function.
To OData or Not to OData Chris Eargle kodefuguru.com.
What’s new in Azure SDK 1.3 (and 1.4) Peter Himschoot Microsoft Regional Director Belux U2U Trainer/Architect
Object Oriented Programming Lecture 2: BallWorld.
Channel Islands Scuba Dive Team Mike Schechter. CISDiveTeam.com as a tool #1 Response for Joining the Team: ● Meet more divers and dive more Scuba diving.
Dive into Application Lifecycle Management with Visual Studio 2010
Andy Wang Object Oriented Programming in C++ COP 3330
Automating AD Administration with Windows PowerShell
Microsoft .NET 3. Language Innovations Pan Wuming 2017.
C++ Memory Management Idioms
Linked Lists head One downside of arrays is that they have a fixed size. To solve this problem of fixed size, we’ll relax the constraint that the.
Pointers Psst… over there.
System Structure and Process Model
System Structure and Process Model
Today’s Topic Dynamic allocation Slides for CS 31 discussion session
Pointers Psst… over there.
Chapter 12: Pointers, Classes, Virtual Functions, and Abstract Classes
Baremetal C Programming for Embedded Systems
Glenn Block MEF in the real world Glenn Block
.NET and .NET Core 9. Towards Higher Order Pan Wuming 2017.
System Structure B. Ramamurthy.
Lab 03 - Iterator.
System Structure and Process Model
SharePoint & jQuery: Better Together
Dynamic Memory Copy Challenge
Pointers & Functions.
A walkthrough Corey Hynes | HynesITe, Inc
Unlocking the secrets of REST with WCF
WCF Web API, HTTP your way
Dynamic Memory A whole heap of fun….
Chris Eargle kodefuguru.com
C++ Pointers and Strings
Introduction to Programming
Passing Arguments and The Big 5
Dynamic Memory Copy Challenge
Pointers & Functions.
Passing Arguments and The Big 5
The Stack.
Opalis System Center Integration Packs Deep Dive
Making your M Queries Dynamic in Power BI
Presentation transcript:

Rock Hard: C++ Evolving Boris Jabes blogs.msdn.com/vcblog (@visualc)

C++0x to become C++11 FDIS Submitted to ISO

Power & Performance on any Platform “Higher-level style of programming more natural than before and as efficient as ever.” “If you timidly approach C++ as just a better C or as an object-oriented language, you are going to miss the point.”

Programming with Values Value = No State || Deep Copy Requires a little bit of forethought

Silly? int Foo(int x) { // check for null if (x == null) // throw exception ... } Bar Foo(Bar x) { // check for null if (x == null) // throw exception ... }

POD struct fighter { string name; int health; }; // just works! int main() { fighter bart = { “bart”, 25 }; fighter lisa = bart; // works just like int! return 0; }

Dynamic Data struct fighter { T* data; string name; int health; fighter(string s, int h) : name(s), health(h), data(new T[1000]) {} }; int main() { fighter bart = { “bart”, 25 }; fighter lisa = bart; // shallow copy return 0; }

Dynamic Data struct fighter { T* data; string name; int health; fighter(string s, int h) : name(s), health(h), data(new T[1000]) {} fighter(const fighter& o) : name(o.name), health(o.health), data(new T[1000]) { std::copy(o.data,o.data+1000,data); } }; int main() { fighter bart = { “bart”, 25 }; fighter kirk(get_fighter()); // this works fighter lisa = bart; // this doesn’t return 0;

Dynamic Data struct fighter { T* data; string name; int health; fighter(string s, int h) : name(s), health(h), data(new T[HUGE]) {} fighter(const fighter& o) : name(o.name), health(o.health), data(new T[HUGE]) { std::copy(o.data,o.data+HUGE,data); } void swap(fighter& left, fighter& right) { std::swap(left.name,right.name); std::swap(left.health,right.health); std::swap(left.data,right.data); // swap head pointer fighter& operator=(fighter o) { swap(*this,o); return *this; };

Expensive Copy struct fighter { T* data; string name; int health; fighter(string s, int h) : name(s), health(h), data(new T[HUGE]) {} fighter(const fighter& o) : name(o.name), health(o.health), data(new T[HUGE]) { std::copy(o.data,o.data+HUGE,data); } friend void swap(fighter& left, fighter& right) { std::swap(left.name,right.name); std::swap(left.health,right.health); std::swap(left.data,right.data); // swap head pointer fighter& operator=(fighter o) { swap(*this,o); return *this; fighter(fighter&& o) : data(nullptr) { };

Destructors + RAII = The Best of C++ Determinism for Resources Cache-Locality Seamless with Exceptions Zero Burden on API Consumer

Higher-Order Programming Multi-Paradigm Generic Control And Yet… Efficient

Control in Context Lambdas

C# List<Action> actions = new List<Action>(); for (int counter = 0; counter < 10; counter++) { actions.Add(() => Console.WriteLine(counter)); } foreach (Action action in actions) action();

C# List<Action> actions = new List<Action>(); for (int counter = 0; counter < 10; counter++) { int copy = counter; actions.Add(() => Console.WriteLine(copy)); } foreach (Action action in actions) { action(); }

C++ vector<function<void()> actions; for (int counter = 0; counter < 10; counter++) { actions.push_back([&] { cout << counter << endl; }); } for(int i=0; i<actions.size(); ++i) actions[i]();

C++ vector<function<void()> actions; for (int counter = 0; counter < 10; counter++) { actions.push_back([=] { cout << counter << endl; }); } for(int i=0; i<actions.size(); ++i) actions[i]();

C++11 Coming Soon to a Compiler Near You Modern C++ != “C with Classes” C++11 = Expressive Without Sacrifice C++11 is Concurrent Go Forth & Be Merry

Stay up to date with MSDN Belux Register for our newsletters and stay up to date: http://www.msdn-newsletters.be Technical updates Event announcements and registration Top downloads Follow our blog http://blogs.msdn.com/belux Join us on Facebook http://www.facebook.com/msdnbe http://www.facebook.com/msdnbelux LinkedIn: http://linkd.in/msdnbelux/ Twitter: @msdnbelux Download MSDN/TechNet Desktop Gadget http://bit.ly/msdntngadget

TechDays 2011 On-Demand Watch this session on-demand via Channel9 http://channel9.msdn.com/belux Download to your favorite MP3 or video player Get access to slides and recommended resources by the speakers

THANK YOU