• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
The Renaissance of C++
 

The Renaissance of C++

on

  • 1,071 views

Inspired by Herb Sutter

Inspired by Herb Sutter

Statistics

Views

Total Views
1,071
Views on SlideShare
1,065
Embed Views
6

Actions

Likes
0
Downloads
1
Comments
0

3 Embeds 6

http://www.linkedin.com 4
https://twitter.com 1
https://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    The Renaissance of C++ The Renaissance of C++ Presentation Transcript

    • The Renaissance of C++by Victor Haydin, Head of R&D Office, ELEKS
    • AgendaA bit of C++ historyWhy C++ is popular again?The future of C++
    • Quick SurveyWhat programming languages do you know?
    • A bit of C++ history
    • The Prehistoric Age (1979-1989) Research:C with Classes ARM C++
    • The Classic Age (1989-1999) Mainstream: Wide usagestandardization
    • The Dark Age (1999-2009)Coffee-based languages domination: Productivity over Efficiency People over Hardware
    • Let’s compare them all Efficiency Flexibility Abstraction ProductivityCEfficient high-level + + Non-goal Non-goalportable codeC++C + efficient + + + Non-goalabstractionJava/C#Productivity At the expence of At the expense of + +
    • Perception Performance & Control Productivity
    • Reality Performance Productivity & Control
    • C++ Values Never compromise on performance and control.  Efficient abstraction (e.g., inlining by default)  Flexibility to express exactly what you need (e.g., specialization)  Exact control over memory layout (e.g., stack/member allocation)  Determinism and ordering WYSIWYG (e.g., stack/member lifetime) Deeply believe in trust and zero overhead.  “Leave no room for a language lower than C++” other than asm  “Zero overhead” / “Don’t pay for what you don’t use”  “Trust the programmer” (  pitfalls! still give usability, guard rails)  “Always provide a way to open the hood and get down to the metal”
    • Priorities C++ says: “Provide default-on guard rails and programmer productivity too, but never at the expense of performance and control.” Coffee-based languages say: “Provide performance and control too, but never at the expense of always-on guard rails and programmer productivity.”
    • Why C++is popularagain?
    • Change driversMobileCloud/DatacenterPlatform shifts
    • Mobile
    • Power
    • Hardware limitations
    • Complex user experience
    • Vendor’s point of view 1st version N/A Java .NET2nd version Objective-C, C, C++ Java, C, C++ .NET, C++
    • Datacenter/Cloud
    • Power consumption 57% Hardware + 31% Power = 88% of expenses are directly dependent on efficiency
    • Platform shifts
    • The Renaissance (2009-2019)Return of the King: C++11 Productivity tools
    • Developer survey Q: How long has your current application been in development? (N=387)
    • C++11 Corollary: Lots of what people “know” about C++ is no longer true. Changes to coding style/idioms/guidance.  That’s why it feels new. Style/idioms/guidance define a language.  Features that significantly change style/idioms/guidance include:
    • Taste of C++11string flip( string s ) { reverse( begin(s), end(s) ); return s;}int main() { vector<future<string>> v; v.push_back( async([]{ return flip(" ,olleH"); }) ); v.push_back( async([]{ return flip( ".gnaL"); }) ); v.push_back( async([]{ return flip("n!TXEN"); }) ); for( auto& e : v ) { cout << e.get(); }}
    • Taste of C++11string flip( string s ) { reverse( begin(s), end(s) ); always there: scoped lifetimes return s; by construction (stack, member)}  strongly exception-safeint main() { vector<future<string>> v;  deterministic v.push_back( async([]{ return flip(" ,olleH"); }) ); v.push_back( async([]{ return flip( ".gnaL"); }) ); v.push_back( async([]{ return flip("n!TXEN"); }) ); for( auto& e : v ) { cout << e.get(); }}
    • Taste of C++11string flip( string s ) { reverse( begin(s), end(s) ); return s;}int main() { vector<future<string>> v; v.push_back( async([]{ return flip(" ,olleH"); }) ); v.push_back( async([]{ return flip( ".gnaL"); }) ); v.push_back( async([]{ return flip("n!TXEN"); }) ); for( auto& e : v ) { cout << e.get(); }}
    • Taste of C++11string flip( string s ) { reverse( begin(s), end(s) ); asynchrony return s;}  201x’s best friendint main() { vector<future<string>> v; v.push_back( async([]{ return flip(" ,olleH"); }) ); v.push_back( async([]{ return flip( ".gnaL"); }) ); v.push_back( async([]{ return flip("n!TXEN"); }) ); for( auto& e : v ) { cout << e.get(); }}
    • Taste of C++11string flip( string s ) { reverse( begin(s), end(s) ); lambdas return s;}  invasion of the functionalsint main() {  capture by ref or by value vector<future<string>> v; v.push_back( async([]{ return flip(" ,olleH"); }) ); v.push_back( async([]{ return flip( ".gnaL"); }) ); v.push_back( async([]{ return flip("n!TXEN"); }) ); for( auto& e : v ) { cout << e.get(); }}
    • Taste of C++11string flip( string s ) { reverse( begin(s), end(s) ); return s;}int main() { vector<future<string>> v; v.push_back( async([]{ return flip(" ,olleH"); }) ); v.push_back( async([]{ return flip( ".gnaL"); }) ); v.push_back( async([]{ return flip("n!TXEN"); }) ); for( auto& e : v ) { cout << e.get(); }}
    • Taste of C++11string flip( string s ) { reverse( begin(s), end(s) ); return s;}int main() { vector<future<string>> v; v.push_back( async([]{ return flip(" ,olleH"); }) ); v.push_back( async([]{ return flip( ".gnaL"); }) ); v.push_back( async([]{ return flip("n!TXEN"); }) ); for( auto& e : v ) { cout << e.get(); }}
    • Taste of C++11string flip( string s ) { move semantics reverse( begin(s), end(s) ); = return s;  the semantics of value types} (no pointers! declared lifetime!)int main() { + vector<future<string>> v; // <-- look ma, no *  the efficiency of reference types (no deep copying!) v.push_back( async([]{ return flip(" ,olleH"); }) ); v.push_back( async([]{ return flip( ".gnaL"); }) ); v.push_back( async([]{ return flip("n!TXEN"); }) ); for( auto& e : v ) { cout << e.get(); }}
    • Taste of C++11string flip( string s ) { reverse( begin(s), end(s) ); return s;}int main() { vector<future<string>> v; v.push_back( async([]{ return flip(" ,olleH"); }) ); v.push_back( async([]{ return flip( ".gnaL"); }) ); v.push_back( async([]{ return flip("n!TXEN"); }) ); for( auto& e : v ) { cout << e.get(); Hello, Lang.NEXT! }}
    • Taste of C++11string flip( string s ) {  program is guaranteed to reverse( begin(s), end(s) ); allocate only three strings return translate_to_french( move(s) );}  high compute / low latencyint main() { vector<future<string>> v; v.push_back( async([]{ return flip(" ,olleH"); }) ); v.push_back( async([]{ return flip( ".gnaL"); }) ); v.push_back( async([]{ return flip("n!TXEN"); }) ); for( auto& e : v ) { cout << e.get(); Bonjour, Langue.SUIVANTE! }}
    • Summary Modern C++ is clean, safe, and fast.  Strong abstraction: Type-safe OO and generic code for modeling power, without sacrificing control and efficiency.  Full control over code and memory: You can always express what you want to do. You can always control memory and data layout exactly.  Pay-as-you-go efficiency: No mandatory overheads.“The going word at Facebook is that ‘reasonably written C++ code just runs fast,’ which underscores the enormous effort spent at optimizing PHP and Java code.Paradoxically, C++ code is more difficult to write than in other languages, but efficient code is a lot easier.” – Andrei Alexandrescu
    • The Future (2019-????)Here be dragons: End of Moore
    • Moore’s law
    • Reality
    • Register atacademy.eleks.combefore February 15And may the Forcebe with you!
    • Got a question? Ask!