Some design trade-offs between
efficiency and safety in C++ language can be written as
follows:
- The conflict between writability
and reliability is a common one in language design.
- The pointers of C++ can be
manipulated in a variety of ways, which leads to highly flexible
addressing of data. Because of the potential reliability problems
with pointers, they are not included in java.
In general the pro's and con's can
be written as follows:
C++
- Extension of C with object-oriented
programming, still able to run C code.
- Compatible with C source code,
except for a few corner cases.
- Write once, compile anywhere
(WOCA).
- Allows procedural programming,
functional programming,object-oriented programming, generic
programming, andtemplate metaprogramming. Favors a mix of
paradigms.
- Runs as native executable machine
code for the targetinstruction set(s).
- Provides object types and type
names. Allows reflection through RTTI.
- Has multiple binary compatibility
standards (commonly Microsoft (for MSVC compiler) and Itanium/GNU
(for virtually all other compilers)).
- Optional automated bounds checking
(e.g., the at()method in vector and string containers).
- Supports native unsigned
arithmetic.
- Standardized minimum limits for all
numerical types, but the actual sizes are implementation-defined.
Standardized types are available through the standard
library<cstdint>.
- Pointers, references, and
pass-by-value are supported for all types (primitive or
user-defined).
- Memory management can be done
manually through new / delete, automatically by scope, or by smart
pointers. Supports deterministic destruction of objects. Garbage
collection ABI standardized in C++11, though compilers are not
required to implement garbage collection.
- Resource management can be done
manually or by automatic lifetime-based resource management
(RAII).
- Supports classes, structs
(POD-types), and unions, and can allocate them on the heap or the
stack.
- Allows explicitly overriding types
as well as some implicit narrowing conversions (for compatibility
with C).
- The C++ Standard Library was
designed to have a limited scope and functionality but includes
language support, diagnostics, general utilities, strings, locales,
containers, algorithms, iterators, numerics, input/output, random
number generators, regular expression parsing, threading
facilities, type traits (for static type introspection) and
Standard C Library. The Boost library offers more functionality
including network I/O.
- A rich amount of third-party
libraries exist for GUI and other functionalities like: ACE,
Crypto++, various XMPP Instant Messaging (IM) libraries,[3]
OpenLDAP, Qt, gtkmm.
- Operator overloading for most
operators. Preserving meaning (semantics) is highly
recommended.
- Single and Multiple inheritance of
classes, including virtual inheritance.
- Compile-time templates. Allows for
Turing complete meta-programming.
- Function pointers, function
objects, lambdas (in C++11), and interfaces.
- No standard inline documentation
mechanism. Third-party software (e.g. Doxygen) exists.
- const keyword for defining
immutable variables and member functions that do not change the
object. Const-ness is propagated as a means to enforce, at
compile-time, correctness of the code with respect to mutability of
objects (see const-correctness).
- Supports the goto statement.
- Source code can be written to be
platform-independent (can be compiled for Windows, BSD, Linux, Mac
OS X,Solaris, etc., without modification) and written to take
advantage of platform-specific features. Typically compiled into
native machine code, must be re-compiled for each target
platform.
Thank you.