Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
60 views

C++ and Java

C++ supports both procedural and object-oriented programming, allows direct calls to native libraries, and exposes low-level system features. It has multiple binary standards and optional bounds checking. Java encourages object-oriented programming, uses automatic garbage collection, and has standardized primitive types and limits. The Java standard library is large and includes support for many domains, while C++ libraries are more limited in scope.

Uploaded by

saini_mohit45
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

C++ and Java

C++ supports both procedural and object-oriented programming, allows direct calls to native libraries, and exposes low-level system features. It has multiple binary standards and optional bounds checking. Java encourages object-oriented programming, uses automatic garbage collection, and has standardized primitive types and limits. The Java standard library is large and includes support for many domains, while C++ libraries are more limited in scope.

Uploaded by

saini_mohit45
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

C++ Java

No backward compatibility with any previous


Compatible with C source code, except for a
language. The syntax is however strongly
few corner cases.
influenced by C/C++.
Write once run anywhere / everywhere
Write once compile anywhere (WOCA)
(WORA / WORE)
Allows both procedural programming and Encourages an object oriented programming
object-oriented programming. paradigm.
Call through the Java Native Interface and
Allows direct calls to native system libraries.
recently Java Native Access
Exposes low-level system facilities. Runs in a protected virtual machine.
Is reflective, allowing metaprogramming and
Only provides object types and type names.
dynamic code generation at runtime.
Has multiple binary compatibility standards Has a binary compatibility standard, allowing
(commonly Microsoft and Itanium/GNU) runtime check of correctness of libraries.
Optional automated bounds checking. (e.g. the Normally performs bounds checking. HotSpot
at() method in vector and string containers) can remove bounds checking.
Supports native unsigned arithmetic. No native support for unsigned arithmetic.
Standardized minimum limits for all numerical
types, but the actual sizes are implementation- Standardized limits and sizes of all primitive
defined. Standardized types are available as types on all platforms.
typedefs (uint8_t, ..., uintptr_t).
Primitive data types always passed by value.
Pointers, References, and pass by value are Objects are passed by nullable reference
supported (comparable to using pointers for all class or
struct parameters in C++).[1]
Automatic garbage collection (can be triggered
Explicit memory management, though third
manually). Doesn't have the concept of
party frameworks exist to provide garbage
Destructor and usage of finalize() is not
collection. Supports destructors.
recommended.
Supports only class and allocates them on the
Supports class, struct, and union and can
heap. Java SE 6 optimizes with escape analysis
allocate them on heap or stack
to allocate some objects on the stack.
Rigid type safety except for widening
Allows explicitly overriding types. conversions. Autoboxing/Unboxing added in
Java 1.5.
The C++ Standard Library has a much more The standard library has grown with each
limited scope and functionality than the Java release. By version 1.6 the library included
standard library but includes: Language support, support for locales, logging, containers and
Diagnostics, General Utilities, Strings, Locales, iterators, algorithms, GUI programming (but not
Containers, Algorithms, Iterators, Numerics, using the system GUI), graphics, multi-
Input/Output and Standard C Library. The Boost threading, networking, platform security,
library offers much more functionality including introspection, dynamic class loading, blocking
threads and network I/O. Users must choose and non-blocking I/O, and provided interfaces
from a plethora of (mostly mutually or support classes for XML, XSLT, MIDI,
database connectivity, naming services (e.g.
LDAP), cryptography, security services (e.g.
incompatible) third-party libraries for GUI and
Kerberos), print services, and web services.
other functionality.
SWT offers an abstraction for platform specific
GUIs.
The meaning of operators is generally
Operator overloading for most operators immutable, however the + and += operators
have been overloaded for Strings.
Full multiple inheritance, including virtual Single inheritance only from classes, multiple
inheritance. from interfaces.
Generics are used to achieve an analogous effect
to C++ templates, however they do not translate
Compile time Templates
from source code to byte code due to the use of
Type Erasure by the compiler.
No function pointer mechanism. Instead idioms
Function pointers, function objects, lambdas (in
such as Interfaces, Adapters and Listeners are
C++0x) and interfaces
extensively used.
No standard inline documentation mechanism.
Javadoc standard documentation
3rd party software (e.g. Doxygen) exists.
final provides a limited version of const,
const keyword for defining immutable equivalent to type* const pointers for objects
variables and member functions that do not and plain const of primitive types only. No
change the object. const member functions, nor any equivalent to
const type* pointers.
Supports the goto statement. Supports labels with loops and statement blocks.
Source code can be written to be platform
independent (can be compiled for Windows, Is compiled into byte code for the JVM. Is
BSD, Linux, Mac OS X, Solaris etc. without dependent on the Java platform but the source
needing modification) and written to take code is typically written not to be dependent on
advantage of platform specific features. Is operating system specific features.
typically compiled into native machine code.

C++ is a powerful language designed for system programming. The Java language was designed
to be simple and easy to learn with a powerful cross-platform library. The Java standard library
is considerably large for a standard library. However, Java does not always provide full access to
the features and performance of the platform that the software runs on. The C++ standard
libraries are simple and robust providing containers and associative array

You might also like