/
One C   Herb Sutter Themes: Understanding the C   Tide One C   Herb Sutter Themes: Understanding the C   Tide

One C Herb Sutter Themes: Understanding the C Tide - PowerPoint Presentation

faustina-dinatale
faustina-dinatale . @faustina-dinatale
Follow
347 views
Uploaded On 2018-09-23

One C Herb Sutter Themes: Understanding the C Tide - PPT Presentation

Organization Momentum Population shift with just a little code Trajectory Visual C Roadmap Update ISO C Update Portable C Libraries Update One C Agenda Conformance roadmap The road to C 14 ID: 676571

2013 amp libs update amp 2013 update libs standard library libraries portable language conformance literals major implementations roadmap types

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "One C Herb Sutter Themes: Understandin..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

One C++

Herb SutterSlide2

Themes: Understanding the C++ Tide

Organization

Momentum

Population shift

(with just

a little code)

TrajectorySlide3

Visual C++ Roadmap Update

ISO C++ Update

Portable C++ Libraries Update

One C++

AgendaSlide4

Conformance roadmap: The road to C++14

VC++ 2013 Preview

Shipped

in June

VC++ 2013 RTM

later

this year

Explicit conversion operatorsNon-static data member initializersRaw string literals= defaultFunction template default arguments= deleteDelegating constructors“using” aliasesC++14 libs: type aliasesUniform init & initializer_listsC99 variable declsC99 _BoolVariadic templatesC99 compound literalsC++14 libs: cbegin/ greater<>/make_uniqueC99 designated initializers

JUN'13Slide5

Conformance roadmap: The road to C++14

VC++ 2013 Preview

Shipped in June

VC++ 2013

A preview

update

will be available

this monthExplicit conversion operatorsNon-static data member initializersRaw string literals= defaultFunction template default arguments= deleteDelegating constructors“using” aliasesC++14 libs: type aliasesUniform init & initializer_listsC99 variable declsC99 _BoolVariadic templatesC99 compound literalsC++14 libs: cbegin/ greater<>/make_uniqueC99 designated initializersSlide6

Conformance roadmap: The road to C++14

wave

VC++ 2013 Preview

Shipped in June

VC++ 2013

A preview

update

will be available this monthExplicit conversion operatorsNon-static data member initializers__func__Extended sizeofThread-safe function local static initUnrestricted unionsAttributesRaw string literals= defaultImplicit move generationUser-defined literals

Universal character names in literals

thread_local

Function template default arguments

=

delete

Ref-qualifiers:

& and && for *this

noexcept

Expression SFINAEC++11 preprocessor (incl. C++98 & C11)Delegating constructors“using” aliasesC++14 libs: type aliasesC++14 generalized lambda capturealignofalignasInheriting constructorsC++98 two-phase lookupUniform init & initializer_listsC99 variable declsC99 _BoolC++14 auto function return type deductionconstexpr (except ctors / literal types)constexpr (literal types)C++14 generalized constexprVariadic templatesC99 compound literalsC++14 generic lambdasC++14 decltype(auto)Inline namespacesC++14 dyn. arraysC++14 var templatesC++14 libs: cbegin/ greater<>/make_uniqueC99 designated initializersC++TS? async/awaitC++14 libs: std:: user-defined literalschar16_t, char32_tC++TS concepts lite

Post-RTM OOB CTPWhat we’re currently implementing, roughly in order… some subset in CTP

PlannedWhat’s next for full conformance

JUN'13Slide7

unconditional

Conformance roadmap: The road to C++14

wave

__func__

Extended

sizeof

Thread-safe

function local static initUnrestricted unionsAttributesImplicit move generationUser-defined literalsUniversal character names in literalsthread_local

Ref-qualifiers:

& and && for *this

noexcept

Expression

SFINAE

C++11 preprocessor

(

incl. C++98

& C11)C++14 generalized lambda capturealignofalignasInheriting constructorsC++98 two-phase lookupC++14 auto function return type deductionconstexpr (except ctors / literal types)constexpr (literal types)C++14 generalized constexprC++14 generic lambdasC++14 decltype(auto)Inline namespacesC++14 dyn. arraysC++14 var templatesC++TS? async/awaitC++14 libs: std:: user-defined literalschar16_t, char32_tC++TS concepts litePost-RTM OOB CTP – 4Q13What we’re currently implementing, roughly in order… some subset in CTPPlannedWhat’s next for full conformancehigh probability in CTPmed probability in CTPSlide8

