没有合适的资源?快使用搜索试试~ 我知道了~
Thriving in a Crowded and Changing World: C++ 2006–2020
0 下载量 22 浏览量
2024-05-14
20:57:56
上传
评论
收藏 1.25MB PDF 举报
温馨提示
试读
168页
这份文件是 Bjarne Stroustrup 撰写的关于 C++ 语言从 2006 年到 2020 年发展的文章,标题为 "Thriving in a Crowded and Changing World: C++ 2006–2020"。Bjarne Stroustrup 是 C++ 语言的创始人,文章讨论了 C++ 在面对新兴编程模型、硬件架构演变、新应用领域的重要性增加以及许多有资金支持和专业营销的其他编程语言的竞争中如何保持活力。
资源推荐
资源详情
资源评论
70
Thriving in a Crowded and Changing World: C++ 2006–2020
BJARNE STROUSTRUP, Morgan Stanley and Columbia University, USA
Shepherd: Yannis Smaragdakis, University of Athens, Greece
By 2006, C++ had been in widespread industrial use for 20 years. It contained parts that had survived unchanged
since introduced into C in the early 1970s as well as features that were novel in the early 2000s. From 2006 to
2020, the C++ developer community grew from about 3 million to about 4.5 million. It was a period where
new programming models emerged, hardware architectures evolved, new application domains gained massive
importance, and quite a few well-nanced and professionally marketed languages fought for dominance. How
did C++ ś an older language without serious commercial backing ś manage to thrive in the face of all that?
This paper focuses on the major changes to the ISO C++ standard for the 2011, 2014, 2017, and 2020 revisions.
The standard library is about 3/4 of the C++20 standard, but this paper’s primary focus is on language features
and the programming techniques they support.
The paper contains long lists of features documenting the growth of C++. Signicant technical points are
discussed and illustrated with short code fragments. In addition, it presents some failed proposals and the
discussions that led to their failure. It oers a perspective on the bewildering ow of facts and features across
the years. The emphasis is on the ideas, people, and processes that shaped the language.
Themes include eorts to preserve the essence of C++ through evolutionary changes, to simplify its use, to
improve support for generic programming, to better support compile-time programming, to extend support
for concurrency and parallel programming, and to maintain stable support for decades’ old code.
The ISO C++ standard evolves through a consensus process. Inevitably, there is competition among proposals
and clashes (usually polite ones) over direction, design philosophies, and principles. The committee is now
larger and more active than ever, with as many as 250 people turning up to week-long meetings three times
a year and many more taking part electronically. We try (not always successfully) to mitigate the eects of
design by committee, bureaucratic paralysis, and excessive enthusiasm for a variety of language fashions.
Specic language-technical topics include the memory model, concurrency and parallelism, compile-time
computation, move-semantics, exceptions, lambda expressions, and modules. Designing a mechanism for
specifying a template’s requirements on its arguments that is suciently exible and precise yet doesn’t
impose run-time costs turned out to be hard. The repeated attempts to design łconceptsž to do that have their
roots back in the 1980s and touch upon many key design issues for C++ and for generic programming.
The description is based on personal participation in the key events and design decisions, backed by the
thousands of papers and hundreds of meeting minutes in the ISO C++ standards committee’s archives.
CCS Concepts:
· Software and its engineering → Software notations and tools
;
General programming
languages;
Additional Key Words and Phrases: C++, programming language design and evolution, standardization, generic
programming, resource management, concurrency and parallelism, simplication of language use
ACM Reference Format:
Bjarne Stroustrup. 2020. Thriving in a Crowded and Changing World: C++ 2006ś2020. Proc. ACM Program.
Lang. 4, HOPL, Article 70 (June 2020), 167 pages. https://doi.org/10.1145/3386320
Author’s address: Bjarne Stroustrup, Morgan Stanley and Columbia University, USA, Bjarne@Stroustrup.com.
Permission to make digital or hard copies of part or all of this work for personal or classroom use is granted without fee
provided that copies are not made or distributed for prot or commercial advantage and that copies bear this notice and
the full citation on the rst page. Copyrights for third-party components of this work must be honored. For all other uses,
contact the owner/author(s).
© 2020 Copyright held by the owner/author(s).
2475-1421/2020/6-ART70
https://doi.org/10.1145/3386320
Proc. ACM Program. Lang., Vol. 4, No. HOPL, Article 70. Publication date: June 2020.
This work is licensed under a Creative Commons Attribution-NoDerivatives 4.0 International License.
70:2 Bjarne Stroustrup
Contents
Abstract 1
Contents 2
1 Introduction 5
1.1 Chronology 6
1.2 Overview 7
2 Background: C++ 1979ś2006 7
2.1 The First Decade 7
2.2 The Second Decade 10
2.2.1 Language Features 10
2.2.2 Standard-Library Components 12
2.3 C++ in 2006 13
2.4 Other Languages 16
3 The C++ Standards Committe e 17
3.1 The Standard 18
3.2 Organization 18
3.3 Impact on Design 21
3.4 Proposal Checklists 28
4 C++11: It Feels Like a New Language 29
4.1 C++11: Support for Concurrency 31
4.1.1 Memory Model 31
4.1.2 Threads and Locks 33
4.1.3 Futures 35
4.2 C++11: Simplifying Use 37
4.2.1 auto and decltype 38
4.2.2 Range-for 41
4.2.3 Move Semantics 42
4.2.4 Resource-Management Pointers 44
4.2.5 Uniform Initialization 45
4.2.6 nullptr 48
4.2.7 constexpr Functions 48
4.2.8 User-Dened Literals 50
4.2.9 Raw literals 51
4.2.10 Attributes 51
4.2.11 Garbage Collection 52
4.3 C++11: Improving Support for Generic Programming 52
4.3.1 Lambda 53
4.3.2 Variadic Templates 55
4.3.3 Aliases 56
4.3.4 tuples 58
4.4 C++11: Increase Static Type Safety 59
4.5 C++11: Support for Library Building 60
4.5.1 Implementation Techniques 60
4.5.2 Metaprogramming Support 61
4.5.3 noexcept Specications 61
4.6 C++11: Standard-Library Components 62
5 C++14: Completing C++11 63
Proc. ACM Program. Lang., Vol. 4, No. HOPL, Article 70. Publication date: June 2020.
Thriving in a Crowded and Changing World: C++ 2006ś2020 70:3
5.1 Digit Separators 64
5.2 Variable Templates 65
5.3 Function Return Type Deduction 65
5.4 Generic Lambdas 65
5.5 Local Variables in constexpr Functions 66
6 Concepts 67
6.1 The Prehistory of Concepts 68
6.2 C++0x Concepts 69
6.2.1 Concept Denitions 70
6.2.2 Concept Use 72
6.2.3 Concept Maps 72
6.2.4 Denition Checking 73
6.2.5 Lessons Learned 73
6.2.6 What Went Wrong? 75
6.3 The Concepts TS 77
6.3.1 Denition Checking 78
6.3.2 Concept Use 79
6.3.3 Concept Denition 81
6.3.4 Concept Name Introducers 82
6.3.5 Concepts and Types 82
6.3.6 Improvements 84
6.3.7 Syntax Equivalences 84
6.3.8 Why No Concepts in C++17? 86
6.4 C++20 Concepts 86
6.5 Naming of Concepts 88
7 Error Handling 89
7.1 Background 89
7.2 Real-World Problems 90
7.3 noexcept Specications 92
7.4 Type System Support 92
7.5 Back to Basics 93
8 C++17: Lost at Sea 95
8.1 Constructor Template Argument Deduction 96
8.2 Structured Bindings 96
8.3 variant, optional, and any 99
8.4 Concurrency 100
8.5 Parallel STL 101
8.6 File System 102
8.7 Explicit Tests in Conditions 103
8.8 Proposals That Didn’t Make C++17 104
8.8.1 Networking 104
8.8.2 Operator Dot 104
8.8.3 Uniform Call Syntax 105
8.8.4 Default Comparisons 106
9 C++20: A Struggle for Direction 109
9.1 Design Principles 109
9.2 My C++17 List 110
9.3 C++20 Features 111
Proc. ACM Program. Lang., Vol. 4, No. HOPL, Article 70. Publication date: June 2020.
70:4 Bjarne Stroustrup
9.3.1 Modules 111
9.3.2 Coroutines 114
9.3.3 Compile-Time Computation Support 117
9.3.4 <=> 118
9.3.5 Ranges 119
9.3.6 Dates and Time Zones 120
9.3.7 Format 120
9.3.8 Span 121
9.4 Concurrency 123
9.5 Minor Features 123
9.6 Work in Progress 124
9.6.1 Contracts 124
9.6.2 Static Reection 127
10 C++ in 2020 128
10.1 What Is C++ Used For? 129
10.2 The C++ Community 130
10.3 Education and Research 131
10.4 Tools 132
10.5 Programming Styles 133
10.5.1 Generic Programming 134
10.5.2 Metaprogramming 134
10.6 Coding Guidelines 136
10.6.1 General Approach 136
10.6.2 Static Analysis 137
11 Retrospective 139
11.1 The C++ Model 139
11.2 Technical Successes 139
11.3 Areas That Need Work 140
11.4 Lessons Learned 141
11.5 The Future 143
Acknowledgments 144
References 145
Proc. ACM Program. Lang., Vol. 4, No. HOPL, Article 70. Publication date: June 2020.
Thriving in a Crowded and Changing World: C++ 2006ś2020 70:5
1 INTRODUCTION
Originally, I designed C++ to answer to the question łHow do you directly manipulate hardware
and also support ecient high-level abstraction?ž Over the years, C++ has grown from a relatively
simple solution based on a combination of facilities from the C and Simula languages aimed
at systems programming on 1980s computers to a far more complex and eective tool for an
extraordinary range of applications. It retains its dual focus on:
• Direct mapping of language constructs to hardware facilities
• Zero-overhead abstraction
This combination is the dening characteristic that sets C++ apart from most languages.
łZero overheadž was explained like this [
Stroustrup 1994]:
• What you don’t use, you don’t pay for (aka łno distributed fatž).
• What you do use, you couldn’t hand-code any better.
Abstractions are represented in code as functions, classes, templates, concepts, and aliases.
C++ is a living language, so it changes to meet new challenges and the styles of use evolve. These
challenges and changes in the 2006-to-2020 time-frame are the focus of this paper. Of course, a
language doesn’t change by itself; it is changed by people. So this is also the story of the people
involved in the evolution of C++, the way they perceived the challenges, interpreted the constraints
on solutions, organized their work, and resolved their inevitable dierences. When presenting a
language or standard-library feature, I do so in the context of the general evolution of C++ and
the concerns of the individuals involved at the time. For many features accepted early in the time
period, we now have the benet of hindsight from massive industrial use.
C++ is primarily an industrial language, a tool for building systems. For a user, łC++ž is not just
a language as dened by a specication; it is part of a tool set with many parts:
• The language
• The standard library
• Many other libraries
• Massive ś often old ś code bases
• Tools (including other languages)
• Teaching and training
• Community support
Where possible and relevant, I will consider the interactions among those łparts.ž
There is a myth, a very popular myth, that programmers want their languages to be simple.
That’s obviously the case when you have to learn a new language, have to design a programming
course or curriculum, or describe a language in an academic paper. For such uses, having a language
cleanly embody a few clear principles is an obvious advantage and the ideal. When the focus shifts
from learning to delivering and maintaining signicant applications, the demands from developers
shift from simplicity to comprehensive support, stability (compatibility), and familiarity. People
invariably confuse familiarity with simplicity and prefer familiarity over simplicity if given a choice.
One way of looking at C++ is as the result of decades of three contradictory demands:
• Make the language simpler!
• Add these two essential features now!!
• Don’t break (any of) my code!!!
I added the exclamation marks because these p oints are often delivered with a fair bit of emotion.
I wanted to make simple things simple and to ensure that complex things are not impossible or
unnecessarily hard. The former is essential for developers who are not language lawyers; the later
Proc. ACM Program. Lang., Vol. 4, No. HOPL, Article 70. Publication date: June 2020.
剩余167页未读,继续阅读
资源评论
CodecConductor
- 粉丝: 7973
- 资源: 33
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功