<s>
Java	B-Language
and	O
C++	B-Language
are	O
two	O
prominent	O
object-oriented	B-Language
programming	I-Language
languages	I-Language
.	O
</s>
<s>
By	O
many	O
language	O
popularity	O
metrics	O
,	O
the	O
two	O
languages	O
have	O
dominated	O
object-oriented	B-Language
and	O
high-performance	O
software	O
development	O
for	O
much	O
of	O
the	O
21st	O
century	O
,	O
and	O
are	O
often	O
directly	O
compared	O
and	O
contrasted	O
.	O
</s>
<s>
Java	B-Language
appeared	O
about	O
10	O
years	O
later	O
and	O
its	O
syntax	O
was	O
based	O
on	O
C/C	O
++	O
.	O
</s>
<s>
The	O
differences	O
between	O
the	O
programming	O
languages	O
C++	B-Language
and	O
Java	B-Language
can	O
be	O
traced	O
to	O
their	O
heritage	O
,	O
as	O
they	O
have	O
different	O
design	O
goals	O
.	O
</s>
<s>
C++	B-Language
was	O
designed	O
for	O
systems	O
and	O
applications	O
programming	O
(	O
i.e.	O
</s>
<s>
infrastructure	O
programming	O
)	O
,	O
extending	O
the	O
procedural	B-Application
programming	I-Application
language	I-Application
C	B-Language
,	O
which	O
was	O
designed	O
for	O
efficient	O
execution	O
.	O
</s>
<s>
To	O
C	B-Language
,	O
C++	B-Language
added	O
support	O
for	O
object-oriented	B-Language
programming	I-Language
,	O
exception	B-General_Concept
handling	I-General_Concept
,	O
lifetime-based	O
resource	O
management	O
(	O
RAII	B-Application
)	O
,	O
generic	B-Language
programming	I-Language
,	O
template	B-Language
metaprogramming	I-Language
,	O
and	O
the	O
C++	B-Language
Standard	I-Language
Library	I-Language
which	O
includes	O
generic	O
containers	O
and	O
algorithms	O
(	O
the	O
Standard	B-Application
Template	I-Application
Library	I-Application
or	O
STL	O
)	O
,	O
and	O
many	O
other	O
general	O
purpose	O
facilities	O
.	O
</s>
<s>
Java	B-Language
is	O
a	O
general-purpose	O
,	O
concurrent	O
,	O
class-based	O
,	O
object-oriented	B-Language
programming	I-Language
language	I-Language
that	O
is	O
designed	O
to	O
minimize	O
implementation	O
dependencies	O
.	O
</s>
<s>
It	O
relies	O
on	O
a	O
Java	B-Language
virtual	I-Language
machine	I-Language
to	O
be	O
secure	O
and	O
highly	O
portable	O
.	O
</s>
<s>
Java	B-Language
is	O
a	O
statically	O
typed	O
object-oriented	B-Language
language	I-Language
that	O
uses	O
a	O
syntax	O
similar	O
to	O
(	O
but	O
incompatible	O
with	O
)	O
C++	B-Language
.	O
</s>
<s>
It	O
includes	O
a	O
documentation	O
system	O
called	O
Javadoc	B-Language
.	O
</s>
<s>
The	O
different	O
goals	O
in	O
the	O
development	O
of	O
C++	B-Language
and	O
Java	B-Language
resulted	O
in	O
different	O
principles	O
and	O
design	O
trade-offs	O
between	O
the	O
languages	O
.	O
</s>
<s>
C++	B-Language
Java	B-Language
Extends	O
C	B-Language
with	O
object-oriented	B-Language
programming	I-Language
and	O
generic	B-Language
programming	I-Language
.	O
</s>
<s>
C	B-Language
code	O
can	O
most	O
properly	O
be	O
used	O
.	O
</s>
<s>
Strongly	O
influenced	O
by	O
C++	B-Language
/C	O
syntax	O
.	O
</s>
<s>
Compatible	O
with	O
C	B-Language
source	O
code	O
,	O
except	O
for	O
a	O
few	O
corner	O
cases	O
.	O
</s>
<s>
Provides	O
the	O
Java	B-Language
Native	I-Language
Interface	I-Language
and	O
recently	O
Java	B-Language
Native	I-Language
Access	I-Language
as	O
a	O
way	O
to	O
directly	O
call	O
C/C	O
++	O
code	O
.	O
</s>
<s>
Allows	O
procedural	B-Application
programming	I-Application
,	O
functional	B-Language
programming	I-Language
,	O
object-oriented	B-Language
programming	I-Language
,	O
generic	B-Language
programming	I-Language
,	O
and	O
template	B-Language
metaprogramming	I-Language
.	O
</s>
<s>
Allows	O
procedural	B-Application
programming	I-Application
,	O
functional	B-Language
programming	I-Language
(	O
since	O
Java	B-Language
8	O
)	O
and	O
generic	B-Language
programming	I-Language
(	O
since	O
Java	B-Language
5	O
)	O
,	O
but	O
strongly	O
encourages	O
the	O
object-oriented	B-Language
programming	I-Language
paradigm	O
.	O
</s>
<s>
Includes	O
support	O
for	O
creating	O
scripting	B-Language
languages	I-Language
.	O
</s>
<s>
Runs	O
as	O
native	O
executable	O
machine	B-Language
code	I-Language
for	O
the	O
target	O
instruction	O
set(s )	O
.	O
</s>
<s>
Runs	O
on	O
a	O
virtual	B-Language
machine	I-Language
.	O
</s>
<s>
Allows	O
reflection	B-Language
via	O
run-time	B-Application
type	I-Application
information	I-Application
(	O
RTTI	B-Application
)	O
.	O
</s>
<s>
Is	O
reflective	B-Language
,	O
allowing	O
metaprogramming	O
and	O
dynamic	O
code	O
generation	O
at	O
runtime	O
.	O
</s>
<s>
Has	O
one	O
binary	O
compatibility	O
standard	O
,	O
cross-platform	B-Operating_System
for	O
OS	O
and	O
compiler	O
.	O
</s>
<s>
Optional	O
automated	O
bounds	B-Data_Structure
checking	I-Data_Structure
(	O
e.g.	O
,	O
the	O
at( )	O
method	O
in	O
vector	O
and	O
string	O
containers	O
)	O
.	O
</s>
<s>
All	O
operations	O
are	O
required	O
to	O
be	O
bound-checked	O
by	O
all	O
compliant	O
distributions	O
of	O
Java	B-Language
.	O
</s>
<s>
HotSpot	B-Language
can	O
remove	O
bounds	B-Data_Structure
checking	I-Data_Structure
.	O
</s>
<s>
Native	O
unsigned	B-Algorithm
arithmetic	I-Algorithm
support	O
.	O
</s>
<s>
Native	O
unsigned	B-Algorithm
arithmetic	I-Algorithm
unsupported	O
.	O
</s>
<s>
Java	B-Language
8	O
changes	O
some	O
of	O
this	O
,	O
but	O
aspects	O
are	O
unclear	O
.	O
</s>
<s>
All	O
types	O
(	O
primitive	O
types	O
and	O
reference	B-Language
types	I-Language
)	O
are	O
always	O
passed	O
by	O
value	O
.	O
</s>
<s>
Memory	B-General_Concept
management	I-General_Concept
can	O
be	O
done	O
manually	B-Application
via	O
new	B-Language
/	O
delete	B-Language
,	O
automatically	O
by	O
scope	O
,	O
or	O
by	O
smart	B-Language
pointers	I-Language
.	O
</s>
<s>
Garbage	B-General_Concept
collection	I-General_Concept
ABI	O
standardized	O
in	O
C++11	B-Language
,	O
though	O
compilers	O
are	O
not	O
required	O
to	O
implement	O
garbage	B-General_Concept
collection	I-General_Concept
.	O
</s>
<s>
Automatic	B-General_Concept
garbage	I-General_Concept
collection	I-General_Concept
.	O
</s>
<s>
Supports	O
a	O
non-deterministic	O
finalize( )	O
method	O
,	O
use	O
of	O
which	O
is	O
not	O
recommended	O
..	O
Resource	O
management	O
can	O
be	O
done	O
manually	B-Application
or	O
by	O
automatic	O
lifetime-based	O
resource	O
management	O
(	O
RAII	B-Application
)	O
.	O
</s>
<s>
Resource	O
management	O
must	O
generally	O
be	O
done	O
manually	B-Application
,	O
or	O
automatically	O
via	O
finalizers	B-Application
,	O
though	O
this	O
is	O
generally	O
discouraged	O
.	O
</s>
<s>
Has	O
try-with-resources	O
for	O
automatic	O
scope-based	B-Application
resource	I-Application
management	I-Application
(	O
version	O
7	O
onwards	O
)	O
.	O
</s>
<s>
It	O
can	O
also	O
be	O
done	O
using	O
the	O
internal	O
API	B-Application
sun.misc.Unsafe	O
but	O
that	O
usage	O
is	O
highly	O
discouraged	O
and	O
will	O
be	O
replaced	O
by	O
a	O
public	O
API	B-Application
in	O
an	O
upcoming	O
Java	B-Language
version	O
.	O
</s>
<s>
Supports	O
classes	O
,	O
structs	O
(	O
passive	B-Language
data	I-Language
structure	I-Language
(	O
PDS	O
)	O
types	O
)	O
,	O
and	O
unions	O
,	O
and	O
can	O
allocate	O
them	O
on	O
the	O
heap	B-General_Concept
or	O
the	O
stack	B-General_Concept
.	O
</s>
<s>
Classes	O
are	O
allocated	O
on	O
the	O
heap	B-General_Concept
.	O
</s>
<s>
Java	B-Language
SE	O
6	O
optimizes	O
with	O
escape	O
analysis	O
to	O
allocate	O
some	O
objects	O
on	O
the	O
stack	B-General_Concept
.	O
</s>
<s>
Allows	O
explicitly	O
overriding	O
types	O
,	O
and	O
some	O
implicit	O
narrowing	O
conversions	O
(	O
for	O
compatibility	O
with	O
C	B-Language
)	O
.	O
</s>
<s>
Rigid	O
type	B-Language
safety	I-Language
except	O
for	O
widening	O
conversions	O
.	O
</s>
<s>
The	O
C++	B-Language
Standard	I-Language
Library	I-Language
was	O
designed	O
to	O
have	O
a	O
limited	O
scope	O
and	O
functions	O
,	O
but	O
includes	O
language	O
support	O
,	O
diagnostics	O
,	O
general	O
utilities	O
,	O
strings	O
,	O
locales	O
,	O
containers	O
,	O
algorithms	O
,	O
iterators	O
,	O
numerics	O
,	O
input/output	O
,	O
random	O
number	O
generators	O
,	O
regular	O
expression	O
parsing	O
,	O
threading	O
facilities	O
,	O
type	O
traits	O
(	O
for	O
static	O
type	O
introspection	O
)	O
and	O
Standard	O
C	B-Language
Library	O
.	O
</s>
<s>
The	O
Boost	B-Language
library	I-Language
offers	O
more	O
functions	O
including	O
network	O
I/O	O
.	O
</s>
<s>
A	O
rich	O
amount	O
of	O
third-party	O
libraries	O
exist	O
for	O
GUI	O
and	O
other	O
functions	O
like	O
:	O
Adaptive	B-Language
Communication	I-Language
Environment	I-Language
(	O
ACE	O
)	O
,	O
Crypto++	B-Language
,	O
various	O
XMPP	B-Protocol
Instant	B-Application
Messaging	I-Application
(	O
IM	O
)	O
libraries	O
,	O
OpenLDAP	B-Language
,	O
Qt	B-Language
,	O
gtkmm	B-Language
.	O
</s>
<s>
By	O
version	O
1.6	O
,	O
the	O
library	O
included	O
support	O
for	O
locales	O
,	O
logging	O
,	O
containers	O
and	O
iterators	O
,	O
algorithms	O
,	O
GUI	O
programming	O
(	O
but	O
not	O
using	O
the	O
system	O
GUI	O
)	O
,	O
graphics	O
,	O
multi-threading	B-Operating_System
,	O
networking	O
,	O
platform	O
security	O
,	O
introspection	O
,	O
dynamic	O
class	O
loading	O
,	O
blocking	O
and	O
non-blocking	O
I/O	O
.	O
</s>
<s>
It	O
provided	O
interfaces	B-Language
or	O
support	O
classes	O
for	O
XML	B-Protocol
,	O
XSLT	B-Application
,	O
MIDI	O
,	O
database	O
connectivity	O
,	O
naming	O
services	O
(	O
e.g.	O
</s>
<s>
LDAP	B-Protocol
)	O
,	O
cryptography	O
,	O
security	O
services	O
(	O
e.g.	O
</s>
<s>
Kerberos	B-Protocol
)	O
,	O
print	O
services	O
,	O
and	O
web	O
services	O
.	O
</s>
<s>
SWT	O
offered	O
an	O
abstraction	O
for	O
platform-specific	O
GUIs	O
,	O
but	O
was	O
superseded	O
by	O
JavaFX	B-Application
in	O
the	O
latest	O
releases	O
;	O
allowing	O
for	O
graphics	O
acceleration	O
and	O
CSS-themable	O
UIs	O
.	O
</s>
<s>
Single	O
and	O
multiple	B-Application
inheritance	I-Application
of	O
classes	O
,	O
including	O
virtual	O
inheritance	O
.	O
</s>
<s>
Compile-time	O
templates	B-Application
.	O
</s>
<s>
Allows	O
for	O
Turing	B-Algorithm
complete	I-Algorithm
meta-programming	O
.	O
</s>
<s>
Generics	B-Language
are	O
used	O
to	O
achieve	O
basic	O
type-parametrization	O
,	O
but	O
they	O
do	O
not	O
translate	O
from	O
source	O
code	O
to	O
byte	O
code	O
due	O
to	O
the	O
use	O
of	O
type	B-General_Concept
erasure	I-General_Concept
by	O
the	O
compiler	O
.	O
</s>
<s>
Function	B-Language
pointers	I-Language
,	O
function	O
objects	O
,	O
lambdas	O
(	O
in	O
C++11	B-Language
)	O
,	O
and	O
interfaces	B-Language
.	O
</s>
<s>
Functions	O
references	O
,	O
function	O
objects	O
and	O
lambdas	O
were	O
added	O
in	O
Java	B-Language
8	O
.	O
</s>
<s>
Classes	O
(	O
and	O
interfaces	B-Language
,	O
which	O
are	O
classes	O
)	O
can	O
be	O
passed	O
as	O
references	O
as	O
well	O
through	O
SomeClass.class	O
and	O
someObject.getClass( )	O
.	O
</s>
<s>
Doxygen	B-Language
)	O
exists	O
.	O
</s>
<s>
Extensive	O
Javadoc	B-Language
documentation	O
standard	O
on	O
all	O
system	O
classes	O
and	O
methods	O
.	O
</s>
<s>
final	B-Language
provides	O
a	O
version	O
of	O
const	O
,	O
equivalent	O
to	O
type*	O
const	O
pointers	O
for	O
objects	O
and	O
const	O
for	O
primitive	O
types	O
.	O
</s>
<s>
Immutability	O
of	O
object	O
members	O
achieved	O
via	O
read-only	O
interfaces	B-Language
and	O
object	O
encapsulation	O
.	O
</s>
<s>
Supports	O
the	O
goto	B-Application
statement	O
.	O
</s>
<s>
goto	B-Application
is	O
a	O
reserved	O
keyword	O
but	O
is	O
marked	O
as	O
"	O
unused	O
"	O
in	O
the	O
Java	B-Language
specification	O
.	O
</s>
<s>
Source	O
code	O
can	O
be	O
written	O
to	O
be	O
cross-platform	B-Operating_System
(	O
can	O
be	O
compiled	O
for	O
Windows	B-Application
,	O
BSD	B-Operating_System
,	O
Linux	B-Application
,	O
macOS	B-Application
,	O
Solaris	B-Application
,	O
etc.	O
,	O
without	O
modification	O
)	O
and	O
written	O
to	O
use	O
platform-specific	O
features	O
.	O
</s>
<s>
Typically	O
compiled	O
into	O
native	O
machine	B-Language
code	I-Language
,	O
must	O
be	O
recompiled	O
for	O
each	O
target	O
platform	O
.	O
</s>
<s>
Compiled	O
into	O
Java	B-Language
bytecode	I-Language
for	O
the	O
JVM	B-Language
.	O
</s>
<s>
Byte	O
code	O
is	O
dependent	O
on	O
the	O
Java	B-Language
platform	O
,	O
but	O
is	O
typically	O
independent	O
of	O
operating	B-General_Concept
system	I-General_Concept
specific	O
features	O
.	O
</s>
<s>
Java	B-Language
syntax	I-Language
has	O
a	O
context-free	O
grammar	O
that	O
can	O
be	O
parsed	O
by	O
a	O
simple	O
LALR	B-Application
parser	I-Application
.	O
</s>
<s>
Parsing	O
C++	B-Language
is	O
more	O
complicated	O
.	O
</s>
<s>
For	O
example	O
,	O
Fooxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1( 3	O
)	O
;	O
is	O
a	O
sequence	O
of	O
comparisons	O
if	O
Foo	O
is	O
a	O
variable	O
,	O
but	O
creates	O
an	O
object	O
if	O
Foo	O
is	O
the	O
name	O
of	O
a	O
class	O
template	B-Application
.	O
</s>
<s>
C++	B-Language
allows	O
namespace-level	O
constants	O
,	O
variables	O
,	O
and	O
functions	O
.	O
</s>
<s>
In	O
Java	B-Language
,	O
such	O
entities	O
must	O
belong	O
to	O
some	O
given	O
type	O
,	O
and	O
therefore	O
must	O
be	O
defined	O
inside	O
a	O
type	O
definition	O
,	O
either	O
a	O
class	O
or	O
an	O
interface	B-Language
.	O
</s>
<s>
In	O
C++	B-Language
,	O
objects	O
are	O
values	O
,	O
while	O
in	O
Java	B-Language
they	O
are	O
not	O
.	O
</s>
<s>
C++	B-Language
uses	O
value	O
semantics	O
by	O
default	O
,	O
while	O
Java	B-Language
always	O
uses	O
reference	O
semantics	O
.	O
</s>
<s>
To	O
opt	O
for	O
reference	O
semantics	O
in	O
C++	B-Language
,	O
either	O
a	O
pointer	O
or	O
a	O
reference	O
can	O
be	O
used	O
.	O
</s>
<s>
//	O
or	O
(	O
C++11	B-Language
)	O
:	O
</s>
<s>
Foo	O
a{args};	O
Foo	O
a	O
=	O
new	B-Language
Foo( )	O
;	O
</s>
<s>
Foo	O
a	O
=	O
new	B-Language
Foo(args )	O
;	O
Foo	O
b	O
=	O
a	O
;	O
</s>
<s>
//	O
copies	O
the	O
contents	O
of	O
a	O
to	O
a	O
new	B-Language
Foo	O
object	O
b	O
;	O
</s>
<s>
//	O
to	O
a	O
new	B-Language
Foo	O
object	O
;	O
</s>
<s>
//	O
sets	O
the	O
reference	O
b	O
to	O
point	O
to	O
this	O
new	B-Language
object	O
;	O
</s>
<s>
//	O
some	O
object	O
other	O
than	O
a	O
Foo	O
*	O
c	B-Language
;	O
</s>
<s>
//	O
undefined	O
;	O
could	O
point	O
anywhere	O
)	O
Foo	O
c	B-Language
;	O
</s>
<s>
//	O
object	O
(	O
initially	O
null	O
if	O
c	B-Language
is	O
a	O
class	O
member	O
;	O
</s>
<s>
//	O
if	O
it	O
is	O
a	O
local	O
variable	O
)	O
c	B-Language
=	O
new	B-Language
Foo	O
;	O
</s>
<s>
//	O
c	B-Language
is	O
set	O
to	O
the	O
value	O
of	O
the	O
address	O
of	O
the	O
Foo	O
object	O
created	O
by	O
operator	O
new	B-Language
c	B-Language
=	O
new	B-Language
Foo( )	O
;	O
</s>
<s>
//	O
binds	O
c	B-Language
to	O
reference	O
a	O
new	B-Language
Foo	O
object	O
Foo	O
&	O
d	O
=	O
*	O
c	B-Language
;	O
</s>
<s>
//	O
binds	O
d	O
to	O
reference	O
the	O
same	O
object	O
to	O
which	O
c	B-Language
points	O
Foo	O
d	O
=	O
c	B-Language
;	O
</s>
<s>
//	O
binds	O
d	O
to	O
reference	O
the	O
same	O
object	O
as	O
c	B-Language
c->x	O
=	O
5	O
;	O
</s>
<s>
//	O
modifies	O
the	O
object	O
pointed	O
to	O
by	O
c	B-Language
c.x	O
=	O
5	O
;	O
</s>
<s>
c.bar(5 )	O
;	O
//	O
invokes	O
Foo.bar( )	O
for	O
c	B-Language
std::cout	O
<<	O
d.x	O
<<	O
std::endl	O
;	O
</s>
<s>
//	O
same	O
object	O
to	O
which	O
c	B-Language
points	O
System.out.println(d.x )	O
;	O
</s>
<s>
In	O
C++	B-Language
,	O
it	O
is	O
possible	O
to	O
declare	O
a	O
pointer	O
or	O
reference	O
to	O
a	O
const	O
object	O
in	O
order	O
to	O
prevent	O
client	O
code	O
from	O
modifying	O
it	O
.	O
</s>
<s>
In	O
Java	B-Language
,	O
for	O
the	O
most	O
part	O
,	O
const-correctness	O
must	O
rely	O
on	O
the	O
semantics	O
of	O
the	O
class	O
 '	O