unconditional

Conformance roadmap: The road to C++14

wave

VC++ 2013 Preview

Shipped in June

VC++ 2013 RC

Available today

Explicit conversion operatorsNon-static data member initializers__func__Extended sizeofThread-safe function local static initUnrestricted unionsAttributes

Raw string literals

= default

Implicit move generation

User-defined literals

Universal character names in literals

thread_local

Function template default arguments

=

deleteRef-qualifiers: & and && for *thisnoexceptExpression SFINAEC++11 preprocessor (incl. C++98 & C11)Delegating constructors“using” aliasesC++14 libs: type aliasesC++14 generalized lambda capturealignofalignasInheriting constructorsC++98 two-phase lookupUniform init & initializer_listsC99 variable declsC99 _BoolC++14 auto function return type deductionconstexpr (except ctors / literal types)constexpr (literal types)C++14 generalized constexprVariadic templatesC99 compound literalsC++14 generic lambdasC++14 decltype(auto)Inline namespacesC++14 dyn. arraysC++14 var templatesC++14 libs: cbegin/ greater<>/make_uniqueC99 designated initializersC++TS? async/await

C++14 libs: std:: user-defined literals

char16_t, char32_t

C++TS concepts lite

PlannedWhat’s next for full conformance

Post-RTM OOB CTP – 4Q13What we’re currently implementing, roughly in order… some subset

in CTPSlide9

Visual C++ Roadmap Update

ISO C++ Update

Portable C++ Libraries Update

One C++

AgendaSlide10

You are

here

ISO C++: A Living Language

98

99

00

01

0203040506070809101112131415161718C++98(major)Library TR1 (aka TS) Performance TRC++03(TC, bug fixes only)C++11(major)C++17(major)

C++14

(minor)

FileSys

TS

Net

TS1

Concepts

TS

142014++ cadenceThis ISO C++ revision cycle: faster, more predictableLess monolithic: Delivering concurrent and decoupled library & language extensionsC++ is a living languageSlide11

Each round of international comment ballots generates bugs, tweaks, and requests

C++14: StabilitySlide12

Each round of international comment ballots generates bugs, tweaks, and requests

C++14: StabilitySlide13

Visual C++ Roadmap Update

ISO C++ Update

Portable C++ Libraries Update

One C++

AgendaSlide14

C++11

C++98 + TR1

C++11

Portable C++

C++98

C++98

language

libraryproxies for size comparisons: spec #pages, book #pagesGN’12Slide15

proxies for size comparisons:

spec #words

library #types (non-‘plumbing’)

2008 .NET FX + VS Pro Libs

Java SE 7

C++11

Portable C++

languageC# 3.0 (2008)Java 7 (2011)2008 .NET FX (only)C++11libraryGN’12Slide16

2008 .NET FX + VS Pro Libs

Java SE 7

C++11

C# 3.0 (2008)

Java 7 (2011)

2008 .NET FX (only)

Portable C++

C++11languagelibraryGN’12Slide17

C++11

C# 3.0 (2008)

Java 7 (2011)

Portable C++

?

C++11

library

“All in all, this [C++0x and post-C++0x library wish lists] … is not quite the ‘ambitious and opportunistic’ policy that I had hoped for in 2001 (§8). However, people who scream for more (such as me) should note that even what’s listed above will roughly double the size of the standard library.”– B. Stroustrup, HoPL-III, 2007GN’12Slide18

Portable C++ Library (PCL)

Goals:

Large

set of useful and current libraries.Available on all major platforms.

Shipped with and supported by C++ implementations.And composable, using consistent types.Minimum: De facto availability as part of all major compiler products.Ideal: De jure inclusion in Standard C++.

GN’12Slide19

Wonderful! But…

… where are we going to find all these libraries?

WG21

PCL

GN’12Slide20

