Java is born with some unique and
interesting features that made it most powerful and demanded language of the
times. Following are the features of Java.
a)
Platform-Independent
"Java
compiled file known as .class file can be executed on any OS without bothering
on which platform (OS) the source code was compiled". That is, a Java
source file can be compiled on any OS and executed on the same or any other OS.
This is quiet contradictory to other languages like C/C++ where these languages
should be executed on the same OS where they were compiled earlier. This Java
feature is very unique and is unparalled by any other language from the day
Java came into its existence, the year 1995; a period of 16 years.
Java's Magic
Touch – Bytecode
Bytecode is
a new term to the programming world introduced by Java. The compilation product
of Java source file is a .class file consisting of bytecode. This
bytecode makes Java platform-independent where as the binary code of C/C++
makes C/C++ platform-dependent.
The bytecode
is not an ultimate format that is readily understood by the microprocessor. It
must be converted into binary code format that can be processed by the
microprocessor directly. This conversion is taken care by the JVM. The format
conversion takes some time and thereby Java executes slower. Incase of C/C++,
they contain binary code directly. The slow nature is overcome to some extent
with the introduction of JIT (Just-In-Time) compiler . Following figure gives
the concept.

Java Compiler – Is Platform-Independent?
A compiler
job is to compile the source code into an executable file. An executable file,
as the name indicates, gives output when executed. Every OS comes with its own
set of functions and for every OS operation, the OS makes a function call to do
the job. The functions may relate to the resource management like file system,
memory and thread operations. Every OS comes with its own functions written in
proprietory code. The compiler should thoroughly understand these functions.
For this reason, the compilers are different for different operating systems.
For example, a C/C++ compiler developed for UNIX understands the functions of
UNIX but not that of Windows.
For the
above rule, Java compiler is not an exception. A Java compiler developed and
executed on UNIX does not work on Macintosh etc. That is, Java compiler, like
any other compiler, is platform-dependent. The difference with Java compiler is
it produces a platform-independent executable file known as .class file.
Following figure explains.