interface	B-Language
,	O
i.e.	O
,	O
it	O
is	O
not	O
strongly	O
enforced	O
,	O
except	O
for	O
public	O
data	O
members	O
that	O
are	O
labeled	O
final	B-Language
.	O
</s>
<s>
//	O
pointed	O
to	O
by	O
a	O
through	O
afinal	O
Foo	O
a	O
;	O
//	O
a	O
declaration	O
of	O
a	O
"	O
final	B-Language
"	O
reference	O
:	O
</s>
<s>
//	O
to	O
the	O
first	O
object	O
assigned	O
to	O
it	O
a	O
=	O
new	B-Language
Foo( )	O
;	O
a	O
=	O
new	B-Language
Foo( )	O
;	O
//	O
Only	O
in	O
constructor	O
a->x	O
=	O
5	O
;	O
</s>
<s>
//	O
unless	O
explicitly	O
declared	O
final	B-Language
in	O
the	O
declaring	O
class	O
Foo	O
*	O
const	O
b	O
=	O
new	B-Language
Foo( )	O
;	O
</s>
<s>
//	O
to	O
the	O
object	O
assigned	O
to	O
it	O
here	O
final	B-Language
Foo	O
b	O
=	O
new	B-Language
Foo( )	O
;	O
</s>
<s>
//	O
a	O
declaration	O
of	O
a	O
"	O
final	B-Language
"	O
reference	O
b	O
=	O
new	B-Language
Foo( )	O
;	O
</s>
<s>
//	O
ILLEGAL	O
,	O
it	O
is	O
not	O
allowed	O
to	O
re-bind	O
it	O
b	O
=	O
new	B-Language
Foo( )	O
;	O
</s>
<s>
C++	B-Language
supports	O
goto	B-Application
statements	O
,	O
which	O
may	O
lead	O
to	O
spaghetti	O
code	O
programming	O
.	O
</s>
<s>
With	O
the	O
exception	B-General_Concept
of	O
the	O
goto	B-Application
statement	O
(	O
which	O
is	O
very	O
rarely	O
seen	O
in	O
real	O
code	O
and	O
highly	O
discouraged	O
)	O
,	O
both	O
Java	B-Language
and	O
C++	B-Language
have	O
basically	O
the	O
same	O
control	O
flow	O
structures	O
,	O
designed	O
to	O
enforce	O
structured	O
control	O
flow	O
,	O
and	O
relies	O
on	O
break	O
and	O
continue	O
statements	O
to	O
provide	O
some	O
goto-like	O
functions	O
.	O
</s>
<s>
C++	B-Language
provides	O
low-level	O
features	O
which	O
Java	B-Language
mostly	O
lacks	O
(	O
one	O
notable	O
exception	B-General_Concept
being	O
the	O
sun.misc.Unsafe	O
API	B-Application
for	O
direct	O
memory	O
access	O
and	O
manipulation	O
)	O
.	O
</s>
<s>
In	O
C++	B-Language
,	O
pointers	O
can	O
be	O
used	O
to	O
manipulate	O
specific	O
memory	O
locations	O
,	O
a	O
task	O
necessary	O
for	O
writing	O
low-level	O
operating	B-General_Concept
system	I-General_Concept
components	O
.	O
</s>
<s>
Similarly	O
,	O
many	O
C++	B-Language
compilers	O
support	O
an	O
inline	B-Language
assembler	I-Language
.	O
</s>
<s>
Assembly	O
language	O
code	O
can	O
be	O
imported	O
to	O
a	O
C	B-Language
program	I-Language
and	O
vice	O
versa	O
.	O
</s>
<s>
This	O
makes	O
C	B-Language
language	I-Language
even	O
faster	O
.	O
</s>
<s>
In	O
Java	B-Language
,	O
such	O
code	O
must	O
reside	O
in	O
external	O
libraries	O
,	O
and	O
can	O
only	O
be	O
accessed	O
via	O
the	O
Java	B-Language
Native	I-Language
Interface	I-Language
,	O
with	O
a	O
significant	O
overhead	O
for	O
each	O
call	O
.	O
</s>
<s>
C++	B-Language
allows	O
default	O
values	O
for	O
arguments	O
of	O
a	O
function/method	O
.	O
</s>
<s>
Java	B-Language
does	O
not	O
.	O
</s>
<s>
However	O
,	O
method	B-Language
overloading	I-Language
can	O
be	O
used	O
to	O
obtain	O
similar	O
results	O
in	O
Java	B-Language
but	O
generate	O
redundant	O
stub	O
code	O
.	O
</s>
<s>
The	O
minimum	O
of	O
code	O
needed	O
to	O
compile	O
for	O
C++	B-Language
is	O
a	O
function	O
,	O
for	O
Java	B-Language
is	O
a	O
class	O
.	O
</s>
<s>
C++	B-Language
allows	O
a	O
range	O
of	O
implicit	O
conversions	O
between	O
native	O
types	O
(	O
including	O
some	O
narrowing	O
conversions	O
)	O
,	O
and	O
also	O
allows	O
defining	O
implicit	O
conversions	O
involving	O
user-defined	O
types	O
.	O
</s>
<s>
In	O
Java	B-Language
,	O
only	O
widening	O
conversions	O
between	O
native	O
types	O
are	O
implicit	O
;	O
other	O
conversions	O
require	O
explicit	O
cast	O
syntax	O
.	O
</s>
<s>
A	O
result	O
of	O
this	O
is	O
that	O
although	O
loop	O
conditions	O
(	O
if	O
,	O
while	O
and	O
the	O
exit	O
condition	O
in	O
for	O
)	O
in	O
Java	B-Language
and	O
C++	B-Language
both	O
expect	O
a	O
boolean	O
expression	O
,	O
code	O
such	O
as	O
if( a	O
=	O
5	O
)	O
will	O
cause	O
a	O
compile	O
error	O
in	O
Java	B-Language
because	O
there	O
is	O
no	O
implicit	O
narrowing	O
conversion	O
from	O
int	O
to	O
boolean	O
,	O
but	O
will	O
compile	O
in	O
C++	B-Language
.	O
</s>
<s>
However	O
,	O
current	O
C++	B-Language
compilers	O
will	O
usually	O
generate	O
a	O
warning	O
when	O
such	O
an	O
assignment	O
is	O
performed	O
within	O
a	O
conditional	O
expression	O
.	O
</s>
<s>
For	O
passing	O
parameters	O
to	O
functions	O
,	O
C++	B-Language
supports	O
both	O
pass-by-reference	O
and	O
pass-by-value	O
.	O
</s>
<s>
In	O
Java	B-Language
,	O
primitive	O
parameters	O
are	O
always	O
passed	O
by	O
value	O
.	O
</s>
<s>
Class	O
types	O
,	O
interface	B-Language
types	O
,	O
and	O
array	O
types	O
are	O
collectively	O
called	O
reference	B-Language
types	I-Language
in	O
Java	B-Language
and	O
are	O
also	O
always	O
passed	O
by	O
value	O
.	O
</s>
<s>
Java	B-Language
built-in	O
types	O
are	O
of	O
a	O
specified	O
size	O
and	O
range	O
defined	O
by	O
the	O
language	O
specification	O
.	O
</s>
<s>
In	O
C++	B-Language
,	O
a	O
minimal	O
range	O
of	O
values	O
is	O
defined	O
for	O
built-in	O
types	O
,	O
but	O
the	O
exact	O
representation	O
(	O
number	O
of	O
bits	O
)	O
can	O
be	O
mapped	O
to	O
whatever	O
native	O
types	O
are	O
preferred	O
on	O
a	O
given	O
platform	O
.	O
</s>
<s>
For	O
instance	O
,	O
Java	B-Language
characters	O
are	O
16-bit	O
Unicode	O
characters	O
,	O
and	O
strings	O
are	O
composed	O
of	O
a	O
sequence	O
of	O
such	O
characters	O
.	O
</s>
<s>
C++	B-Language
offers	O
both	O
narrow	O
and	O
wide	O
characters	O
,	O
but	O
the	O
actual	O
size	O
of	O
each	O
is	O
platform	B-Operating_System
dependent	I-Operating_System
,	O
as	O
is	O
the	O
character	O
set	O
used	O
.	O
</s>
<s>
This	O
also	O
implies	O
that	O
C++	B-Language
compilers	O
can	O
automatically	O
select	O
the	O
most	O
efficient	O
representation	O
for	O
the	O
target	O
platform	O
(	O
i.e.	O
,	O
64-bit	O
integers	O
for	O
a	O
64-bit	O
platform	O
)	O
,	O
while	O
the	O
representation	O
is	O
fixed	O
in	O
Java	B-Language
,	O
meaning	O
the	O
values	O
can	O
either	O
be	O
stored	O
in	O
the	O
less-efficient	O
size	O
,	O
or	O
must	O
pad	O
the	O
remaining	O
bits	O
and	O
add	O
code	O
to	O
emulate	O
the	O
reduced-width	O
behavior	O
.	O
</s>
<s>
The	O
rounding	O
and	O
precision	O
of	O
floating	O
point	O
values	O
and	O
operations	O
in	O
C++	B-Language
is	O
implementation-defined	O
(	O
although	O
only	O
very	O
exotic	O
or	O
old	O
platforms	O
depart	O
from	O
the	O
IEEE	O
754	O
standard	O
)	O
.	O
</s>
<s>
Java	B-Language
provides	O
an	O
optional	O
strict	O
floating-point	O
model	O
(	O
strictfp	B-Language
)	O
that	O
guarantees	O
more	O
consistent	O
results	O
across	O
platforms	O
,	O
though	O
at	O
the	O
cost	O
of	O
possibly	O
slower	O
run-time	O
performance	O
.	O
</s>
<s>
However	O
,	O
Java	B-Language
does	O
not	O
comply	O
strictly	O
with	O
the	O
IEEE	O
754	O
standard	O
.	O
</s>
<s>
Most	O
C++	B-Language
compilers	O
will	O
,	O
by	O
default	O
,	O
comply	O
partly	O
with	O
IEEE	O
754	O
(	O
usually	O
excluding	O
strict	O
rounding	O
rules	O
and	O
raise	O
exceptions	O
on	O
NaN	O
results	O
)	O
,	O
but	O
provide	O
compliance	O
options	O
of	O
varied	O
strictness	O
,	O
to	O
allow	O
for	O
some	O
optimizing	O
.	O
</s>
<s>
If	O
we	O
label	O
those	O
options	O
from	O
least	O
compliant	O
to	O
most	O
compliant	O
as	O
fast	O
,	O
consistent	O
(	O
Java	B-Language
's	O
strictfp	B-Language
)	O
,	O
near-IEEE	O
,	O
and	O
strict-IEEE	O
,	O
we	O
can	O
say	O
that	O
most	O
C++	B-Language
implementations	O
default	O
to	O
near-IEEE	O
,	O
with	O
options	O
to	O
switch	O
to	O
fast	O
or	O
strict-IEEE	O
,	O
while	O
Java	B-Language
defaults	O
to	O
fast	O
with	O
an	O
option	O
to	O
switch	O
to	O
consistent	O
.	O
</s>
<s>
In	O
C++	B-Language
,	O
pointers	O
can	O
be	O
manipulated	O
directly	O
as	O
memory	O
address	O
values	O
.	O
</s>
<s>
Java	B-Language
references	O
are	O
pointers	O
to	O
objects	O
.	O
</s>
<s>
Java	B-Language
references	O
do	O
not	O
allow	O
direct	O
access	O
to	O
memory	O
addresses	O
or	O
allow	O
memory	O
addresses	O
to	O
be	O
manipulated	O
with	O
pointer	O
arithmetic	O
.	O
</s>
<s>
In	O
C++	B-Language
one	O
can	O
construct	O
pointers	O
to	O
pointers	O
,	O
pointers	O
to	O
ints	O
and	O
doubles	O
,	O
and	O
pointers	O
to	O
arbitrary	O
memory	O
locations	O
.	O
</s>
<s>
Java	B-Language
references	O
only	O
access	O
objects	O
,	O
never	O
primitives	O
,	O
other	O
references	O
,	O
or	O
arbitrary	O
memory	O
locations	O
.	O
</s>
<s>
In	O
Java	B-Language
,	O
memory	O
can	O
be	O
read	O
and	O
written	O
by	O
arbitrary	O
values	O
using	O
the	O
sun.misc.Unsafe	O
API	B-Application
,	O
however	O
it	O
is	O
deprecated	O
and	O
not	O
recommended	O
.	O
</s>
<s>
In	O
C++	B-Language
,	O
pointers	O
can	O
point	O
to	O
functions	O
or	O
member	O
functions	O
(	O
function	B-Language
pointers	I-Language
)	O
.	O
</s>
<s>
The	O
equivalent	O
mechanism	O
in	O
Java	B-Language
uses	O
object	O
or	O
interface	B-Language
references	O
.	O
</s>
<s>
Via	O
stack-allocated	O
objects	O
,	O
C++	B-Language
supports	O
scoped	B-Application
resource	I-Application
management	I-Application
,	O
a	O
technique	O
used	O
to	O
automatically	O
manage	O
memory	O
and	O
other	O
system	O
resources	O
that	O
supports	O
deterministic	O
object	O
destruction	O
.	O
</s>
<s>
While	O
scoped	B-Application
resource	I-Application
management	I-Application
in	O
C++	B-Language
cannot	O
be	O
guaranteed	O
(	O
even	O
objects	O
with	O
proper	O
destructors	O
can	O
be	O
allocated	O
using	O
new	B-Language
and	O
left	O
undeleted	O
)	O
it	O
provides	O
an	O
effective	O
means	O
of	O
resource	O
management	O
.	O
</s>
<s>
Java	B-Language
supports	O
automatic	B-General_Concept
memory	I-General_Concept
management	I-General_Concept
using	O
garbage	B-General_Concept
collection	I-General_Concept
which	O
can	O
free	O
unreachable	B-General_Concept
objects	I-General_Concept
even	O
in	O
the	O
presence	O
of	O
cyclic	O
references	O
,	O
but	O
other	O
system	O
resources	O
(	O
files	O
,	O
streams	O
,	O
windows	B-Application
,	O
communication	O
ports	O
,	O
threads	B-Operating_System
,	O
etc	O
.	O
)	O
</s>
<s>
must	O
be	O
explicitly	O
released	O
because	O
garbage	B-General_Concept
collection	I-General_Concept
is	O
not	O
guaranteed	O
to	O
occur	O
immediately	O
after	O
the	O
last	O
object	O
reference	O
is	O
abandoned	O
.	O
</s>
<s>
C++	B-Language
features	O
user-defined	O
operator	O
overloading	O
.	O
</s>
<s>
Java	B-Language
supports	O
no	O
form	O
of	O
operator	O
overloading	O
(	O
although	O
its	O
library	O
uses	O
the	O
addition	O
operator	O
for	O
string	O
concatenation	O
)	O
.	O
</s>
<s>
Java	B-Language
features	O
standard	O
application	B-Application
programming	I-Application
interface	I-Application
(	O
API	B-Application
)	O
support	O
for	O
reflection	B-Language
and	O
dynamic	B-Operating_System
loading	I-Operating_System
of	O
arbitrary	O
new	B-Language
code	O
.	O
</s>
<s>
C++	B-Language
supports	O
static	O
and	O
dynamic	O
linking	O
of	O
binaries	O
.	O
</s>
<s>
Java	B-Language
has	O
generics	B-Language
,	O
whose	O
main	O
purpose	O
is	O
to	O
provide	O
type-safe	B-Language
containers	O
.	O
</s>
<s>
C++	B-Language
has	O
compile-time	O
templates	B-Application
,	O
which	O
provide	O
more	O
extensive	O
support	O
for	O
generic	B-Language
programming	I-Language
and	O
metaprogramming	O
.	O
</s>
<s>
Java	B-Language
has	O
annotations	B-Language
,	O
which	O
allow	O
adding	O
arbitrary	O
custom	O
metadata	O
to	O
classes	O
and	O
metaprogramming	O
via	O
an	O
annotation	O
processing	O
tool	O
.	O
</s>
<s>
Both	O
Java	B-Language
and	O
C++	B-Language
distinguish	O
between	O
native	O
types	O
(	O
also	O
termed	O
fundamental	O
or	O
built-in	O
types	O
)	O
and	O
user-defined	O
types	O
(	O
also	O
termed	O
compound	O
types	O
)	O
.	O
</s>
<s>
In	O
Java	B-Language
,	O
native	O
types	O
have	O
value	O
semantics	O
only	O
,	O
and	O
compound	O
types	O
have	O
reference	O
semantics	O
only	O
.	O
</s>
<s>
In	O
C++	B-Language
all	O
types	O
have	O
value	O
semantics	O
,	O
but	O
a	O
reference	O
can	O
be	O
created	O
to	O
any	O
type	O
,	O
which	O
will	O
allow	O
the	O
object	O
to	O
be	O
manipulated	O
via	O
reference	O
semantics	O
.	O
</s>
<s>
C++	B-Language
supports	O
multiple	B-Application
inheritance	I-Application
of	O
arbitrary	O
classes	O
.	O
</s>
<s>
In	O
Java	B-Language
a	O
class	O
can	O
derive	O
from	O
only	O
one	O
class	O
,	O
but	O
a	O
class	O
can	O
implement	O
multiple	O
interfaces	B-Language
(	O
in	O
other	O
words	O
,	O
it	O
supports	O
multiple	B-Application
inheritance	I-Application
of	O
types	O
,	O
but	O
only	O
single	O
inheritance	O
of	O
implementation	O
)	O
.	O
</s>
<s>
Java	B-Language
explicitly	O
distinguishes	O
between	O
interfaces	B-Language
and	O
classes	O
.	O
</s>
<s>
In	O
C++	B-Language
,	O
multiple	B-Application
inheritance	I-Application
and	O
pure	B-Application
virtual	I-Application
functions	I-Application
make	O
it	O
possible	O
to	O
define	O
classes	O
that	O
function	O
almost	O
like	O
Java	B-Language
interfaces	I-Language
do	O
,	O
with	O
a	O
few	O
small	O
differences	O
.	O
</s>
<s>
Java	B-Language
has	O
both	O
language	O
and	O
standard	O
library	O
support	O
for	O
multi-threading	B-Operating_System
.	O
</s>
<s>
The	O
synchronized	O
keyword	B-Language
in	I-Language
Java	I-Language
provides	O
simple	O
and	O
secure	O
mutex	B-Operating_System
locks	I-Operating_System
to	O
support	O
multi-threaded	B-Operating_System
applications	O
.	O
</s>
<s>
Java	B-Language
also	O
provides	O
robust	O
and	O
complex	O
libraries	O
for	O
more	O
advanced	O
multi-threading	B-Operating_System
synchronizing	O
.	O
</s>
<s>
Only	O
as	O
of	O
C++11	B-Language
is	O
there	O
a	O
defined	O
memory	O
model	O
for	O
multi-threading	B-Operating_System
in	O
C++	B-Language
,	O
and	O
library	O
support	O
for	O
creating	O
threads	B-Operating_System
and	O
for	O
many	O
synchronizing	O
primitives	O
.	O
</s>
<s>
C++	B-Language
member	O
functions	O
can	O
be	O
declared	O
as	O
virtual	B-Application
functions	I-Application
,	O
which	O
means	O
the	O
method	O
to	O
be	O
called	O
is	O
determined	O
by	O
the	O
run-time	O
type	O
of	O
the	O
object	O
(	O
a.k.a.	O
</s>
<s>
By	O
default	O
,	O
methods	O
in	O
C++	B-Language
are	O
not	O
virtual	O
(	O
i.e.	O
,	O
opt-in	O
virtual	O
)	O
.	O
</s>
<s>
In	O
Java	B-Language
,	O
methods	O
are	O
virtual	O
by	O
default	O
,	O
but	O
can	O
be	O
made	O
non-virtual	O
by	O
using	O
the	O
final	B-Language
keyword	O
(	O
i.e.	O
,	O
opt-out	O
virtual	O
)	O
.	O
</s>
<s>
C++	B-Language
enumerations	O
are	O
primitive	O
types	O
and	O
support	O
implicit	O
conversion	O
to	O
integer	O
types	O
(	O
but	O
not	O
from	O
integer	O
types	O
)	O
.	O
</s>
<s>
Java	B-Language
enumerations	O
can	O
be	O
public	O
static	O
enum{enumName1,enumName2}	O
and	O
are	O
used	O
like	O
classes	O
.	O
</s>
<s>
Another	O
way	O
is	O
to	O
make	O
another	O
class	O
that	O
extends	O
java.lang.Enumxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1	O
)	O
and	O
may	O
therefore	O
define	O
constructors	O
,	O
fields	O
,	O
and	O
methods	O
as	O
any	O
other	O
class	O
.	O
</s>
<s>
As	O
of	O
C++11	B-Language
,	O
C++	B-Language
also	O
supports	O
strongly-typed	O
enumerations	O
which	O
provide	O
more	O
type-safety	B-Language
and	O
explicit	O
specification	O
of	O
the	O
storage	O
type	O
.	O
</s>
<s>
Unary	O
operators	O
'	O
++	O
 '	O