Portable C++ LibrariesSlide21

De Jure: The Standard

De jure libraries

std

::HorizontalShip in the boxSlide22

Challenge

Make the world’s most flexible and efficient library-building language

better for building

libraries and

bundle more broadly useful librariesSlide23

Challenge, Part 2

‘Who will specify all these libraries? To make it happen, we must involve

new people

, not just ask for more work from today’s committee members.’

– B. Stroustrup, Kona, Feb 6, 2012Slide24

Thanks to all the volunteers!

ISO C++ (WG21) attendance

Completed

C++11

Completed

C++14

CDSlide25

sg4

3

…………Slide26

Lib Evolution

WG

Library WG

WG21 Organization

WG21 – Full Committee

Evolution WG

Core WG

SG5Tx. MemorySG2ModulesSG6NumericsSG4NetworkingSG3FilesystemSG7ReflectionSG8ConceptsSG9RangesSG10Feature TestSG11DatabasesSG12U. BehaviorSG1Conc. & Parall.Lang ExtensionLib buildingLib composabilityBase LibsDomain Libs

-

-

-

-

-

-

----------Slide27

Update: SG1 July Meeting, Santa Clara

Concurrency TS1 (2014?)

All of:

std::future

Extensions: then, wait_any, wait_all

Executors

Resumable

Functions:await (with futures)+ If ready (else TS2):CountersQueuesConcurrent containers: concurrent_vector, unordered associative containersLatches and barriersupgrade_lock?Parallelism TS1At least one of:Parallel algorithms (e.g., Parallel STL)Data-based parallelismTask-based parallelism+ If ready (else TS2)MapReducePipelines?Bringing state-of-the-art concurrency and parallelism to Standard C++Slide28

Lib Evolution

WG

Library WG

WG21 Organization

WG21 – Full Committee

Evolution WG

Core WG

SG5Tx. MemorySG2ModulesSG6NumericsSG4NetworkingSG3FilesystemSG7ReflectionSG8ConceptsSG9RangesSG10Feature TestSG11DatabasesSG12U. BehaviorSG1Conc. & Parall.Lang ExtensionLib buildingLib composabilityBase LibsDomain Libs

-

-

-

-

-

-

----------(SG13)2D GraphicsThanks, Tom et al.!Slide29

Reality check

Nobody knows what “most” C++ programmers do.

— Bjarne StroustrupSlide30

Planetary

Language: C++

Primary author: Robert

Hodgin

Self

taught

programmer

Sculpture major at RISDQ: Which language would you recommend for creative graphics apps written by non-CS majors?Slide31

Q: Which language would you

recommend for creative graphics

apps written by

non-CS majors?

Did you know?

C++ library

openFrameworks

is widely used in teaching art & designIncl. prestigious schools like Parsons School for DesignC++ “creative coding” library Cinder awarded ad industry’s highest honorJune 2013: Cannes Lions Festival, Innovation Grand PrixC++ app Planetary acquired by SmithsonianAugust 2013: The museum’s first-ever curation/preservation of codeSlide32

From the trenches

The

advertising and design industries have really embraced C++

in recent years for a new generation of interactive

projects.I think that’s largely because in our work, a piece of software’s performance often marks the difference between a user’s experience feeling ordinary and

feeling magical

.

This [2013] has been an excellent year for C++’s visibility in the art and design worlds… — Andrew BellSlide33

Who did/do I want it for?

Primary concerns

Systems programming

Embedded systemsResource constrained systemsLarge systemsExperts“C++ is expert friendly”NovicesC++ Is not

just expert friendlyStroustrup - Essence - Going Naive'13

33

GN’13

StroustrupSlide34

How Easy Is C++, Really?

// First thing Scott said:

cout

<< “Is that on a scale of 10 to 20?\n”Slide35

#include

<

iostream

> #include

<algorithm> #include <vector> using namespace std;

int

main() {

vector<int> v; int i = 0; cout << "Please enter some numbers: "; while( cin >> i ) v.push_back(i); sort( begin(v), end(v) ); cout << "Here are those numbers, sorted:"; for( auto& e : v ) cout << ' ' << e; cout << endl;}How Easy Is C++, Really? 15 LOC ExampleSlide36

