+ All Categories
Home > Documents > New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History...

New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History...

Date post: 17-Oct-2020
Category:
Upload: others
View: 2 times
Download: 0 times
Share this document with a friend
30
Evolution of C++ Tuukka Haapasalo Overview History C with Classes Early C++ ARM C++ Standard Template Library ISO C++: C++98 Future C++0x Afterwards References Evolution of C++ Tuukka Haapasalo October 13, 2009
Transcript
Page 1: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

Evolution of C++

Tuukka Haapasalo

October 13, 2009

Page 2: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

Outline

1 Overview

2 HistoryC with ClassesEarly C++ARM C++Standard Template LibraryISO C++: C++98

3 FutureC++0xAfterwards

4 References

Page 3: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

Overview

Basics of C++Designed (mostly) by Bjarne Stroustrup.

Begun as PhD work in Cambridge University, England.From the C++ Programming Language book: C++ is ageneral purpose programming language designed to makeprogramming more enjoyable for the serious programmer.Goal: Simula’s facilities for program organization with C’sefficiency and flexibility for systems programming [4].Not (merely) an object-oriented language, but amulti-paradigm language.Static types and compile-time type checking.Separation: OS is kept separate from the language.Design now controlled by ISO C++ standards committee.

Page 4: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

Origins

Stroustrup was working with Simula on his Ph.D. thesis in theComputing Laboratory of Cambridge University, England.

Languages at the timeSimula was a good language, but the implementation wasnot efficient.BCPL was efficient, but too low-level for large-scaleapplications.

Page 5: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

Evolution

Page 6: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

Usage

How many programmers use C++?1980 161985 5001987 40001988 150001990 1500001991 400000. . .2004 3270000

Page 7: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

Popularity of Programming Languages

From a survey by Tiobe Softwares in Jan 2009 [2]:

Page 8: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

Usage

Where is C++ used? [5]Adobe Acrobat, Photoshop, Illustrator, . . .AmazonApple iPod, finder, . . .eBayGames (Doom 3, StarCraft, Halo, . . . )Google search engines, Google Earth, . . .MayaMicrosoft Windows XP, Office, IE, Visual Studio, .NET,. . .Mozilla FirefoxSun compilers, OpenOffice, HotSpot Java Virtual MachineSymbian OS

Page 9: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

Extends Classic C

Why C? [4]C is flexible, efficient, available, and portable.

Why not a completely separate language?Provides easy transition from and interoperability with C.Possible to implement as a C front-end (e.g., Cfront a).Available now, or next month, rather than in two years.Use standard linker.Interoperability with other languages.Close to the machine.

aIn Cfront, C compiler is used only as a code generator

Page 10: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

History of C++

HistoryWhat is the history of the C++ language?

Page 11: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

C with Classes

C with ClassesImplemented as a C preprocessor in 1980.Simple classes and class hierarchies for organizing data.

Derived and base classes instead of sub- and super-Classes could have member functions, constructors,destructors, etc.Not claimed to support object-oriented programming.No virtual functions, templates, or any other advancedfeatures of C++.Also had call and return functions.

Class functions called before and after calls to any otherclass functions.

Inline functions, default arguments and assignmentoperator overloading added in 1981.

Page 12: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

C++

In 1982, Stroustrup realized that C with Classes was amedium success, and would remain so.

C with Classes did help organize a large class of problemsbetter than C,but it was not attractive enough to continue developingand supporting.

The new extended language was first named C84, but thiswas deemed too institutional.The name C++ was suggested by Rick Mascitti in 1983.

Page 13: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

Some first features of C++

AdditionsVirtual functions

From Simula, to prevent switch(type) style constructsFunction name and operator overloading

Experience of operator overloading from Algol68References

Provided to support operator overloading, experiencesfrom Algol68

Constants

The notion of call and return functions was removed from thelanguage because it was not used.

Page 14: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

The stream I/O library

First implemented in 1984 and presented in 1985.Created as a type-safe, extensible and efficient alternativeto the printf function.

ExampleIn classic C:/* Primitive types */fprintf (stderr ,

"x = %.2f\n", x);

/* Custom types */fprintf (stderr , "x = ");put_complex (stderr , x);fprintf (stderr , "\n");

In C++:/* All types */cerr << "x = " << fixed << setprecision (2)

<< x << "\n";

Java (old style):/* Primitive types */NumberFormat n = new DecimalFormat ("#.##");System .out. println ("x = " + n. format (x) + "\n");

Page 15: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

The “whatis?” paper

What is object-oriented programming? [3], originallypresented at the 1986 ASU conference (Association ofSimula Users) in Stockholm.Listed missing features of C++:

Parametrized typesExceptionsMultiple inheritance

Example of planned exceptions [3]

class vector {void f() { if (...) raise vector_range ; }except vector_range {

error (" global : vector range error ;");exit (99); }

};void f() {

vector v; try { v.f(); }except { vector :: vector_range :

error (" vector range error "); }}

Page 16: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

C++ 2.0

Second major release of C++ in 1987.Some features:

Multiple inheritanceAbstract classesStatic and const member functions

Featured a space optimization in comparison to theprevious release, which had separate virtual function tablesfor each compilation unit.

Page 17: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

ARM C++

The Annotated C++ Reference Manual [1] in 1990 (or1989).The reference manual covers entire C++ (at the time),including planned features:

TemplatesException handling

These were planned from the start, but had beenpostponed.

Includes annotations that explain why some features aredesigned as they are and how they might be implemented.First “standard” for the C++ language.

Page 18: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

Standard Template Library

A container library supporting generic programming.Basic idea was to create the most general and mostefficient code.Stroustrup found out about Alex Stepanov’s STL library in1993.

Stepanov had worked with the ideas for over a decadebefore this.