and	O
'	O
--	O
 '	O
:	O
in	O
C++	B-Language
"	O
The	O
operand	O
shall	O
be	O
a	O
modifiable	O
lvalue	O
.	O
</s>
<s>
 [ skipped ] 	O
The	O
result	O
is	O
the	O
updated	O
operand	O
;	O
it	O
is	O
an	O
lvalue	O
...	O
"	O
,	O
but	O
in	O
Java	B-Language
"	O
the	O
binary	O
numeric	O
promotion	O
mentioned	O
above	O
may	O
include	O
unboxing	O
conversion	O
and	O
value	O
set	O
conversion	O
.	O
</s>
<s>
in	O
Java	B-Language
,	O
after	O
the	O
initialization	O
"	O
Integer	O
i	O
=	O
2	O
;	O
"	O
,	O
"	O
++i	O
;	O
"	O
changes	O
the	O
reference	O
i	O
by	O
assigning	O
new	B-Language
object	O
,	O
while	O
in	O
C++	B-Language
the	O
object	O
is	O
still	O
the	O
same	O
.	O
</s>
<s>
Java	B-Language
offers	O
automatic	B-General_Concept
garbage	I-General_Concept
collection	I-General_Concept
,	O
which	O
may	O
be	O
bypassed	O
in	O
specific	O
circumstances	O
via	O
the	O
Real	B-Language
time	I-Language
Java	I-Language
specification	O
.	O
</s>
<s>
Memory	B-General_Concept
management	I-General_Concept
in	O
C++	B-Language
is	O
usually	O
done	O
via	O
constructors	O
,	O
destructors	O
,	O
and	O
smart	B-Language
pointers	I-Language
.	O
</s>
<s>
The	O
C++	B-Language
standard	O
permits	O
garbage	B-General_Concept
collection	I-General_Concept
,	O
but	O
does	O
not	O
require	O
it	O
.	O
</s>
<s>
Garbage	B-General_Concept
collection	I-General_Concept
is	O
rarely	O
used	O
in	O
practice	O
.	O
</s>
<s>
C++	B-Language
can	O
allocate	O
arbitrary	O
blocks	O
of	O
memory	O
.	O
</s>
<s>
Java	B-Language
only	O
allocates	O
memory	O
via	O
object	O
instantiation	O
.	O
</s>
<s>
Arbitrary	O
memory	O
blocks	O
may	O
be	O
allocated	O
in	O
Java	B-Language
as	O
an	O
array	O
of	O
bytes	O
.	O
</s>
<s>
Java	B-Language
and	O
C++	B-Language
use	O
different	O
idioms	O
for	O
resource	O
management	O
.	O
</s>
<s>
Java	B-Language
relies	O
mainly	O
on	O
garbage	B-General_Concept
collection	I-General_Concept
,	O
which	O
can	O
reclaim	O
memory	O
,	O
while	O
C++	B-Language
relies	O
mainly	O
on	O
the	O
Resource	B-Application
Acquisition	I-Application
Is	I-Application
Initialization	I-Application
(	O
RAII	B-Application
)	O
idiom	O
.	O
</s>
<s>
In	O
C++	B-Language
it	O
is	O
common	O
to	O
allocate	O
objects	O
of	O
compound	O
types	O
as	O
local	O
stack-bound	O
variables	O
which	O
are	O
destroyed	O
when	O
they	O
go	O
out	O
of	O
scope	O
.	O
</s>
<s>
In	O
Java	B-Language
compound	O
types	O
are	O
always	O
allocated	O
on	O
the	O
heap	B-General_Concept
and	O
collected	O
by	O
the	O
garbage	B-General_Concept
collector	I-General_Concept
(	O
except	O
in	O
virtual	O
machines	O
that	O
use	O
escape	O
analysis	O
to	O
convert	O
heap	B-Application
allocations	I-Application
to	O
stack	B-General_Concept
allocations	I-General_Concept
)	O
.	O
</s>
<s>
C++	B-Language
has	O
destructors	O
,	O
while	O
Java	B-Language
has	O
finalizers	B-Application
.	O
</s>
<s>
Both	O
are	O
invoked	O
before	O
an	O
object	O
's	O
deallocation	B-General_Concept
,	O
but	O
they	O
differ	O
significantly	O
.	O
</s>
<s>
A	O
C++	B-Language
object	O
's	O
destructor	O
must	O
be	O
invoked	O
implicitly	O
(	O
in	O
the	O
case	O
of	O
stack-bound	O
variables	O
)	O
or	O
explicitly	O
to	O
deallocate	O
an	O
object	O
.	O
</s>
<s>
Synchronous	O
,	O
coordinated	O
uninitializing	O
and	O
deallocating	O
in	O
C++	B-Language
thus	O
satisfy	O
the	O
RAII	B-Application
idiom	O
.	O
</s>
<s>
In	O
Java	B-Language
,	O
object	O
deallocation	B-General_Concept
is	O
implicitly	O
handled	O
by	O
the	O
garbage	B-General_Concept
collector	I-General_Concept
.	O
</s>
<s>
A	O
Java	B-Language
object	O
's	O
finalizer	B-Application
is	O
invoked	O
asynchronously	B-Operating_System
some	O
time	O
after	O
it	O
has	O
been	O
accessed	O
for	O
the	O
last	O
time	O
and	O
before	O
it	O
is	O
deallocated	O
.	O
</s>
<s>
Very	O
few	O
objects	O
need	O
finalizers	B-Application
.	O
</s>
<s>
A	O
finalizer	B-Application
is	O
needed	O
by	O
only	O
objects	O
that	O
must	O
guarantee	O
some	O
cleanup	O
of	O
the	O
object	O
state	O
before	O
deallocating	O
,	O
typically	O
releasing	O
resources	O
external	O
to	O
the	O
JVM	B-Language
.	O
</s>
<s>
Additionally	O
,	O
finalizers	B-Application
come	O
with	O
severe	O
performance	O
penalties	O
and	O
significantly	O
increase	O
the	O
time	O
it	O
takes	O
for	O
objects	O
to	O
be	O
deallocated	O
,	O
so	O
their	O
use	O
is	O
discouraged	O
and	O
deprecated	O
in	O
Java	B-Language
9	O
.	O
</s>
<s>
With	O
RAII	B-Application
in	O
C++	B-Language
,	O
one	O
type	O
of	O
resource	O
is	O
typically	O
wrapped	O
inside	O
a	O
small	O
class	O
that	O
allocates	O
the	O
resource	O
upon	O
construction	O
and	O
releases	O
the	O
resource	O
upon	O
destruction	O
,	O
and	O
provide	O
access	O
to	O
the	O
resource	O
in	O
between	O
those	O
points	O
.	O
</s>
<s>
Any	O
class	O
that	O
contain	O
only	O
such	O
RAII	B-Application
objects	O
do	O
not	O
need	O
to	O
define	O
a	O
destructor	O
since	O
the	O
destructors	O
of	O
the	O
RAII	B-Application
objects	O
are	O
called	O
automatically	O
as	O
an	O
object	O
of	O
this	O
class	O
is	O
destroyed	O
.	O
</s>
<s>
In	O
Java	B-Language
,	O
safe	O
synchronous	O
deallocation	B-General_Concept
of	O
resources	O
can	O
be	O
performed	O
deterministically	O
using	O
the	O
try/catch/finally	O
construct	O
.	O
</s>
<s>
In	O
C++	B-Language
,	O
it	O
is	O
possible	O
to	O
have	O
a	O
dangling	B-Error_Name
pointer	I-Error_Name
,	O
a	O
stale	O
reference	O
to	O
an	O
object	O
that	O
has	O
already	O
been	O
deallocated	O
.	O
</s>
<s>
Attempting	O
to	O
use	O
a	O
dangling	B-Error_Name
pointer	I-Error_Name
typically	O
results	O
in	O
program	O
failure	O
.	O
</s>
<s>
In	O
Java	B-Language
,	O
the	O
garbage	B-General_Concept
collector	I-General_Concept
will	O
not	O
destroy	O
a	O
referenced	O
object	O
.	O
</s>
<s>
In	O
C++	B-Language
,	O
it	O
is	O
possible	O
to	O
have	O
uninitialized	O
primitive	O
objects	O
.	O
</s>
<s>
Java	B-Language
enforces	O
default	O
initialization	O
.	O
</s>
<s>
In	O
C++	B-Language
,	O
it	O
is	O
possible	O
to	O
have	O
an	O
allocated	O
object	O
to	O
which	O
there	O
is	O
no	O
valid	O
reference	O
.	O
</s>
<s>
Such	O
an	O
unreachable	B-General_Concept
object	I-General_Concept
cannot	O
be	O
destroyed	O
(	O
deallocated	O
)	O
,	O
and	O
results	O
in	O
a	O
memory	B-Error_Name
leak	I-Error_Name
.	O
</s>
<s>
In	O
contrast	O
,	O
in	O
Java	B-Language
an	O
object	O
will	O
not	O
be	O
deallocated	O
by	O
the	O
garbage	B-General_Concept
collector	I-General_Concept
until	O
it	O
becomes	O
unreachable	B-General_Concept
(	O
by	O
the	O
user	O
program	O
)	O
.	O
</s>
<s>
(	O
Weak	B-General_Concept
references	I-General_Concept
are	O
supported	O
,	O
which	O
work	O
with	O
the	O
Java	B-Language
garbage	B-General_Concept
collector	I-General_Concept
to	O
allow	O
for	O
different	O
strengths	O
of	O
reachability	O
.	O
)	O
</s>
<s>
Garbage	B-General_Concept
collection	I-General_Concept
in	O
Java	B-Language
prevents	O
many	O
memory	B-Error_Name
leaks	I-Error_Name
,	O
but	O
leaks	O
are	O
still	O
possible	O
under	O
some	O
circumstances	O
.	O
</s>
<s>
C++	B-Language
provides	O
cross-platform	B-Operating_System
access	O
to	O
many	O
features	O
typically	O
available	O
in	O
platform-specific	O
libraries	O
.	O
</s>
<s>
Direct	O
access	O
from	O
Java	B-Language
to	O
native	O
operating	B-General_Concept
system	I-General_Concept
and	O
hardware	O
functions	O
requires	O
the	O
use	O
of	O
the	O
Java	B-Language
Native	I-Language
Interface	I-Language
.	O
</s>
<s>
C++	B-Language
Java	B-Language
C++	B-Language
is	O
compiled	O
directly	O
to	O
machine	B-Language
code	I-Language
which	O
is	O
then	O
executed	O
directly	O
by	O
the	O
central	B-General_Concept
processing	I-General_Concept
unit	I-General_Concept
.	O
</s>
<s>
Java	B-Language
is	O
compiled	O
to	O
byte-code	O
which	O
the	O
Java	B-Language
virtual	I-Language
machine	I-Language
(	O
JVM	B-Language
)	O
then	O
interprets	B-Application
at	O
runtime	O
.	O
</s>
<s>
Actual	O
Java	B-Language
implementations	O
do	O
just-in-time	O
compilation	O
to	O
native	O
machine	B-Language
code	I-Language
.	O
</s>
<s>
Alternatively	O
,	O
the	O
GNU	B-Language
Compiler	I-Language
for	I-Language
Java	I-Language
can	O
compile	O
directly	O
to	O
machine	B-Language
code	I-Language
.	O
</s>
<s>
Due	O
to	O
its	O
unconstrained	O
expressiveness	O
,	O
low	O
level	O
C++	B-Language
language	I-Language
features	O
(	O
e.g.	O
</s>
<s>
unchecked	O
array	O
access	O
,	O
raw	O
pointers	O
,	O
type	B-Language
punning	I-Language
)	O
cannot	O
be	O
reliably	O
checked	O
at	O
compile-time	O
or	O
without	O
overhead	O
at	O
run-time	O
.	O
</s>
<s>
Related	O
programming	O
errors	O
can	O
lead	O
to	O
low-level	O
buffer	B-General_Concept
overflows	I-General_Concept
and	O
segmentation	B-Error_Name
faults	I-Error_Name
.	O
</s>
<s>
The	O
Standard	B-Application
Template	I-Application
Library	I-Application
provides	O
higher-level	O
RAII	B-Application
abstractions	O
(	O
like	O
vector	O
,	O
list	O
and	O
map	O
)	O
to	O
help	O
avoid	O
such	O
errors	O
.	O
</s>
<s>
In	O
Java	B-Language
,	O
low	O
level	O
errors	O
either	O
cannot	O
occur	O
or	O
are	O
detected	O
by	O
the	O
Java	B-Language
virtual	I-Language
machine	I-Language
(	O
JVM	B-Language
)	O
and	O
reported	O
to	O
the	O
application	O
in	O
the	O
form	O
of	O
an	O
exception	B-General_Concept
.	O
</s>
<s>
The	O
Java	B-Language
language	I-Language
requires	O
specific	O
behavior	O
in	O
the	O
case	O
of	O
an	O
out-of-bounds	O
array	O
access	O
,	O
which	O
generally	O
requires	O
bounds	B-Data_Structure
checking	I-Data_Structure
of	O
array	O
accesses	O
.	O
</s>
<s>
In	O
some	O
cases	O
,	O
especially	O
since	O
Java	B-Language
7	O
,	O
compiler	B-Application
analysis	I-Application
can	O
prove	O
a	O
bounds	B-Data_Structure
check	I-Data_Structure
unneeded	O
and	O
eliminate	O
it	O
.	O
</s>
<s>
C++	B-Language
has	O
no	O
required	O
behavior	O
for	O
out-of-bounds	O
access	O
of	O
native	O
arrays	O
,	O
thus	O
requiring	O
no	O
bounds	B-Data_Structure
checking	I-Data_Structure
for	O
native	O
arrays	O
.	O
</s>
<s>
C++	B-Language
standard	I-Language
library	I-Language
collections	O
like	O
std::vector	O
,	O
however	O
,	O
offer	O
optional	O
bounds	B-Data_Structure
checking	I-Data_Structure
.	O
</s>
<s>
In	O
summary	O
,	O
Java	B-Language
arrays	O
are	O
"	O
usually	O
safe	O
;	O
slightly	O
constrained	O
;	O
often	O
have	O
overhead	O
"	O
while	O
C++	B-Language
native	O
arrays	O
"	O
have	O
optional	O
overhead	O
;	O
are	O
slightly	O
unconstrained	O
;	O
are	O
possibly	O
unsafe.	O
"	O
</s>
<s>
Both	O
C++	B-Language
and	O
Java	B-Language
provide	O
facilities	O
for	O
generic	B-Language
programming	I-Language
,	O
templates	B-Application
and	O
generics	B-Language
,	O
respectively	O
.	O
</s>
<s>
|	O
Parameters	O
can	O
be	O
variadic	O
,	O
of	O
any	O
type	O
,	O
integral	O
value	O
,	O
character	O
literal	O
,	O
or	O
a	O
class	O
template	B-Application
.	O
</s>
<s>
|	O
Parameters	O
can	O
be	O
any	O
reference	B-Language
type	I-Language
,	O
including	O
boxed	O
primitive	O
types	O
(	O
i.e.	O
</s>
<s>
For	O
class	O
templates	B-Application
,	O
only	O
the	O
member	O
functions	O
that	O
are	O
used	O
will	O
be	O
instantiated	O
.	O
</s>
<s>
|	O
Objects	O
of	O
a	O
class	O
template	B-Application
instantiated	O
with	O
different	O
parameters	O
will	O
have	O
different	O
types	O
at	O
run	O
time	O
(	O
i.e.	O
,	O
distinct	O
template	B-Application
instantiations	O
are	O
distinct	O
classes	O
)	O
.	O
</s>
<s>
Because	O
of	O
this	O
type	B-General_Concept
erasure	I-General_Concept
,	O
it	O
is	O
not	O
possible	O
to	O
overload	B-Language
methods	O
using	O
different	O
instantiations	O
of	O
the	O
generic	B-Language
class	I-Language
.	O
</s>
<s>
|	O
Implementation	O
of	O
the	O
class	O
or	O
function	O
template	B-Application
must	O
be	O
visible	O
within	O
a	O
translation	O
unit	O
in	O
order	O
to	O
use	O
it	O
.	O
</s>
<s>
This	O
usually	O
implies	O
having	O
the	O
definitions	O
in	O
the	O
header	B-Language
files	I-Language
or	O
included	O
in	O
the	O
header	B-Language
file	I-Language
.	O
</s>
<s>
As	O
of	O
C++11	B-Language
,	O
it	O
is	O
possible	O
to	O
use	O
extern	O
templates	B-Application
to	O
separate	O
compiling	O
of	O
some	O
instantiations	O
.	O
</s>
<s>
|	O
Signature	O
of	O
the	O
class	O
or	O
function	O
from	O
a	O
compiled	O
class	B-Language
file	I-Language
is	O
sufficient	O
to	O
use	O
it	O
.	O
</s>
<s>
|	O
Templates	B-Application
can	O
be	O
specialized	O
—	O
a	O
separate	O
implementation	O
could	O
be	O
provided	O
for	O
a	O
particular	O
template	B-Application
parameter	O
.	O
</s>
<s>
|	O
Generics	B-Language
cannot	O
be	O
specialized	O
.	O
</s>
<s>
|	O
Template	B-Application
parameters	O
can	O
have	O
default	B-Language
arguments	I-Language
.	O
</s>
<s>
Pre-C	O
++11	O
,	O
this	O
was	O
allowed	O
only	O
for	O
template	B-Application
classes	O
,	O
not	O
functions	O
.	O
</s>
<s>
|	O
Generic	B-Language
type	I-Language
parameters	O
cannot	O
have	O
default	B-Language
arguments	I-Language
.	O
</s>
<s>
Instead	O
,	O
return	O
types	O
are	O
often	O
available	O
as	O
nested	O
typedefs	B-Language
.	O
</s>
<s>
(	O
Also	O
,	O
C++11	B-Language
added	O
keyword	O
auto	O
,	O
which	O
acts	O
as	O
a	O
wildcard	O
for	O
any	O
type	O
that	O
can	O
be	O
determined	O
at	O
compile	O
time	O
.	O
)	O
</s>
<s>
|	O
Precludes	O
instantiation	O
of	O
an	O
object	O
with	O
the	O
type	O
of	O
the	O
parameter	O
type	O
(	O
except	O
via	O
reflection	B-Language
)	O
.	O
</s>
<s>
|	O
Type	O
parameter	O
of	O
class	O
template	B-Application
can	O
be	O
used	O
for	O
static	O
methods	O
and	O
variables	O
.	O
</s>
<s>
|	O
Type	O
parameter	O
of	O
generic	B-Language
class	I-Language
cannot	O
be	O
used	O
for	O
static	O
methods	O
and	O
variables	O
.	O
</s>
<s>
|	O
Static	B-General_Concept
variables	I-General_Concept
unshared	O
between	O
classes	O
and	O
functions	O
of	O
different	O
type	O
parameters	O
.	O
</s>
<s>
|	O
Static	B-General_Concept
variables	I-General_Concept
shared	O
between	O
instances	O
of	O
classes	O
of	O
different	O
type	O
parameters	O
.	O
</s>
<s>
|	O
Class	O
and	O
function	O
templates	B-Application
do	O
not	O
enforce	O
type	O
relations	O
for	O
type	O
parameters	O
in	O
their	O
declaration	O
.	O
</s>
<s>
Use	O
of	O
an	O
incorrect	O
type	O
parameter	O
results	O
in	O
compiling	O
failure	O
,	O
often	O
generating	O
an	O
error	O
message	O
within	O
the	O
template	B-Application
code	O
rather	O
than	O
in	O
the	O
user	O
's	O
code	O
that	O
invokes	O
it	O
.	O
</s>
<s>
There	O
was	O
a	O
proposition	O
to	O
solve	O
this	O
problem	O
in	O
C++11	B-Language
,	O
so-called	O
Concepts	B-Language
,	O
it	O
is	O
planned	O
for	O
the	O
next	O
standard	O
.	O
</s>
<s>
This	O
results	O
in	O
greater	O
type	B-Language
safety	I-Language
at	O
the	O
cost	O
of	O
flexibility	O
.	O
</s>
<s>
|	O
Templates	B-Application
are	O
Turing-complete	O
(	O
see	O
template	B-Language
metaprogramming	I-Language
)	O
.	O
</s>
<s>
Java	B-Language
and	O
C++	B-Language
use	O
different	O
means	O
to	O
divide	O
code	O
into	O
multiple	O
source	O
files	O
.	O
</s>
<s>
Java	B-Language
uses	O
a	O
package	O
system	O
that	O
dictates	O
the	O
file	O
name	O
and	O
path	O
for	O
all	O
program	O
definitions	O
.	O
</s>
<s>
Its	O
compiler	O
imports	O
the	O
executable	O
class	B-Language
files	I-Language
.	O
</s>
<s>
C++	B-Language
uses	O
a	O
header	B-Language
file	I-Language
source	O
code	O
inclusion	O
system	O
to	O
share	O
declarations	O
between	O
source	O
files	O
.	O
</s>
<s>
Compiled	O
Java	B-Language
code	I-Language
files	O
are	O
generally	O
smaller	O
than	O
code	O
files	O
in	O
C++	B-Language
as	O
Java	B-Language
bytecode	I-Language
is	O
usually	O
more	O
compact	O
than	O
native	O
machine	B-Language
code	I-Language
and	O
Java	B-Language
programs	O
are	O
never	O
statically	O
linked	O
.	O
</s>
<s>
C++	B-Language
compiling	O
features	O
an	O
added	O
textual	O
preprocessing	B-General_Concept
phase	O
,	O
while	O
Java	B-Language
does	O
not	O
.	O
</s>
<s>
Thus	O
some	O
users	O
add	O
a	O
preprocessing	B-General_Concept
phase	O
to	O
their	O
build	O
process	O
for	O
better	O
support	O
of	O
conditional	O
compiling	O
.	O
</s>
<s>
Java	B-Language
's	O
division	O
and	O
modulus	O
operators	O
are	O
well	O
defined	O
to	O
truncate	O
to	O
zero	O
.	O
</s>
<s>
C++	B-Language
(	O
pre-C	O
++11	O
)	O
does	O
not	O
specify	O
whether	O
or	O
not	O
these	O
operators	O
truncate	O
to	O
zero	O
or	O
"	O
truncate	O
to	O
-infinity	O
"	O
.	O
</s>
<s>
-3/2	O
will	O
always	O
be	O
-1	O
in	O
Java	B-Language
and	O
C++11	B-Language
,	O
but	O
a	O
C++03	B-Language
compiler	O
may	O
return	O
either	O
-1	O
or	O
-2	O
,	O
depending	O
on	O
the	O
platform	O
.	O
</s>
<s>
C99	B-Language
defines	O
division	O
in	O
the	O
same	O
fashion	O
as	O
Java	B-Language
and	O
C++11	B-Language
.	I-Language
</s>
<s>
The	O
C++03	B-Language
version	O
will	O
sometimes	O
be	O
faster	O
,	O
as	O
it	O
is	O
allowed	O
to	O
pick	O
whichever	O
truncation	O
mode	O
is	O
native	O
to	O
the	O
processor	O
.	O
</s>
<s>
The	O
sizes	O
of	O
integer	O
types	O
are	O
defined	O
in	O
Java	B-Language
(	O
int	O
is	O
32-bit	O
,	O
long	O
is	O
64-bit	O
)	O
,	O
while	O
in	O
C++	B-Language
the	O
size	O
of	O
integers	O
and	O
pointers	O
is	O
compiler	O
and	O
application	B-Operating_System
binary	I-Operating_System
interface	I-Operating_System
(	O
ABI	O
)	O
dependent	O
within	O
given	O
constraints	O
.	O
</s>
<s>
Thus	O
a	O
Java	B-Language
program	O
will	O
have	O
consistent	O
behavior	O
across	O
platforms	O
,	O
whereas	O
a	O
C++	B-Language
program	I-Language
may	O
require	O
adapting	O
for	O
some	O
platforms	O
,	O
but	O
may	O
run	O
faster	O
with	O
more	O
natural	O
integer	O
sizes	O
for	O
the	O
local	O
platform	O
.	O
</s>
<s>
An	O
example	O
comparing	O
C++	B-Language
and	O
Java	B-Language
exists	O
in	O
Wikibooks	O
.	O
</s>
<s>
In	O
addition	O
to	O
running	O
a	O
compiled	O
Java	B-Language
program	O
,	O
computers	O
running	O
Java	B-Language
applications	O
generally	O
must	O
also	O
run	O
the	O
Java	B-Language
virtual	I-Language
machine	I-Language
(	O
JVM	B-Language
)	O
,	O
while	O
compiled	O
C++	B-Language
programs	I-Language
can	O
be	O
run	O
without	O
external	O
applications	O
.	O
</s>
<s>
Early	O
versions	O
of	O
Java	B-Language
were	O
significantly	O
outperformed	O
by	O
statically	O
compiled	O
languages	O
such	O
as	O
C++	B-Language
.	O
</s>
<s>
This	O
is	O
because	O
the	O
program	O
statements	O
of	O
these	O
two	O
closely	O
related	O
languages	O
may	O
compile	O
to	O
a	O
few	O
machine	B-Language
instructions	I-Language
with	O
C++	B-Language
,	O
while	O
compiling	O
into	O
several	O
byte	O
codes	O
involving	O
several	O
machine	B-Language
instructions	I-Language
each	O
when	O
interpreted	O
by	O
a	O
JVM	B-Language
.	O
</s>
<s>
Since	O
performance	O
optimization	O
is	O
a	O
very	O
complex	O
issue	O
,	O
it	O
is	O
very	O
difficult	O
to	O
quantify	O
the	O
performance	O
difference	O
between	O
C++	B-Language
and	O
Java	B-Language
in	O
general	O
terms	O
,	O
and	O
most	O
benchmarks	O
are	O
unreliable	O
and	O
biased	O
.	O
</s>
<s>
In	O
a	O
nutshell	O
,	O
there	O
are	O
inherent	O
inefficiencies	O
and	O
hard	O
limits	O
on	O
optimizing	O
in	O
Java	B-Language
,	O
given	O
that	O
it	O
heavily	O
relies	O
on	O
flexible	O
high-level	O
abstractions	O
,	O
however	O
,	O
the	O
use	O
of	O
a	O
powerful	O
JIT	O
compiler	O
(	O
as	O
in	O
modern	O
JVM	B-Language
implementations	O
)	O
can	O
mitigate	O
some	O
issues	O
.	O
</s>
<s>
In	O
any	O
case	O
,	O
if	O
the	O
inefficiencies	O
of	O
Java	B-Language
are	O
too	O
great	O
,	O
compiled	O
C	B-Language
or	O
C++	B-Language
code	I-Language
can	O
be	O
called	O
from	O
Java	B-Language
via	O
the	O
JNI	B-Language
.	O
</s>
<s>
Some	O
inefficiencies	O
that	O
are	O
inherent	O
to	O
the	O
Java	B-Language
language	I-Language
include	O
,	O
mainly	O
:	O
</s>
<s>
All	O
objects	O
are	O
allocated	O
on	O
the	O
heap	B-General_Concept
.	O
</s>
<s>
Though	O
allocation	O
is	O
extremely	O
fast	O
in	O
modern	O
JVMs	B-Language
using	O
'	O
bump	O
allocation	O
 '	O
,	O
which	O
performs	O
similarly	O
to	O
stack	B-General_Concept
allocation	I-General_Concept
,	O
performance	O
can	O
still	O
be	O
negatively	O
impacted	O
due	O
to	O
the	O
invocation	O
of	O
the	O
garbage	B-General_Concept
collector	I-General_Concept
.	O
</s>
<s>
Modern	O
JIT	O
compilers	O
mitigate	O
this	O
problem	O
to	O
some	O
extent	O
with	O
escape	O
analysis	O
or	O
escape	O
detection	O
to	O
allocate	O
some	O
objects	O
on	O
the	O
stack	B-General_Concept
,	O
since	O
Oracle	B-Application
JDK	O
6	O
.	O
</s>
<s>
Performance-critical	O
projects	O
like	O
efficient	O
database	O
systems	O
and	O
messaging	O
libraries	O
have	O
had	O
to	O
use	O
internal	O
unofficial	O
APIs	B-Application
like	O
sun.misc.Unsafe	O
to	O
gain	O
access	O
to	O
manual	O
resource	O
management	O
and	O
be	O
able	O
to	O
do	O
stack	B-General_Concept
allocation	I-General_Concept
;	O
effectively	O
manipulating	O
pseudo-pointers	O
.	O
</s>
<s>
Guarding	O
each	O
array	O
access	O
with	O
a	O
range	O
check	O
is	O
not	O
efficient	O
,	O
so	O
most	O
JIT	O
compilers	O
will	O
try	O
to	O
eliminate	O
them	O
statically	O
or	O
by	O
moving	O
them	O
out	O
of	O
inner	O
loops	O
(	O
although	O
most	O
native	O
compilers	O
for	O
C++	B-Language
will	O
do	O
the	O
same	O
when	O
range-checks	O
are	O
optionally	O
used	O
)	O
.	O
</s>
<s>
The	O
mandatory	O
use	O
of	O
reference-semantics	O
for	O
all	O
user-defined	O
types	O
in	O
Java	B-Language
can	O
introduce	O
large	O
amounts	O
of	O
superfluous	O
memory	O
indirections	O
(	O
or	O
jumps	O
)	O
(	O
unless	O
elided	O
by	O
the	O
JIT	O
compiler	O
)	O
which	O
can	O
lead	O
to	O
frequent	O
cache	O
misses	O
(	O
a.k.a.	O
</s>
<s>
cache	B-General_Concept
thrashing	I-General_Concept
)	O
.	O
</s>
<s>
Furthermore	O
,	O
cache-optimization	O
,	O
usually	O
via	O
cache-aware	O
or	O
cache-oblivious	B-Application
data	O
structures	O
and	O
algorithms	O
,	O
can	O
often	O
lead	O
to	O
orders	O
of	O
magnitude	O
improvements	O
in	O
performance	O
as	O
well	O
as	O
avoiding	O
time-complexity	O
degeneracy	O
that	O
is	O
characteristic	O
of	O
many	O
cache-pessimizing	O
algorithms	O
,	O
and	O
is	O
therefore	O
one	O
of	O
the	O
most	O
important	O
forms	O
of	O
optimization	O
;	O
reference-semantics	O
,	O
as	O
mandated	O
in	O
Java	B-Language
,	O
makes	O
such	O
optimizations	O
impossible	O
to	O
realize	O
in	O
practice	O
(	O
by	O
neither	O
the	O
programmer	O
nor	O
the	O
JIT	O
compiler	O
)	O
.	O
</s>
<s>
Garbage	B-General_Concept
collection	I-General_Concept
,	O
as	O
this	O
form	O
of	O
automatic	B-General_Concept
memory	I-General_Concept
management	I-General_Concept
introduces	O
memory	O
overhead	O
.	O
</s>
<s>
However	O
,	O
there	O
are	O
a	O
number	O
of	O
benefits	O
to	O
Java	B-Language
's	O
design	O
,	O
some	O
realized	O
,	O
some	O
only	O
theorized	O
:	O
</s>
<s>
Java	B-Language
garbage	B-General_Concept
collection	I-General_Concept
may	O
have	O
better	O
cache	O
coherence	O
than	O
the	O
usual	O
use	O
of	O
malloc/new	O
for	O
memory	B-General_Concept
allocation	I-General_Concept
.	O
</s>
<s>
Nevertheless	O
,	O
arguments	O
exist	O
that	O
both	O
allocators	O
equally	O
fragment	O
the	O
heap	B-General_Concept
and	O
neither	O
exhibits	O
better	O
cache	O
locality	O
.	O
</s>
<s>
However	O
,	O
in	O
C++	B-Language
,	O
allocation	O
of	O
single	O
objects	O
on	O
the	O
heap	B-General_Concept
is	O
rare	O
,	O
and	O
large	O
quantities	O
of	O
single	O
objects	O
are	O
usually	O
allocated	O
in	O
blocks	O
via	O
an	O
STL	O
container	O
and/or	O
with	O
a	O
small	O
object	O
allocator	O
.	O
</s>
<s>
However	O
,	O
most	O
state-of-the-art	O
native	O
(	O
C	B-Language
,	O
C++	B-Language
,	O
etc	O
.	O
)	O
</s>
<s>
Also	O
,	O
the	O
inverse	O
argument	O
can	O
be	O
made	O
that	O
native	O
compilers	O
can	O
better	O
exploit	O
architecture-specific	O
optimizing	O
and	O
instruction	B-General_Concept
sets	I-General_Concept
than	O
multi-platform	B-Operating_System
JVM	B-Language
distributions	O
.	O
</s>
<s>
Run-time	O
compiling	O
allows	O
for	O
more	O
aggressive	O
virtual	B-Application
function	I-Application
inlining	O
than	O
is	O
possible	O
for	O
a	O
static	O
compiler	O
,	O
because	O
the	O
JIT	O
compiler	O
has	O
more	O
information	O
about	O
all	O
possible	O
targets	O
of	O
virtual	O
calls	O
,	O
even	O
if	O
they	O
are	O
in	O
different	O
dynamically	O
loaded	O
modules	O
.	O
</s>
<s>
Currently	O
available	O
JVM	B-Language
implementations	O
have	O
no	O
problem	O
in	O
inlining	O
most	O
of	O
the	O
monomorphic	O
,	O
mostly	O
monomorphic	O
and	O
dimorphic	O
calls	O
,	O
and	O
research	O
is	O
in	O
progress	O
to	O
inline	O
also	O
megamorphic	O
calls	O
,	O
thanks	O
to	O
the	O
recent	O
invoke	O
dynamic	O
enhancements	O
added	O
in	O
Java	B-Language
7	O
.	O
</s>
<s>
Inlining	O
can	O
allow	O
for	O
further	O
optimisations	O
like	O
loop	O
vectorisation	O
or	O
loop	B-Operating_System
unrolling	I-Operating_System
,	O
resulting	O
in	O
a	O
huge	O
overall	O
performance	O
increase	O
.	O
</s>
<s>
In	O
Java	B-Language
,	O
thread	B-Operating_System
synchronizing	O
is	O
built	O
into	O
the	O
language	O
,	O
so	O
the	O
JIT	O
compiler	O
can	O
potentially	O
,	O
via	O
escape	O
analysis	O
,	O
elide	O
locks	O
,	O
significantly	O
improve	O
the	O
performance	O
of	O
naive	O
multi-threaded	B-Operating_System
code	O
.	O
</s>
<s>
Also	O
,	O
some	O
performance	O
problems	O
occur	O
in	O
C++	B-Language
:	O
</s>
<s>
Since	O
the	O
code	O
generated	O
from	O
various	O
instantiations	O
of	O
the	O
same	O
class	O
template	B-Application
in	O
C++	B-Language
is	O
not	O
shared	O
(	O
as	O
with	O
type-erased	O
generics	B-Language
in	I-Language
Java	I-Language
)	O
,	O
excessive	O
use	O
of	O
templates	B-Application
may	O
lead	O
to	O
significant	O
increase	O
of	O
the	O
executable	O
code	O
size	O
(	O
code	O
bloat	O
)	O
.	O
</s>
<s>
However	O
,	O
because	O
function	O
templates	B-Application
are	O
aggressively	O
inlined	O
,	O
they	O
can	O
sometimes	O
reduce	O
code	O
size	O
,	O
but	O
more	O
importantly	O
allow	O
for	O
more	O
aggressive	O
static	O
analysis	O
and	O
code	O
optimizing	O
by	O
the	O
compiler	O
,	O
more	O
often	O
making	O
them	O
more	O
efficient	O
than	O
non-templated	O
code	O
.	O
</s>
<s>
In	O
contrast	O
,	O
Java	B-Language
generics	I-Language
are	O
necessarily	O
less	O
efficient	O
than	O
non-genericized	O
code	O
.	O
</s>
<s>
Because	O
in	O
a	O
traditional	O
C++	B-Language
compiler	O
,	O
dynamic	O
linking	O
is	O
performed	O
after	O
code	O
generating	O
and	O
optimizing	O
in	O
C++	B-Language
,	O
function	O
calls	O
spanning	O
different	O
dynamic	O
modules	O
cannot	O
be	O
inlined	O
.	O
</s>
<s>
However	O
modern	O
C++	B-Language
compilers	O
like	O
MSVC	O
and	O
Clang+LLVM	O
offer	O
link-time-code-generation	O
options	O
that	O
allow	O
modules	O
to	O
be	O
compiled	O
to	O
intermediate	O
formats	O
which	O
allows	O
inlining	O
at	O
the	O
final	B-Language
link	O
stage	O
.	O
</s>
<s>
The	O
C++	B-Language
language	I-Language
is	O
defined	O
by	O
ISO/IEC	O
14882	O
,	O
an	O
ISO	O
standard	O
,	O
which	O
is	O
published	O
by	O
the	O
ISO/IEC	O
JTC1/SC22/WG21	O
committee	O
.	O
</s>
<s>
The	O
latest	O
,	O
post-standardization	O
draft	O
of	O
C++17	B-Language
is	O
available	O
as	O
well	O
.	O
</s>
<s>
The	O
C++	B-Language
language	I-Language
evolves	O
via	O
an	O
open	O
steering	O
committee	O
called	O
the	O
C++	B-Language
Standards	O
Committee	O
.	O
</s>
<s>
The	O
committee	O
is	O
composed	O
of	O
the	O
creator	O
of	O
C++	B-Language
Bjarne	O
Stroustrup	O
,	O
the	O
convener	O
Herb	O
Sutter	O
,	O
and	O
other	O
prominent	O
figures	O
,	O
including	O
many	O
representatives	O
of	O
industries	O
and	O
user-groups	O
(	O
i.e.	O
,	O
the	O
stake-holders	O
)	O
.	O
</s>
<s>
The	O
committee	O
now	O
aims	O
to	O
release	O
a	O
new	B-Language
standard	O
every	O
few	O
years	O
,	O
although	O
in	O
the	O
past	O
strict	O
review	O
processes	O
and	O
discussions	O
have	O
meant	O
longer	O
delays	O
between	O
publication	O
of	O
new	B-Language
standards	O
(	O
1998	O
,	O
2003	O
,	O
and	O
2011	O
)	O
.	O
</s>
<s>
The	O
Java	B-Language
language	I-Language
is	O
defined	O
by	O
the	O
Java	B-Language
Language	I-Language
Specification	I-Language
,	O
a	O
book	O
which	O
is	O
published	O
by	O
Oracle	B-Application
.	O
</s>
<s>
The	O
Java	B-Language
language	I-Language
continuously	O
evolves	O
via	O
a	O
process	O
called	O
the	O
Java	B-Language
Community	I-Language
Process	I-Language
,	O
and	O
the	O
world	O
's	O
programming	O
community	O
is	O
represented	O
by	O
a	O
group	O
of	O
people	O
and	O
organizations	O
-	O
the	O
Java	B-Language
Community	O
members	O
—	O
which	O
is	O
actively	O
engaged	O
into	O
the	O
enhancement	O
of	O
the	O
language	O
,	O
by	O
sending	O
public	O
requests	O
-	O
the	O
Java	B-Language
Specification	I-Language
Requests	I-Language
-	O
which	O
must	O
pass	O
formal	O
and	O
public	O
reviews	O
before	O
they	O
get	O
integrated	O
into	O
the	O
language	O
.	O
</s>
<s>
The	O
lack	O
of	O
a	O
firm	O
standard	O
for	O
Java	B-Language
and	O
the	O
somewhat	O
more	O
volatile	O
nature	O
of	O
its	O
specifications	O
have	O
been	O
a	O
constant	O
source	O
of	O
criticism	O
by	O
stake-holders	O
wanting	O
more	O
stability	O
and	O
conservatism	O
in	O
the	O
addition	O
of	O
new	B-Language
language	O
and	O
library	O
features	O
.	O
</s>
<s>
In	O
contrast	O
,	O
the	O
C++	B-Language
committee	O
also	O
receives	O
constant	O
criticism	O
,	O
for	O
the	O
opposite	O
reason	O
,	O
i.e.	O
,	O
being	O
too	O
strict	O
and	O
conservative	O
,	O
and	O
taking	O
too	O
long	O
to	O
release	O
new	B-Language
versions	O
.	O
</s>
<s>
"	O
C++	B-Language
"	O
is	O
not	O
a	O
trademark	O
of	O
any	O
company	O
or	O
organization	O
and	O
is	O
not	O
owned	O
by	O
any	O
individual	O
.	O
</s>
<s>
"	O
Java	B-Language
"	O
is	O
a	O
trademark	O
of	O
Oracle	B-Application
Corporation	I-Application
.	O
</s>
