summaryrefslogtreecommitdiff
path: root/where_to_learn_cxx.html
blob: 4fd9263518bf976052caacf31d3a8ce30040449d (plain)
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="aki">
<meta name="tags" content="C++, resources, literature, documentation">
<meta name="published-on" content="2024-06-23T23:34:33+02:00">
<link rel="icon" type="image/png" href="favicon.png">
<link rel="stylesheet" href="style.css">

<title>Where to Learn C++</title>

<header>
<nav><a href="https://ignore.pl">ignore.pl</a></nav>
<time>23 June 2024</time>
<h1>Where to Learn C++</h1>
</header>

<article>
<p>This post is an attempt to list down resources I find interesting or useful for learning, polishing, debugging,
or exploring C++ programming language. It is unlikely to provide an exhaustive list and I don't necessarily intend to
create one. If you have any suggestions, I'm happy to read them.
<p>An alternative title would be: <i>where to read about C++</i> or <i>my links about C++</i>.
<p>I organized this list into completely arbitrary items with no particular order. It is completely opinionated and each
item has a very short explanatory description, link, instruction, and/or any other reference. I swear there is a reason
for each entry...
<ol>
<li><a class="always-fresh" href="#literature">Literature</a>
<li><a class="always-fresh" href="#standard-references">Standard References</a>
<li><a class="always-fresh" href="#proposals">Proposals</a>
<li><a class="always-fresh" href="#the-standard">The Standard</a>
<li><a class="always-fresh" href="#implementations">Implementations</a>
<li><a class="always-fresh" href="#headers">Headers</a>
<li><a class="always-fresh" href="#source-code">Source Code</a>
<li><a class="always-fresh" href="#boost">Boost</a>
<li><a class="always-fresh" href="#conferences">Conferences</a>
<li><a class="always-fresh" href="#core-guidelines">Core Guidelines</a>
<li><a class="always-fresh" href="#code-style-guidelines">Code Style Guidelines</a>
<li><a class="always-fresh" href="#interactive-exploration">Interactive Exploration</a>
<li><a class="always-fresh" href="#other">Other</a>
</ol>


<h2 id="literature">Literature</h2>
<p>There are three books on C++ that are good enough to be excluded from my usual "ban on books about programming
languages, frameworks and libraries."</p>
<img src="where_to_learn_cxx-1.png" alt="book covers">
<p><span style="font-style: italic; font-size: 75%;">From left to right</span>
<ol>
<li><strong>Effective Modern C++</strong>, Scott Meyers
<li><strong>The C++ Programming Language</strong>, Bjarne Stroustrup
<li><strong>C++ Primer</strong>, Stanley B. Lippman, Josée  Lajole, Barbara E. Moo
</ol>
<p>If you are beginning your programming journey, you have better chance of learning something if you use the books as
complementary resource to your class/course. If you are intermediate or higher, these books are good as "back-to-basics"
and to solidify your foundations.


<h2 id="standard-references">Standard References</h2>
<p>The intent is to translate the legal language from the standard to a more programmer friendly language complemented
with examples, compatibility matrices, and a good number of other useful resources. Currently there is only one
worthwhile community-driven page:
<ul>
<li><a href="https://en.cppreference.com/w/">cppreference.com</a>
</ul>
<p>You are likely to use it the most compared to any other entry in this list. This is the case for me.


<h2 id="proposals">Proposals</h2>
<p>Proposals are my favourites for filling the "would you like to know more" gap. They are C++ standard committee papers
that propose changes to the language or standard library. Their goals are to present an idea in understandable way,
reason it, and make it look good. This part of their nature makes them often better to read than the actual C++
standard. This is especially evident when they are coming from the outside of the working group and/or compiler circles.
<p>You can find them at <a href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/">C++ Standards Committee
Papers</a> index.
<p>Alternatively, if you are looking for proposal regarding a particular feature, you can:
<ol>
<li>Go to <a href="https://en.cppreference.com/w/">cppreference.com</a>.
<li>Find applicable C++ standard revision, e.g., <a href="https://en.cppreference.com/w/cpp/17">C++17</a>.
<li>
	Find feature in one of the matrices, e.g., <b>Structured Bindings</b> and associated
	<a href="https://wg21.link/P0217R3">P0217R3</a>.