STL code may seem quite complicated (e.g., cryptic errormessages).

It took weeks for Stroustrup to get comfortable with STL.

Page 19: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

Container checklist

Stroustrup has developed a checklist of important propertiesfor containers [5]:

Individual containers are simple and efficient.Simple operations do not require function calls.Statically type safe and homogenous.Containers are non-intrusive.Containers can contain primitive types.. . .Common services can be provided in a single place (e.g.,base class).

STL fulfilled every point except the last one.

Page 20: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

STL usage

Simple usage

vector <int >:: iterator p = find(v. begin (), v.end (), 7);

/* This can be implemented with a template : */while ( first != last && * first != val)

++ first ;

The crucial point in this example is that this same templatewill work both with iterator types that are classes and with intpointers, for example.

Page 21: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

STL usage

Lambda emulationlist <int > lst;Lambda x;list <int >:: iterator p = find_if (lst. begin (), lst.end (), x < 7);

/* This can be implemented with a template : */while ( first != last && !pred (* first ))

++ first ;

template < class T>class Lambda {

LessThan <T> operator <( const T & v) {return LessThan <T >(v);

}};

class Lambda {};template < class T>LessThan <T> operator <( Lambda , const T & v) {

return LessThan <T >(v);}

Page 22: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

STL usage

Lambda emulationlist <int > lst;Lambda x;list <int >:: iterator p = find_if (lst. begin (), lst.end (), x < 7);

/* This can be implemented with a template : */while ( first != last && !pred (* first ))

++ first ;

template < class T>class Lambda {

LessThan <T> operator <( const T & v) {return LessThan <T >(v);

}};

class Lambda {};template < class T>LessThan <T> operator <( Lambda , const T & v) {

return LessThan <T >(v);}

Page 23: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

STL usage

Lambda emulationlist <int > lst;Lambda x;list <int >:: iterator p = find_if (lst. begin (), lst.end (), x < 7);

/* This can be implemented with a template : */while ( first != last && !pred (* first ))

++ first ;

template < class T>class Lambda {

LessThan <T> operator <( const T & v) {return LessThan <T >(v);

}};

class Lambda {};template < class T>LessThan <T> operator <( Lambda , const T & v) {

return LessThan <T >(v);}

Page 24: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

ISO C++: C++98 (ISO/IEC 14882:1998)

The C++ standard [5, 6]Some new features:

NamespacesRun-time type identification (RTTI)Boolean type

Includes the standard library, which includes the STL.

What was left outConcurrency (no clear idea what would be best approach,libraries can be used)More useful libraries (not enough resources, STL requiredmuch work)GUI (see previous)

Page 25: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

C++ Standard Library

C standard libraryThe STLiostreams

locales

string

bitset

complex

valarray

auto_ptr

Page 26: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

Updates to the standard

2003: C++03 (ISO/IEC 14882:2003)

Corrected version of the standard.Contains just minor corrections.

2004: Technical Report (TR) (ISO/IEC PDTR 18015)

Technical Report on C++ PerformanceEmbedded C++, or EC++ for embedded systems programming.Subset of C++ (almost).

2005: The Library TR (TR1) (ISO/IEC PDTR 19768)

Technical Report on C++ Standard Library ExtensionsExtensions to the standard librariesTuple types, regexp, smart pointers, random, hash tables. . .

Page 27: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

Future of C++

FutureWhat is the future of the C++ language?

Page 28: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

Next C++ standard: C++0x [5, 7]

C++0xWill come out earliest at the end of 2011 (C++0B?)Some planned features:

Move semantics (vector<int> a = f();)Generalized constant expressions (constexpr)Initializer lists (Sequence s = { 1, 4, 5, 6 };)Type inference (auto, decltype)Range-based for-loop (for(int &x : my_array))Lambda functions and expressions

[](int x, int y) { return x + y; }

Construction improvement (calls to peer constructors)Null pointer constant (nullptr)Variadic templates

template<typename... Values> class tuple;

Static assertions

Page 29: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

Future

What next? [5]Stroustrup: C++ is the most successful traditionalsystems programming language.Stroustrup predicts a C++1x standard will come afterC++0x.Next technical report (TR2) expected after C++0x.

Page 30: New Evolution of C++ · 2009. 10. 14. · Evolutionof C++ Tuukka Haapasalo Overview History CwithClasses EarlyC++ ARMC++ StandardTemplate Library ISOC++: C++98 Future C++0x Afterwards

Evolution ofC++

TuukkaHaapasalo

Overview

HistoryC with Classes

Early C++

ARM C++

Standard TemplateLibrary

ISO C++: C++98

FutureC++0x

Afterwards

References

References I

[1] M. Ellis and B. Stroustrup.The annotated C++ reference manual.Addison-Wesley Longman Publishing Co., Inc. Boston, MA, USA, 1990.

[2] T. Softwares.Popularity of programming languages: January 2009, 2009.http://www.hurricanesoftwares.com/popularity-of-programming-languages-january-2009/.Referenced on 6.10.2009.

[3] B. Stroustrup.What is object-oriented programming?IEEE Software, 5(3):10–20, 1988.

[4] B. Stroustrup.A history of C++: 1979–1991.ACM SIGPLAN Notices, 28(3), Mar 1996.

[5] B. Stroustrup.Evolving a language in and for the real world: C++ 1991-2006.In Proceedings of the 3rd ACM SIGPLAN Conference on History of Programming Languages, pages1–58. ACM New York, NY, USA, 2007.

[6] Wikipedia.C++.http://en.wikipedia.org/wiki/C++. Referenced on 2.10.2009.

[7] Wikipedia.C++0x.http://en.wikipedia.org/wiki/C++0x. Referenced on 2.10.2009.


Recommended