Articles Index
Dave Brown on Servers and Multithreading
John Papageorge
Former JavaSoft programmer Dave Brown has never regretted going crazy over
Java during the summer of 1995. One night a friend turned him on to the
Java web site. "I downloaded the browser and immediately started writing
my own applet," he says, proudly. "I was hooked, and that winter I came
out to work for Sun."
Brown's work at JavaSoft focused on two classes in the JDK package:
java.net and java.io. What's the difference between the two sets? Brown
explains; java.net is reading and writing to other computers on the network.
It will allow you to read URLs from the WWW. The I/O classes deal with reading
and writing files from a local disk," Brown continues. "You read files such as
word-processing documents from
your computer, workstation, or Mac. If you wrote a word-processing application in
Java, it would look at documents from the local disk and store it to the
local disk."
For those new to the term "class," Brown explains it better than
anyone in the business: "Java is an object-oriented language. Every object
has a type. The type of an object is its class. A class is a description
of what constitutes that object and what you can ask it to do. Different
classes represent different things in programming."
And that's that.
If Brown seems well-versed in the art of programming--it's not
surprising, the boy genius got his graduate degree from Columbia. What
inspires him? "Knowing that the software I write is used by more
people than I could probably count," he says.
JDC: What's the class structure comparison between the JDK and other Java
products?
DB: I think JDK is unparalleled. There's no reasonable competition. As
far as a cross-platform set of libraries, it's more comprehensive than any
other class library that you could purchase anywhere.
JDC: What's the best part of this new and improved Java class structure?
DB: Java's new class structure has runtime type checking. When you're
programming, Java interpreters will recognize if it's the wrong type.
JDC: What's the strategy behind the class project?
DB: The most important goal is to ensure that the APIs work robustly.
The second goal is to make sure that they work the same on each program.
JDC: What is the coolest thing about Java?
DB: Networking the APIs of Java, and how simply and compactly you can
make computers talk to each other by programming in Java. What does that
mean? Most networking applications can be done in Java with the fraction of
what it would take to do it in C, primarily because it's so much easier to
understand and faster to develop. It has cross-platform portability, and
it's simply the programming language for the Internet.
JDC: How important is Java and its class structure?
DB: The development of ubiquitous computer networks is a huge
development in computer science in general. Being able to extract
information from millions of computers across the world is incredibly
powerful. The fact that Java is written once and runs on all of these
computer platforms is also powerful.
JDC: What does Java mean to Microsoft?
DB: Windows 95 is the most ubiquitous operating system out there. But
Java, because it's so nice to program in, and because it runs on all platforms, means
that Microsoft's stranglehold on the market might begin to deteriorate.
Java is simply a nicer language to program in, and that means people won't
be developing in Microsoft Foundation Classes.
JDC: What does Java mean to Macintosh?
DB: When Macintosh gets Java working on it, it should give them new
life--I would hope. When the new Java programs come on the market--if they
run well on the Macintosh--people will have the impetus to buy a Mac.
JDC: What's a mistake beginner programmers should avoid at all costs,
especially when working in class structure?
DB: One thing to avoid is to begin writing a program without clearly
establishing a design for what you want to do. It means more work and
revision later. Planning and designing are most of the development
process. I would advise not to forgo a design in haste.
JDC: What's a mistake programmers need to make to get better?
DB: My advice is not unique to Java. To do anything well and
efficiently in life, it's best to have things planned out with a clear goal
in mind. That was one mistake I learned. When you start implementing
something without planning it out or designing it well, you have to redo it.
That's a painful process.
JDC: What's the best resource for Java programmers?
DB: A computer in a quiet place without distraction, and a copy of
JavaSoft's JDK. Enthusiasm and patience are also vital.
JDC: What's the future of Java?
DB: The future of Java is Java developers. Java already has a
tremendous amount of momentum. The more people who use it, the more
important it becomes. I can't imagine writing software in anything other
than Java; it's nothing short of a revolution in software development.
The continued effort to augment and fix JDK's convenient building blocks
will be critical to Java's continued success.
JDC: What's your specialty?
DB: Working on the networking stuff and on the guts of the virtual
machine. The Java interpreter is the virtual machine, and it interprets
Java code into bit code.
JDC: What's your most cherished programming tip?
DB: Java is a multithreaded programming language. And one of the
primary primitives for synchronizing different threads in a program is the
synchronized keyword. And by making a Java method synchronized, one thread
can execute the method at any given time.
But the mistake I've seen is overusing synchronized,
instead of leaving things unsynchronized. In a typical program, only a
small fraction, if any, of the methods need to be synchronized and by
gratuitously doing it, you create problems. You slow down your program.
You also make it more error-prone by opening up the possibility that two
threads are trying to enter and then neither one can proceed. In short,
use synchronized only when needed.
JDC: What are some interesting Java developments or particularly great uses
of Java?
DB: WebCrawler uses Java to index a whole collection of web sites. When
you point to a page on the World Wide Web, it finds the links that page
points to, stores information, and follows those links. It's easy to
program something like this in Java. Another neat Java development is the
Java Operating System; its advent proves that Java is a general-purpose
programming language, and you can do a lot more than write applets with it.
A Simple, Multithreaded
Web Server