<li>
	<b>P0217R3</b> describes wording changes but refers to <a href="https://wg21.link/P0144R2">P0144R2</a> as original
	proposal.
</ol>


<h2 id="the-standard">The Standard</h2>
<p>Also known as <strong>ISO/IEC 14882</strong>.</p>
<img src="where_to_learn_cxx-2.png" alt="c++ logo">
<p><strong>This is the primary source</strong>. Or rather the working draft of the primary source. Standard is intended
to define requirements for compiler and library implementations. It is not necessarily intended as your day-to-day
reference document. Nonetheless, it is useful because it can provide you with an authoritative answer.
<p>You can buy the actual standard revisions at the ISO Store.
<p>Draft is available at <a href="https://eel.is/c++draft/">eel.is/c++draft</a>.
<p>Standard C++ has a homepage at <a href="https://isocpp.org/">isocpp.org</a> with a good amount of useful resources,
i.a., <b>Get Started!</b>, <b>Tour</b>, and <b>Super-FAQ</b>.


<h2 id="implementations">Implementations</h2>
<p>On the other side of the standard specifications are implementations of said requirements: compilers and standard
libraries. It is as awkward to split them into separate list items as it is to have them both here. I rely mostly on
standard specification and/or reference and use these from time to time, when I need to consult implementation-defined
behaviour or details, options, recommendations.
<ul>
<li>
	<a href="https://gcc.gnu.org/onlinedocs/">GCC online documentation</a> contains both <b>GCC CPP Manual</b> and
	<b>GCC Standard C++ Library Manual</b> for all stable and historical versions
<li><a href="https://clang.llvm.org/docs/index.html">Clang documentation</a>
<li><a href="https://libcxx.llvm.org/">libc++ documentation</a>
<li><a href="https://learn.microsoft.com/en-us/cpp/">Microsoft C++, C, and Assembler documentation</a>
<li>
	<a href="https://www.intel.com/content/www/us/en/docs/dpcpp-cpp-compiler/developer-guide-reference/2024-2/overview.html">
	Intel oneAPI DPC++/C++ Compiler Developer Guide and Reference</a>
</ul>


<h2 id="headers">Headers</h2>
<p>The gist of it is, know your include paths. For example to start with:
<ol>
<li><code>/usr/include/c++/14.1.1</code>
<li><code>/usr/include/c++/14.1.1/x86_64-pc-linux-gnu</code>
<li><code>/usr/include/c++/14.1.1/backward</code>
<li><code>/usr/lib/gcc/x86_64-pc-linux-gnu/14.1.1/include</code>
<li><code>/usr/local/include</code>
<li><code>/usr/lib/gcc/x86_64-pc-linux-gnu/14.1.1/include-fixed</code>
<li><code>/usr/include</code>
</ol>
<p>Of course, depending on your compiler, library provider and targets these will vary. Consult your compiler
documentation. With GCC you can provide a <code>-v</code> flag to command and find the applicable paths, for example:
<pre>
$ c++ -v example.cpp -o example
Using built-in specs.
...
#include "..." search starts here:
#include &lt;...&gt; search starts here:
 /usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1
 /usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/x86_64-pc-linux-gnu
 /usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/backward
 /usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/include
 /usr/local/include
 /usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/include-fixed
 /usr/include
End of search list.
</pre>
<p>They may feel hit-or-miss. It gets especially bad when dealing with multi-target back-compatible headers as they
quickly devolve into macro madness. Yet, they are your exact specification of what you are dealing with.


