-
Notifications
You must be signed in to change notification settings - Fork 6
/
00_foreword.html
211 lines (167 loc) · 9.3 KB
/
00_foreword.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>Foreword</title>
<link rel="stylesheet" href="template/style.css">
</head>
<body>
<span style="float: right">
[
<a href="">previous</a>,
<a href="index.html">contents</a>,
<a href="01_data_structures.html">next</a>
]
</span>
<a name="Foreword"></a>
<h1>Foreword</h1>
<p>Alexander Stepanov is well-known for being the creator of the C++ “Standard Template Library” (STL).
Anyone who has used <code>std::vector</code> has benefited from his work.
Much less well-known is that STL is not just a collection
of common routines;
it’s an ecosystem for a <em>theory of programming</em>
championed by Alex called <strong>generic programming</strong>.
For those not familiar with the ideas of generic programming, the STL
can be a confusing and verbose mess.
But with just a short introduction to generic
programming
principles, its thoughtful design and capability
for writing reusable and correct code become clear.
These lectures are intended to teach exactly that.</p>
<p>Programming, as distinct from computer science,
tends to be described as a craft or art,
rather than a field of science or engineering.
It’s learned by experience and by studying a loose collection
of examples and rules passed down;
don’t make functions “too long,” hide “unnecessary” details
in abstractions, group “similar” functionality,
don’t use global variables,
avoid duplicating code.
While these hint at some truly good ideas, they also
suggest that perhaps the field’s underlying principles
have yet to be understood.</p>
<p>Much more than anything in particular about C++,
Alex’s work is about discovering these principles.
It’s about the basic logic and math which govern programs.
The power of this foundational approach is being recognized in more areas.
(For example, see Apple’s WWDC session on <a href="https://developer.apple.com/videos/play/wwdc2015/408/">Protocol-Oriented Programming</a>.)</p>
<p>Generic programming starts with algorithms.
Given an algorithm, how do we know it will work?
To answer this question, a programmer must discover its essential mechanism
and, consequently, the minimal requirements for it to work.
These requirements are described as mathematical
constraints on the algorithm’s inputs.
From this understanding, we can <em>express</em> the algorithm
in an implementation useful for others, called a <strong>component</strong>.
Complex programs are written simply by combining simple
components that are well understood.</p>
<p>Components facilitate abstraction and code reuse through minimalism;
code is reduced to its essential function,
as opposed to traditional black-box layering
which merely hides information.
Programs written this way also tend to be fast,
which contributes to their reusability.
If a component doesn’t perform,
there will always be some performance-sensitive application
that can’t use it.
Of course, not every algorithm is the best choice for all needs,
but those limitations should be imposed by the algorithm,
not the implementation.</p>
<p>Alex’s work makes an additional contribution
to the question, what does developing software look like in the future?
Will we scavenge for snippets to piece together from the GitHub junkyard?
Will programs be carefully specified and verified with formal proof systems?
Can you <code>npm install banking-app-starter-template</code> and
start customizing?
Are all programs written by hobbyist C artisans? (the vision I’m most partial to)</p>
<p>Alex derives a different model from generic programming,
resembling engineering as done in other fields.
Mathematicians and computer scientists discover algorithms.
Software engineers work together as an industry to implement these as
standard components with a high degree of professionalism.
These are distributed as standardized catalogs.
Each component is documented in detail, with references to academic literature.
They specify their requirements and complexity in mathematical terms.
It displays graphs of their performance on various data sets.
Programmers carefully select components that fit their needs
and assemble them into applications.
To understand these catalogs and make contributions of their own,
programmers must be educated in basic mathematics
and computer science
in the same way that engineers require physics and calculus.</p>
<p>– Justin Meiners</p>
<a name="Acknowledgments"></a>
<h1>Acknowledgments</h1>
<p>Original course by Alexander. A. Stepanov.</p>
<p><img src="img/alex.jpg" alt="alex" /></p>
<p>Course notes were assembled from videos, course materials, interviews,
and books by <a href="https://github.com/justinmeiners">Justin Meiners</a> in 2021.
The lectures were given in 2013 at <a href="https://en.wikipedia.org/wiki/A9.com">A9</a>.
These notes are intended to share scientific information for educational and historical purposes. This is a non-commercial project.
Most of the code comes from <a href="https://github.com/rjernst">Ryan Ernst’s repo</a>, who attended the lectures.</p>
<p>Special thanks to <a href="https://github.com/aharrison24">Alastair Harrison</a> for his significant efforts editing and providing feedback.</p>
<p>The following people also helped provide corrections:
<a href="https://github.com/petter-holmberg">Petter Holmberg</a>, <a href="https://github.com/rpendleton">Ryan Pendleton</a>, Frank Ettwein, <a href="https://github.com/yuroller">Yuri Valentini</a>.</p>
<a name="FAQ"></a>
<h1>FAQ</h1>
<p><strong>Why do we need these notes if we can watch the <a href="https://www.youtube.com/watch?v=aIHAEYyoTUc&list=PLHxtyCq_WDLXryyw91lahwdtpZsmo4BGD">videos</a>?</strong></p>
<p>This has all the information in an organized form, with references
and working code.</p>
<p>The videos are often hard to watch due to the slow pace and interaction with the audience.
Sometimes a mistake is made, and they go back and fix it.
Alex may introduce a story and then finish it days later.
Consequently, some videos have fewer than 800 views, and at least 10 of those views are mine.</p>
<p><strong>Is all this information available in his books?</strong></p>
<p>A majority of the information, but not the code, is available in other forms.
In these lectures, you get history, opinions, motivation, practical tips, applications, and responses to criticism, all at once.
This is not present in the books, especially “Elements of Programming” which is very formal.
Having this rich context makes the books much more approachable and meaningful.</p>
<p><strong>This is ten years old. Is it relevant for a C++ programmer today?</strong></p>
<p>Absolutely. He will almost certainly teach you applicable things about
current-day C++ and STL you did not know.</p>
<p><strong>Is this relevant for a non-C++ programmer?</strong></p>
<p>These ideas are not limited to C++ and are being adopted
in more and more libraries and languages.
I hardly ever write C++ anymore.
But, if you have no familiarity with C++, then
this presentation will probably be difficult
to follow.
Try the first lesson.</p>
<p><strong>How similar is Alex’s vision to the “modern C++” style?</strong></p>
<p>The emphasis on value types and templates over dynamically allocated
objects with virtual members is similar,
but I think that’s where the similarities end.</p>
<p>It’s important to emphasize that this is not a style guide,
but a theory of programming.
The C++ style is then one way of representing this theory in C++.</p>
<p>In my opinion, (somewhat supported by various comments made by Alex),
most developments since C++11 seemed to have missed the point of STL.
A lot of it has been partially understood and remixed in strange and inconsistent ways.
Things which were understood, are no longer (see <a href="https://sean-parent.stlab.cc/papers-and-presentations/#warning-stdfind-is-broken">std::find is broken</a>).</p>
<p>If you study these notes, you will find that Alex outlined much cleaner solutions to many of the problems which later C++ versions attempt to address.
The most baffling of these to me are three-way comparison and ranges.
I am unsure of his opinion on move semantics.
I am unable to comment on whether the Concepts which made it into C++20
are anything like his original vision.</p>
<p><strong>I have a correction, additional reference, or other helpful idea.</strong></p>
<p>Please, make a <a href="https://github.com/justinmeiners/efficient-programming-with-components">pull request</a>.
Corrections are welcome and needed.
However, be aware that some of the awkwardness of grammar
comes from the speaker and is intentionally preserved.</p>
<p><strong>How accurate is this text?</strong></p>
<p>The goal of this project is to provide course notes, not a transcript.
I try to discern and communicate his intended message,
not necessarily make a historical record of the conversation.</p>
<p>If Alex is sharing a strong opinion or giving a speech,
I usually quote him exactly (with corrections to grammar) to avoid misinterpreting him.
The technical exposition is where significant rearrangements and have been made for educational purposes.</p>
<span style="float: right">
[
<a href="">previous</a>,
<a href="index.html">contents</a>,
<a href="01_data_structures.html">next</a>
]
</span>
</body>
</html>