<s>
Although	O
C++	B-Language
is	O
one	O
of	O
the	O
most	O
widespread	O
programming	O
languages	O
,	O
many	O
prominent	O
software	O
engineers	O
criticize	O
C++	B-Language
(	O
the	O
language	O
,	O
and	O
its	O
compilers	B-Language
)	O
for	O
being	O
overly	O
complex	O
and	O
fundamentally	O
flawed	O
.	O
</s>
<s>
C++	B-Language
was	O
widely	O
adopted	O
and	O
implemented	O
as	O
a	O
systems	B-Application
language	I-Application
through	O
most	O
of	O
its	O
existence	O
,	O
it	O
has	O
been	O
used	O
to	O
build	O
many	O
pieces	O
of	O
very	O
important	O
software	O
(	O
such	O
types	O
of	O
software	O
include	O
,	O
but	O
are	O
not	O
limited	O
to	O
:	O
operating	B-General_Concept
systems	I-General_Concept
,	O
runtime	B-Device
systems	I-Device
,	O
programming	B-Application
language	I-Application
interpreters	I-Application
,	O
parsers	B-Language
,	O
lexers	B-Application
,	O
compilers	B-Language
,	O
etc	O
...	O
)	O
.	O
</s>
<s>
The	O
natural	O
interface	O
between	O
source	B-Language
files	I-Language
in	O
C	O
and	O
C++	B-Language
are	O
header	B-Language
files	I-Language
.	O
</s>
<s>
Each	O
time	O
a	O
header	B-Language
file	I-Language
is	O
modified	O
,	O
all	O
source	B-Language
files	I-Language
that	O
include	O
the	O
header	B-Language
file	I-Language
should	O
recompile	B-Language
their	O
code	O
.	O
</s>
<s>
Header	B-Language
files	I-Language
are	O
slow	O
because	O
they	O
are	O
textual	O
and	O
context-dependent	O
as	O
a	O
consequence	O
of	O
the	O
preprocessor	O
.	O
</s>
<s>
C	O
only	O
has	O
limited	O
amounts	O
of	O
information	O
in	O
header	B-Language
files	I-Language
,	O
the	O
most	O
important	O
being	O
struct	B-Application
declarations	O
and	O
function	O
prototypes	O
.	O
</s>
<s>
C++	B-Language
stores	O
its	O
classes	B-Application
in	O
header	B-Language
files	I-Language
and	O
they	O
not	O
only	O
expose	O
their	O
public	O
variables	O
and	O
public	O
functions	O
(	O
like	O
C	O
with	O
its	O
structs	B-Application
and	O
function	O
prototypes	O
)	O
but	O
also	O
their	O
private	O
functions	O
.	O
</s>
<s>
This	O
forces	O
unnecessary	O
recompiles	B-Language
of	O
all	O
source	B-Language
files	I-Language
that	O
include	O
the	O
header	B-Language
file	I-Language
,	O
each	O
time	O
when	O
changing	O
these	O
private	O
functions	O
.	O
</s>
<s>
This	O
problem	O
is	O
magnified	O
where	O
the	O
classes	B-Application
are	O
written	O
as	O
templates	B-Application
,	O
forcing	O
all	O
of	O
their	O
code	O
into	O
the	O
slow	O
header	B-Language
files	I-Language
,	O
which	O
is	O
the	O
case	O
with	O
much	O
of	O
the	O
C++	B-Language
standard	I-Language
library	I-Language
.	O
</s>
<s>
Large	O
C++	B-Language
projects	O
can	O
therefore	O
be	O
relatively	O
slow	O
to	O
compile	B-Language
.	O
</s>
<s>
The	O
problem	O
is	O
largely	O
solved	O
by	O
precompiled	O
headers	O
in	O
modern	O
compilers	B-Language
or	O
using	O
the	O
module	O
system	O
that	O
was	O
added	O
in	O
C++20	B-Language
;	O
future	O
C++	B-Language
standards	O
are	O
planning	O
to	O
expose	O
the	O
functionality	O
of	O
the	O
standard	O
library	O
using	O
modules	O
.	O
</s>
<s>
C++	B-Language
<iostream>, unlike C <stdio.h>	O
,	O
relies	O
on	O
a	O
global	O
format	O
state	O
.	O
</s>
<s>
This	O
fits	O
very	O
poorly	O
together	O
with	O
exceptions	B-General_Concept
,	O
when	O
a	O
function	O
must	O
interrupt	O
the	O
control	O
flow	O
,	O
after	O
an	O
error	O
but	O
before	O
resetting	O
the	O
global	O
format	O
state	O
.	O
</s>
<s>
One	O
fix	O
for	O
this	O
is	O
to	O
use	O
Resource	B-Application
Acquisition	I-Application
Is	I-Application
Initialization	I-Application
(	O
RAII	B-Application
)	O
,	O
which	O
is	O
implemented	O
in	O
the	O
Boost	B-Language
libraries	I-Language
and	O
part	O
of	O
the	O
C++	B-Language
Standard	I-Language
Library	I-Language
.	O
</s>
<s>
<iostream>	B-Language
uses	O
static	O
constructors	O
which	O
causes	O
useless	O
overhead	O
if	O
included	O
,	O
even	O
if	O
the	O
library	O
is	O
not	O
used	O
.	O
</s>
<s>
C++	B-Language
<iostream> is by default synchronized with <stdio.h>	O
which	O
can	O
cause	O
performance	O
problems	O
in	O
command-line	O
io	O
intensive	O
applications	O
.	O
</s>
<s>
Here	O
follows	O
an	O
example	O
where	O
an	O
exception	O
interrupts	O
the	O
function	O
before	O
std::cout	B-Language
can	O
be	O
restored	O
from	O
hexadecimal	O
to	O
decimal	O
.	O
</s>
<s>
It	O
is	O
even	O
acknowledged	O
by	O
some	O
members	O
of	O
the	O
C++	B-Language
standards	O
body	O
that	O
<iostream>	B-Language
is	O
an	O
aging	O
interface	O
that	O
eventually	O
needs	O
to	O
be	O
replaced	O
.	O
</s>
<s>
C++20	B-Language
added	O
std::format	O
that	O
eliminated	O
the	O
global	O
formatting	O
state	O
and	O
addressed	O
other	O
issues	O
in	O
iostreams	O
.	O
</s>
<s>
The	O
philosophy	O
of	O
the	O
Standard	B-Application
Template	I-Application
Library	I-Application
(	O
STL	O
)	O
embedded	O
in	O
the	O
C++	B-Language
Standard	I-Language
Library	I-Language
is	O
to	O
use	O
generic	O
algorithms	O
in	O
the	O
form	O
of	O
templates	B-Application
using	O
iterators	O
.	O
</s>
<s>
Early	O
compilers	B-Language
optimized	O
small	O
objects	O
such	O
as	O
iterators	O
poorly	O
,	O
which	O
Alexander	O
Stepanov	O
characterized	O
as	O
the	O
"	O
abstraction	O
penalty	O
"	O
,	O
although	O
modern	O
compilers	B-Language
optimize	O
away	O
such	O
small	O
abstractions	O
well	O
.	O
</s>
<s>
The	O
C++20	B-Language
standard	O
library	O
's	O
introduction	O
of	O
ranges	O
should	O
solve	O
this	O
problem	O
.	O
</s>
<s>
One	O
big	O
problem	O
is	O
that	O
iterators	O
often	O
deal	O
with	O
heap	O
allocated	O
data	O
in	O
the	O
C++	B-Language
containers	O
and	O
become	O
invalid	O
if	O
the	O
data	O
is	O
independently	O
moved	O
by	O
the	O
containers	O
.	O
</s>
<s>
Functions	O
that	O
change	O
the	O
size	O
of	O
the	O
container	O
often	O
invalidate	O
all	O
iterators	O
pointing	O
to	O
it	O
,	O
creating	O
dangerous	O
cases	O
of	O
undefined	B-Language
behavior	I-Language
.	O
</s>
<s>
The	O
C++11	B-Language
uniform	O
initialization	O
syntax	O
and	O
std::initializer_list	O
share	O
the	O
same	O
syntax	O
which	O
are	O
triggered	O
differently	O
depending	O
on	O
the	O
internal	O
workings	O
of	O
the	O
classes	B-Application
.	O
</s>
<s>
There	O
have	O
been	O
concerns	O
that	O
the	O
zero-overhead	O
principle	O
is	O
not	O
compatible	O
with	O
exceptions	B-General_Concept
.	O
</s>
<s>
Most	O
modern	O
implementations	O
have	O
a	O
zero	O
performance	O
overhead	O
when	O
exceptions	B-General_Concept
are	O
enabled	O
but	O
not	O
used	O
,	O
but	O
do	O
have	O
an	O
overhead	O
during	O
exception	B-General_Concept
handling	I-General_Concept
and	O
in	O
binary	O
size	O
due	O
to	O
the	O
need	O
to	O
unroll	O
tables	O
.	O
</s>
<s>
Many	O
compilers	B-Language
support	O
disabling	O
exceptions	B-General_Concept
from	O
the	O
language	O
to	O
save	O
the	O
binary	O
overhead	O
.	O
</s>
<s>
Exceptions	B-General_Concept
have	O
also	O
been	O
criticized	O
for	O
being	O
unsafe	O
for	O
state-handling	O
.	O
</s>
<s>
This	O
safety	O
issue	O
has	O
led	O
to	O
the	O
invention	O
of	O
the	O
RAII	B-Application
idiom	O
,	O
which	O
has	O
proven	O
useful	O
beyond	O
making	O
C++	B-Language
exceptions	B-General_Concept
safe	O
.	O
</s>
<s>
C++	B-Language
string	O
literals	O
,	O
like	O
those	O
of	O
C	O
,	O
do	O
not	O
consider	O
the	O
character	O
encoding	O
of	O
the	O
text	O
within	O
them	O
:	O
they	O
are	O
merely	O
a	O
sequence	O
of	O
bytes	O
,	O
and	O
the	O
C++	B-Language
string	O
class	O
follows	O
the	O
same	O
principle	O
.	O
</s>
<s>
Although	O
source	O
code	O
can	O
(	O
since	O
C++11	B-Language
)	O
request	O
an	O
encoding	O
for	O
a	O
literal	O
,	O
the	O
compiler	B-Language
does	O
not	O
attempt	O
to	O
validate	O
that	O
the	O
chosen	O
encoding	O
of	O
the	O
source	O
literal	O
is	O
"	O
correct	O
"	O
for	O
the	O
bytes	O
being	O
put	O
into	O
it	O
,	O
and	O
the	O
runtime	O
does	O
not	O
enforce	O
character	O
encoding	O
.	O
</s>
<s>
Despite	O
the	O
presence	O
of	O
the	O
C++11	B-Language
'	O
u8	O
 '	O