Reality check

C++ is about

exploiting the machine

Standard C++ doesn’t exploit my 1979 Atari

Image credit:

Bilby

(via Wikipedia)Addressable text modes: get/set (x,y)Graphics modes up to 320x192 @ 1.5 colorsSlide37

#

include "cinder/app/

AppBasic.h

"#include "cinder/dx/

dx.h"#include <vector>using namespace ci;using namespace ci::app

;

class

MyApp : public AppBasic { std::vector<Vec2f> points;public: void mouseDrag( MouseEvent e ) { points.push_back(e.getPos()); } void draw() { dx::clear( Color( 0.1f, 0.1f, 0.15f ) ); dx::color( 1.0f, 0.5f, 0.25f );  dx::begin( GL_LINE_STRIP ); for( auto& e : points ) dx::vertex(e); dx::end(); }};CINDER_APP_BASIC( MyApp, RendererDx )How Easy Is C++, Really? 18 LOC ExampleSlide38

How Easy Is C++, Really?

200

LOC Example

Time: One afternoon

From scratch, incl. installing & learning Cinder, and incl. 1h lost on a GL bug

Line count (nonempty)

9

: #include / using34: data86: game logic60: graphics + inputIncluding board display, player animation, powerup color flashing and warning transitions, …5%18%45%32%Slide39

Q: How many people here are developers?Slide40

Q2: How many of you brought a compiler?Slide41

Q3: … and used it already?

Gauntlet:

What creative graphics app can

you

build

tonight

?

Use a favorite compiler and target OSFrom scratch = empty projectUsing only Standard C++ plus either openFrameworks (openframeworks.cc) or Cinder (libcinder.org; for DX, search “cinder site:msdn.com”)Email your name and screenshot(s)/video to ctorre@microsoft.comTell us about it for 2 min tomorrowThis is what I built from scratch in an afternoonSlide42

Slide courtesy Rick BarrazaSlide43

Slide courtesy Rick BarrazaSlide44

Slide courtesy Rick BarrazaSlide45

Slide courtesy Rick BarrazaSlide46

Slide courtesy Rick BarrazaSlide47

Slide courtesy Rick BarrazaSlide48

Just Getting Organized: 2D Graphics

“Draft” proposed initial scope

Initial thinking, subject to change:

Modern C++11/14 API for 2D + text. Audio and 3D separate, but combinable (e.g., 2D as HUD over 3D). Flexible, not a “game engine.” Thin, not a new platform or Big-F Framework.

Immediate mode + sprites/particles/input. Later: retained mode. Included-but-optional default graphics loop.native_handle

hook.

Implementable

on at least DX & OpenGL + native_handle gateway to platform-specific code. Asset loading/construction hook. Included-but-optional default “load asset from file” + simple way to plug into user’s asset system (maybe ‘load from memory’ suffices?).Major C++ graphics librariesInviting participation from:openFrameworksCinderSFMLLibSDLQtDirectXTKCocos2DGraphucksHieroglyph…Slide49

PCL Scope

Do

focus on pure libraries.

Do focus on common modern tasks with state-of-the-art existing practice.Lower-level: Message queue, ranges + range algorithms, parallel algorithms, thread-safe containers

, continuations (future.then), async I/O, file system, networking/sockets, serialization.

Higher-level:

REST web services, sensor fusion, HTTP, HTML,

XML/XSLT, JSON, persistence, settings/preferences, compression, cryptography, audio/image/video, databases, SMS messaging.Don’t target niche uses. (Example: Sci-eng linear algebra.)Don’t become a platform = fat libs that duplicate native services.Don’t attempt to define a “portable cross-platform” library that will be inferior to a native platform app. (Example: GUI WIMP widgets.)GN’12Slide50

PCL Scope

Do

focus on pure libraries.

Do focus on common modern tasks with state-of-the-art existing practice.Lower-level: Message queue, ranges + range algorithms, parallel algorithms, thread-safe containers

, continuations (future.then), async I/O, file system, networking/sockets, serialization.

Higher-level:

REST web services, sensor fusion, HTTP, HTML,

