Java review
Java is the well known programming language created and
delivered by Sun Microsystems. Its main feature is an extrem
portability. Any Java compiled code will run everywhere a Java
virtual machine is available : "write once, run every where".
The success came quite quickly. Internet and the new need of
running some code anywhere is one of the reason. The second
is that Java appears to be a simple subset of C++ language
easy to learn for all C/C++ users.
The real benefits of Java
Binary portability ?
Is binary portability so important ? Its cost is so
high : it needs the Java Virtual Machine. A big and complex
software that is not a very simple abstract machine and no
more a complete virtual computer... It is something hard
to define between a virtual RISC processor and a complete
POSIX system (think about this idea : POSIX, a full
featured virtual system). POSIX, ANSI, ISO C/C++ softwares
can run everywhere. The GNU/Linux system I use is the best
exemple : full and efficient portability can rely only upon
source portability. Last, why not a virtual machine designed
to let any standard C/C++ (may be any language) program run ?
It exists !
The only area where binary portability is really usefull
is internet applets. Those little softwares runnable directly
from your browser handled thrue a simple HTML page are a
wonderfull tool. But Java fails where Macromedia Flash succeed.
I'm sorry to observe that today's web users just want some nice
animations, shiny colors and new stranges widgets. So what can
do Java in this Macromedia and Microsoft's web version ?
Let's think about applet's need ? why forwading thrue the
net heavy and slow-run byte-code and ? There is no need of
binary portability for
applets. An XML based programming language may be a wonderfull
tool to achieve such a feature (JavaScript could be a good start
point and nowadays it seems hard to create norms and standards
whithout XML inside).
Fun java things
IMO, you may have already understand it, binary
portability is not the greatest feature of Java. But don't
guess about my mind. I like Java. It is so rich and versatil
to get RAD realy possible even without any full featured IDE.
The Java Standard API is exptremly powerfull, complete
and standard (standardization will be perfect when sun
accepts letting ISO doing its job !). All what you need is
provided inside the SDK : network, threads, multimedia,
graphic toolkit, database interface, distibuted objects
support...
All this complete set of tools is designed the same
way, using the same design paterns concepts : Factories,
observers, interfaces.
And last, the MAIN java feature : memory management.
No more pointer, objects are dynamicaly allocated and
automaticaly deleted.
Java lacks
Java is not really portable everywhere. It is portable
only where a Java virtual machine is available. Since Java
is not completely free, it is not possible to port the JVM
to a new plateform if Sun does'nt agree. The JVM is a big
fat environment. It needs a lot of memory to run. So it
is not efficient on minimalistic embeded systems (Sun's
plans for a java chip was a solution, but we are still
waiting for such a low cost devices).
The design is good but sometimes too simplistic.
Sometimes, I wonder what Sun thinks about developers :
stupid people ? I hope all limitations introduced by
the Java specification are the best solution found
to keep the Java Virtual Machine robust and efficient.
The well known limitation is multiple inheritence.
Interface is often shown as an alternative. Its not
a alternative it's the good way to think. But interface
were perfect with some add-ons :
- static properties as good support of default
values
- "methods template" : possibility to let
programmer implement methods inside interface.
This kind of implementation should use only its
own methods :
Interface Exemple {
public void init();
public boolean finished();
public void process();
public void fullJob() {
init();
while (!finished()) {
process();
}
}
}
Actually a method like fullJob needs to be copied and
pasted to each Interface implementation unless one
inherits from another.
And think about all little constaints present across
the API like the deprecated Thread.stop() method, no
operator overload...