prefix	O
,	O
meaning	O
"	O
Unicode	O
UTF-8	O
string	O
literal	O
"	O
,	O
the	O
output	O
of	O
this	O
program	O
actually	O
depends	O
on	O
the	O
source	O
file	O
's	O
text	O
encoding	O
(	O
or	O
the	O
compiler	B-Language
's	O
settings	O
-	O
most	O
compilers	B-Language
can	O
be	O
told	O
to	O
convert	O
source	B-Language
files	I-Language
to	O
a	O
specific	O
encoding	O
before	O
compiling	B-Language
them	O
)	O
.	O
</s>
<s>
However	O
,	O
when	O
the	O
same	O
source	O
file	O
is	O
instead	O
saved	O
in	O
ISO-8859-1	O
and	O
re-compiled	O
,	O
the	O
output	O
of	O
the	O
program	O
on	O
the	O
same	O
terminal	O
becomes	O
:	O
</s>
<s>
One	O
proposed	O
solution	O
is	O
to	O
make	O
the	O
source	O
encoding	O
reliable	O
across	O
all	O
compilers	B-Language
.	O
</s>
<s>
Some	O
older	O
implementations	O
of	O
C++	B-Language
have	O
been	O
accused	O
of	O
generating	O
code	O
bloat	O
.	O
</s>
