My father used to pick college courses by teacher, not topic. He said he
could learn more from an outstanding teacher of Chinese architecture than from a
boring teacher of business law. That's how I like to pick my web developer
seminars here in Berlin. This weekend, I took a 3-day weekend seminar workshop
at the Free University taught by Kai Seidler. Kai is an IT graduate, a James
Hetfield look-alike, dresses in black and uses the vi editor like a Swiss army
knife. I religiously enroll in his annual seminars at the Free University, as he
has the rare combination of wide technical competence, a pagan joy for
computers, and a natural and theoretical art of communicating complex topics in
chunks which allows you to both use and understand the topic. Last year it was
Linux, this year Java.
Java in a philosophical nutshell
The Java class this weekend reminded me at times of some of my college
philosophy classes. First, there is the obvious relationship between Plato's
Forms and Java's classes. Just as Plato would say that a bird is an
"instance of the Form Bird", in Java you see a button as an
"instance of the class Button". Further, when you begin to
understand how Java programmers approach the world, you understand that
"everything is an object". Just as 17th and 18th century philosophers
tried to reduce the world down to one thing: the monad, Java programmers
today reduce the world down to one thing: the object. Once everything is
an object, your work is cut out for you: you then need only to define what each
object can do (methods) and when it can do it (events). This is the essence of
object oriented programming.
Advantages of Java
The best object oriented language. If you are looking for a pure
object-oriented language, Java is it. The evolution of Java is basically C to
C++ to Java. C was a very popular language throughout the 70s and 80s to write
large applications. In the late 80s, C++ was created which added object
orientation, but was backward compatible to C and hence not a pure
object-oriented language. Java took the best from C++ and is hence the purest
object-oriented language today. (By the way, JavaScript has nothing to do with
the evolution from C to C++ to Java. JavaScript was simply patterned after Java
and shares its name for marketing reasons).
Simplicity. The core of Java is so simple that you can actually learn
it in a weekend seminar. However, you will then spend the next couple years
learning how to use all the Java classes. This simplicity forces good
programming style. Whereas C++ says, "do what you want, a little object
oriented here, a bit there, I'll translate everything for you", Java's
simplicity requires good object-oriented programming.
Widely used and becoming more popular. Java entered the world in the
mid 90s with lots of hype. This hype died back down in the late 90s as all most
of us saw of Java were a few decorative, slow-loading applets on a web site now
and then. Behind the scenes, however, Java has been positioning itself as the
most robust programming language of choice for large teams of programmers in
large corporations.
Pays well. Statistics show that if you are in the web programming
business to make money, you should develop solid skills in Java. I read on a
newsgroup a couple months ago that as part of a salary package a Java programmer
"demanded a helicopter and got it". You can't believe everything you
read in a news group (!) but this hints that companies who can pay big will pay
for your Java programming skills with handsome sums.
Platform independent. Whereas C and C++ are compiled into the machine
code for a particular computer, Java is compiled into an intermediate code
(B-code) which is then interpreted by each kind of machine. This means that
after you have compiled your java program, it will be able to run on Linux or
Windows, for instance. If you think about it, that is quite an advantage over
other program languages.
Dynamic and distributed. Imagine changing your tire while speeding
down the Interstate at 80 miles an hour! In the world of programming, this is
what Java can do. A Java application actually consists of many compiled
components which then get interpreted at run time, so if you have a running
application and need to update one part of it, you simple recompile that
component, not the whole application. This is the meaning of dynamic. Java is
also distributed in the sense that these components do not have to all reside on
the same machine. A Java application can be composed of 100 components on one
computer and another 100 on other computers scattered throughout the world. The
application is simply the synergy of the various components relating to each
other.
Disadvantages of Java
Java is slow. As advanced as Java sounds, it does have some
"built in disadvantages". First of all, it is slow. Ironically, as the
languages progress on the evolutionary scale from C to C++ to Java, they go
slower each time. One reason for this is that object orientation reduces the
speed. The other is the fact that Java compiles into a B-code which is then
interpreted by the local machine. This interpreting takes time as well.
Garbage collection interferes with real-time accuracy. Java has to run
a process called "garbage collection" which busies the processor at
regular intervals. For this reason, you would not want to write a Java
application which operates a knife on an operating table. If you told the knife
to move left for four seconds and then begin cutting, Java might go into a
garbage collecting routine for .2 seconds which would cause the knife to
actually move left for 4.2 seconds and then begin cutting (!). There are ways to
program around this, of course. And it is not really "garbage" in a
negative sense which Java has to clean up, but more like "hair in a barber
shop" which is a natural part of the process and which has to be cleaned up
regularly.
Limited access to local machine. Because Java can run on all machines
as an interpreted language, it necessarily cannot access various hardware
specific areas of the machine which languages like C and C++ can. For this
reason, it would be easier to write a printer driver in C than in Java.
Learning Java for the long run
Although I learned quite a bit of practical Java this weekend, I don't plan
to incorporate it into my web development projects any time soon. Like XML, it's
too all-encompassing to use immediately. Instead, Java is interesting for me to
consider it "in the wider scope of things". It represents the future
object-oriented-way that objects in our world will be tightly interrelated and
webbed.
For example, in the next five years we will witness an explosion of wireless
devices which will populate our worlds. These physical devices fit nicely into
the philosophy of Java: they are objects. So Java will soon no longer be
confined to organizing and controlling objects which exist on our 2D screens,
but will extend to these real objects which we wear on our clothes, hold in our
hands and place on our kitchen counter tops. In 2010, few mechanical devices
will be produced without an open network architecture which allows them to
intelligently communicate with other devices. For example, a wristwatch (object)
will beep (method) when your dog (object) runs outside the geometrical bounds of
your yard (event). And perhaps your dog's collar (object) will at this time
administer a light electrical shock (method) into your dog (object). Our future
is eerie, but when it comes to this, at least I want to be able to program it.
That's why I"ve started to learn Java now. Thanks Kai!
10/24 Using Tables for Web Site Layout
11/06 Packaging Complexity
More of Edward's diaries