XML/XSLT, JSON, persistence, settings/preferences, compression, cryptography, audio/image/video, databases, SMS messaging.Don’t target niche uses. (Example: Sci-eng linear algebra.)Don’t become a platform = fat libs that duplicate native services.Don’t attempt to define a “portable cross-platform” library that will be inferior to a native platform app. (Example: GUI WIMP widgets.)Lower-level: Message queue, ranges + range algorithms, parallel algorithms, thread-safe containers, continuations (future.then), async I/O, file system, networking/sockets, serialization.Higher-level: REST web services, sensor fusion, HTTP, HTML, XML/XSLT, JSON, persistence, settings/preferences, compression, cryptography, audio/image/video, databases, SMS messaging.GN’12Slide51

Next: De Facto

“De facto” portable libraries

Few exemplars today (e.g.,

core Boost)Find by word of mouthDownload and install on your ownQ: What more is needed?Think

“PyPI + apt-get” for C++ libsDiscovery: Catalog, filtering, reviewsAcquisition: Package management, installation, project integrationNascent today:

MacPorts

,

NuGet (Fri)Slide52

Visual C++ Roadmap Update

ISO C++ Update

Portable C++ Libraries Update

One C++

AgendaSlide53

Observation

The world has never had

“One C++”Slide54

Standard vs. implementations

Having a standard is great.

But: Multi-year lag until (mostly) conforming implementations available.

Implementation A vs. implementation BVendors implementing the standard is great.But: Vendor A implements different snapshots of draft standard features than vendor B, while the standard is still changing. (Example: &&.)But: Vendor A implements features in a different order than vendor B.

“The nice thing about standards is that there are so many to choose from.”— Andrew Tanenbaums/standards/de facto implementations/The world has never had “One C++”Slide55

198x-1998: Pre-Standard Wild West

Competing template instantiation models, etc.

What’s this “STL” you speak of?

1998-2003: Partial convergenceCompilers implemented features in different ordersSome features were never widely implemented: export, std:: hoisting

2003-2011: C++0x — for(;;) ++x;Compilers implemented different versions of features in different orders“Each did that which was right in his own eyes”2011-2013: Approaching first convergence

Digesting a decade-sized package of features once it stopped changing

“The nice thing about standards is that there are so many to choose from.”

— Andrew Tanenbaums/standards/de facto implementations/The world has never had “One C++”Slide56

This has been a landmark summer

May 31: GCC 4.8.1 ships complete C++11 language

4.9 to have complete C++11

lang & libJune 5: Clang 3.3 ships complete C++11 lang & libComparison: Time to full conformanceC++98: 5 years

* (2003, EDG + Dinkumware)C++11: 2 years (2013, Clang)C++14: 0 years (2014, probably multiple)

“The nice thing about standards is that there are so many to choose from.”

— Andrew Tanenbaum

s/standards/de facto implementations/MilestonesSlide57

2013: Two major C++11 language implementations

June: GCC 4.8.1 and Clang 3.3

2014: Two major C++11 complete implementations

Probably early 2014: GCC 4.9 expected to join Clang 3.3+2014-15

: Multiple C++14 complete implementationsMy personal estimates, not official:Clang: Releasing every 6-7 months (Jun/Dec), likely to make “14 in 14.”GCC: Releasing every spring, 4.9 may not get all the way (?), but if not then the next one seems likely to make “14 in just-past-14.”VC++: No ETA yet (will keep you posted). Targeting whole “C++14 wave” incl. Concepts.

“The nice thing about standards is that there are so many to choose from.”

— Andrew Tanenbaum

s/standards/de facto implementations/“One C++”Slide58

Until 2013, the

world

had never

enjoyed even one

of the following, and we’ve still never had all three:Slide59

Until 2013, the

world

had never

enjoyed even one

of the following, and we’ve still never had all three:

Multiple consistent

C++ products

(never)with 100% conformance modulo bugs (first in 2013)in the same year the standard is published (never)Slide60

Multiple consistent

C++ products

with

100%

conformance modulo bugs

in the

same year

the standard is publishedStarting in 12-18mo, this could be the new normalSlide61

Observation

We are

rapidly

approaching

One C++