<h2 id="source-code">Source Code</h2>
<p>I like reading what others wrote. I don't really care if it is bad or not, because I can learn from it nonetheless
simply by asking a questions "why?" and "what does this excerpt exactly do?"
<p>Selected pieces of software (alphabetical order):
<ul>
<!-- EnTT --><li><a href="https://github.com/skypjack/entt">EnTT</a>
<!-- fmt --><li><a href="https://github.com/fmtlib/fmt">fmt</a>
<!-- FreeCAD --><li><a href="https://github.com/FreeCAD/FreeCAD">FreeCAD</a>
<!-- GoogleTest --><li><a href="https://github.com/google/googletest">GoogleTest</a>
<!-- JSON --><li><a href="https://github.com/nlohmann/json">JSON</a>
<!-- rpclib --><li><a href="https://github.com/rpclib/rpclib">rpclib</a>
<!-- Yes, I sorted it by piping it to sort(1). -->
</ul>
<p>In general, just take a look at whatever software you use. You might even end up contributing to it and that's always
good.


<h2 id="boost">Boost</h2>
<p>I have a love-hate relationship with Boost. Nonetheless, its documentation has a number of good examples and
recommendations. Even if you don't plan using Boost, it may provide you with solution patterns.
<p>Docs version index is located at <a href="https://www.boost.org/doc/">boost.org/doc</a>.


<h2 id="conferences">Conferences</h2>
<p>I'm socially awkward but I do like to listen to knowledgeable people. Even better if I'm interested in the topic they
talk about. <b>Isocpp.org</b> maintains <a href="https://isocpp.org/wiki/faq/conferences-worldwide">a list of worldwide
conferences</a>.
<p>Here are channels with recordings from C++ or around C++ conferences:
<ul>
<li><a href="https://www.youtube.com/@CppCon">CppCon</a> (YouTube)
<li><a href="https://www.youtube.com/@ACCUConf">ACCU Conference</a> (YouTube)
<li><a href="https://www.youtube.com/@BoostCon">C++Now</a> (YouTube)
</ul>


<h2 id="core-guidelines">Core Guidelines</h2>
<p>A document maintained by Bjarne Stroustrup and Herb Sutter with a whole lot of recommendations. It is available
online at <a href="https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines">C++ Core Guidelines</a>.
<p>It's not necessary to read it like a book, but doing a full skim at least once would be beneficial to get an idea
when to refer to the guideline. Choosing a random topic and reading it on a coffee break is also an option. Whatever the
method - read it - it's good.


<h2 id="code-style-guidelines">Code Style Guidelines</h2>
<p>Even if you work alone these can be useful as rules may prevent trivial errors and make the code more maintainable in
the long run.
<p>Examples of coding styles (alphabetical order):
<ul>
<!-- GCC Co... --><li><a href="https://gcc.gnu.org/codingconventions.html">GCC Coding Conventions</a>
<!-- Google... --><li><a href="https://google.github.io/styleguide/cppguide.html">Google C++ Style Guide</a>
<!-- LLVM C... --><li><a href="https://llvm.org/docs/CodingStandards.html">LLVM Coding Standards</a>
</ul>


<h2 id="interactive-exploration">Interactive Exploration</h2>
<p>A good way to build intuition around C++ is to watch the tools do what they are intended to do and inspect the
results. An example of such tool is <a href="https://godbolt.org/">Compiler Explorer</a>.
<p>We can get similar results in local environment. For example, we can make GCC emit assembly output with
<code>-S</code> flag. Another command, <b>c++filt</b>(1) can be used to demangle symbols in the output:
<pre>
$ g++ -O3 -S something.cpp -o - | c++filt
</pre>
<p>Other than assembly output, we can also view preprocessor output with <code>-E</code> flag or <b>cpp</b>(1) command.
In general, building minimal examples to see certain behaviours is a decent debugging method. Of course, full blown
debuggers are also an option for exploration.


<h2 id="other">Other</h2>
<p>I don't have much to say about these. They listed here only to avoid questions about them.
<ul>
<li>Classes
<li>Courses
<li>Tutorials
<li>Stack Overflow
<li>LLMs
</ul>
<p>Older revision of this article had some additional notes, but even at the time of writing I was struggling to see any
good points in my comments.
</article>
<script src="https://stats.ignore.pl/track.js"></script>