Note: The .class file is not really an
executable file because it must be converted in binary code specific to the OS
at execution time.
2. Portable
Portability
for Java comes from its bytecode. A Java .class file, obtained from the
compilation on one platform can be ported or carried, for execution, to a
different platform. The necessity is to have a compatible JVM (specific to the
platform). JDKs are different for different platforms.
3. Simple
and Familiar
The main
motto of Java designers is to take out the language very simple to practice and
develop the code. Many confusing concepts of C++ are simply deleted from Java
and right now Java proved that a language can exist without these concepts.
Following list gives a few concepts not supported by Java but supported by
other object-oriented languages like C++.
1. No
support for pointers.
2. No "goto" keyword. The minus point of "goto" is that you loose the command on control flow of the code and thereby debugging becomes a nightmare.
3. No support for unsigned data types.
4. No operator overloading.
5. No preprocessor directives (# define).
6. No multiple inheritance.
7. No garbage values for unassigned data types.
8. No explicit memory management by the developer. Memory management is taken care implicitly.
9. No structures, no templates and no unions.
2. No "goto" keyword. The minus point of "goto" is that you loose the command on control flow of the code and thereby debugging becomes a nightmare.
3. No support for unsigned data types.
4. No operator overloading.
5. No preprocessor directives (# define).
6. No multiple inheritance.
7. No garbage values for unassigned data types.
8. No explicit memory management by the developer. Memory management is taken care implicitly.
9. No structures, no templates and no unions.
Java looks
as if it is a known language, familiar earlier, as much of the syntax is
borrowed from C/C++. The control structures, functions, arrays and data types
etc. looks the same of C/C++. Even though it is a derivative of C++, Java is
fully an independent language where the execution entity is a class.
4.
Object-Oriented
Encapsulation,
Inheritance and Polymorphism, the three object-oriented principles are duly
supported by Java. Object-oriented methodology aims at reusability of code
written only once earlier. Java supports reusability through composition
and inheritance.
Everything can be viewed as an object;
to achieve this, the Java API includes a plethora of classes like java.lang.Integer (to
treat a primitive data type as an object), java.io.File
(to view an ordinary text file as an object) and java.net.URL (to
convert an IP address of a system into an object) etc. Apart this, Java
supports dynamic
binding and static
binding of methods and object casting etc.
5.
Architecture Neutral
We know
earlier, the Java compiler generates an intermediary bytecode that must be
again converted into binary code at execution time. This binary code conversion
is effected by the JVM. The bytecode is OS architecture neutral. Any OS can
execute the bytecode without bothering its architecture.
6. Robust
Java is a
robust language which avoids many mistakes a programmer can commit at coding
level. First and foremost towards this goal is exception handling
mechanism which takes care of user's mistakes at runtime. Java includes a
strong type checking for objects and data types both at compile time and
runtime. Variables must be assigned before they are used. Array size should not
be given in initialization.
Java comes
with implicit memory management which takes care of many mistakes a programmer
can commit in coding. Java eliminates the memory manipulations functions like
free() or delete() etc.
Java started
its development for Web-based communication. Java is a strong supporter of Web.
Java comes with special programs, Applets and Servlets useful for Internet
(Web) communication. Applets placed on client-side can communicate with
servlets placed on server-side. Applets written in Java can be downloaded from
any Web server and executed on any client system irrespective of OS.
8. Implicit
Memory Management
We know
earlier, one of the striking features of Java is its implicit memory
management. It avoids much of the tedious code of memory management by the
programmer. If a programmer does not manage the memory robustly with utmost
care, as in C/C++, the system may crash sometimes while executing the program.
The programmer is relieved of the usage of destructors and many functions like
malloc(), calloc(), sizeof(), free() and delete() etc.
When Java
software starts, it spawns a garbage collector (gc) thread that takes cares of
the garbage of a process. The objects not required in further process of a
program are treated as garbage. Keeping the memory for unwanted objects is a
wastage. The garbage collector removes these garbage objects while execution is
going on; even without a message or warning to the programmer.
9.
Interpreted
Generally, a
language like C/C++ is compiled or a HTML is parsed or VBScript is interpreted;
but Java is both compiled and interpreted. At compilation stage, the Java source
code is converted into a bytecode file. As bytecode cannot be executed by a
microprocessor, at runtime, the JVM converts the bytecode into binary code.
This platform-specific binary code is executed and generates output. That is,
in Java, from source code to the output, two stages exist – compilation and
interpretation.
10.
Distributed
No language
can parallel Java in networking support. Java supports both LAN programming
(TCP/IP and UDP) and distributed programming. In distributed computing, the
systems in communication are spread across the globe. Again this is of two
types – Internet-based and non internet-based. Java includes sockets and server
sockets to support socket
(LAN) programming (with java.net package), servlets and JSP (with
javax.servlet.http package) for Internet-based programming and RMI/EJB (with
java.rmi and javax.ejb packages) to support distributed non Internet-based
communication. Java wisely knows the utilization of HTTP, SMTP, POP3 and FTP
protocols etc. to communicate between systems.
11.
Multithreaded
For latest
computing techniques, multitasking is a must as in multimedia (animation). Multitasking
is a concept supported by OS. A language can utilize effectively the
multitasking capabilities of an OS. Java too feels its necessity and supports
through its built-in classes from java.lang package. Java supports multitasking
through multithreading.
A single Java process can be divided into multiple threads and each thread can
be given a different task. If one thread's execution stops for some reason, the
microprocessor can be assigned with the task of another thread. This shifting
of threads reduces microprocessor idle time and thereby output is given at an
earliest and looks at the same time.
12. Dynamic
Generally in
coding, one class may require the functionality of another class. At runtime,
JRE can search, hook and load the necessary classes required for the smooth
execution of the program. Do not bother where the files are, may be on your own
local disk or in a server at a far off place, JRE knows well how to play the
game dynamically. Java has got built-in support for many protocols like HTTP
and FTP using which the JRE can download the classes, files and libraries
required for the execution of a program.
13. Secured
Java, with
its good support for distributed technology, comes with many security features
required in programming. Java does not support pointers and thereby avoids
accidental erasures or changes of the values existing in a different location.
Bytecode verifier checks the permissions in between the classes whether they
can access or not. Java includes encryption algorithms that can be used by the
programmer in distributed communication. Applets are not permitted to access
the hard disk files and software.
14. High-Performance
We know
earlier, Java is slower in its execution. To enhance the performance, the
designers took utmost care in designing the API libraries like introducing
StringBuffer in place of String, StringBuilder
in place of StringBuffer, lightweight Swing GUI components in place of AWT
heavyweight components. ArrayList
(methods are not synchronized) can be used for Vector (methods are
synchronized).
DrawBacks
Even though Java is projected as the most demanded language of the times,
but has its own disadvantages. Of course, they are very minor in nature and
need not be considered as drawbacks compared to the advantages it brings
forward. a) Slow performance: The first and foremost drawback everyone accepts is Java's slow speed of execution. Of course it is designed so to get the affect of platform-independent feature. Designers do trying to increase the performance in other aspects like the introduction of JIT (Just-In-Time) compiler.
b) No support for low-level programming: With Java, low-level programming cannot be done as it is intended to be portable across platforms.
c) Poor features in GUI: Java supports GUI controls but with less features. For example, an image cannot be placed on a button. The is overcome with the introduction of
javax.swing
package. Swing controls come with abundant features that are
comparable with any GUI available.d) No control over garbage collection: Garbage collection is one of the built-in features of Java and is entirely managed by JVM. programmer is not given any handles to control the garbage collection to make coding simple. For this reason, Java does not come with
delete(), free(), malloc() and
sizeof()
etc. functions.What Java Can't Do?
Even though Java is termed as a production language where productivity is very high, but still it cannot do certain things. The productivity is possible due to the abundant classes available in Java API that can cater to the very specific needs of the programmer. Java includes a few thousands of classes with JDK 1.5 that takes care of many minute aspects of coding. Even though it is hyped so heavily, but it cannot be used to develop low-level programming. Using Java, a new OS or new protocols or DVD burning software etc. cannot be programmed.
Well explained.You have shared good tutorial on java programming. java vogue is also good java resoource Click Here
ReplyDelete