What are the things C++ can do and Java cannot?

Answer by Sergey Zubkov:

C++ can swap variables a and b with a function call, such as swap(a, b)

it can place objects on the stack, in memory pools, shared memory areas, etc

can transform types at compile time, choose different code paths for unrelated types with different properties, call static member functions of type parameters and construct their instances (Scala was able to hack some of that onto JVM, actually)

compile-time execution of arbitrary functions (given compile-time inputs)

transforming expressions (on vectors or other complex types) into syntax trees at compile time, to vectorize and execute lazily

single-step initialization and guaranteed class invariants

guaranteed destruction and object lifetime control

Strategy pattern implemented at the type system level

not to mention value semantics, operator overloading, multiple inheritance, and many other features that Java doesn't have, either by design, or as consequence of its design.

What are the things C++ can do and Java cannot?


Leave a comment

Filed under Life

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s