Monday, October 24, 2011

The Heroes of Java: Cay Horstmann


The fifth part in my Java interview series: "The Heroes of Java".

Cay Horstmann
Cay; Looking a bit surprised about
the photographer he didn't know ;)
Java Leaders Brunch JavaOne 
grew up in Northern Germany and attended the Christian-Albrechts-Universit├Ąt in Kiel, a harbor town at the Baltic sea. He received a M.S. in computer science from Syracuse University, and a Ph.D. in mathematics from the University of Michigan in Ann Arbor. He was VP and CTO of Preview Systems Inc. that went from 3 people in a tiny office to a public company in four years. He now teaches computer science at San Jose State University. Being the author of two of my first ever Java books qualifies him to be among my Java Heroes (beside the fact, that he is a born German :))

General part
Who are you? 
I teach computer science, write college textbooks and professional books, and code as much as I can in my copious spare time. I learned a lot in several startups, both about software engineering and running a business. I was born in Germany but came to the United States as a student, where I witnessed the birth of the personal computer and the internet.

Your offical job title at your company?
Professor?

Do you care about it?
The title, yes, absolutely. When I was an undergraduate in Germany and addressed my professor as "Herr X", he let me know in no uncertain terms that I was to address him as "Herr Professor Doktor X". So I decided I'd be a professor too. Except, here I get emails addressed to "Hey Cay" or "Hello Hortsman".

Do you speak foreign languages? Which ones?
German, a bit of Chinese, and now I am re-learning French.

How long is your daily "bootstrap" process? (Coffee, news, email)
15 - 30 minutes. I try to get some work out of the way early in the morning.

Twitter
You have a twitter handle? Why?
Yes, cayhorstmann, so that nobody else can grab it.

Whom are you following in general?
Nobody.

Do you have a personal "policy" for twitter?
Never, ever to use it. The few times that I did, I regretted it. To me, it's very distracting and the information density is abysmally low.

I like Google+, which is a powerful indicator that it is doomed.

Does your company restricts or encourages you with your twitter ussage?
I am not sure they know what it is.

Work
What's your daily development setup? (OS/IDE/VC/other Tools)
Ten years ago, I switched from Windows ME to Linux, and I never looked back. I am using Ubuntu right now, but not with any of the UI glitz. Just OpenBox.

I use whatever IDE is best for a particular task. NetBeans for Java EE, Eclipse for Android, IntelliJ for Scala, Emacs for simple projects where an IDE would get in the way.

My preferred version control is Mercurial. I find it simple and logical. But if a project uses Git or Subversion, I'll just use that.

I automate lots of processes, so I use a fair amount of bash, and the various Unix power tools (sed, curl, imagemagick, pdftk. Ant with Ivy for build automation, now moving to SBT. (I never could love Maven.)

Which is the tool providing most productivity to your work?
Perhaps surprisingly, it is my XHTML editor. Being a book author, I naturally write a lot, and I also need to make lots and lots of presentation slides. Put me in front of PowerPoint, and it's an endless mousing and clicking and fussing with fonts and alignments, and the simplest tasks seem to take forever. I asked my colleagues who use Word and PowerPoint what they did to crunch out material quickly. Style sheets? Macros? My colleagues stare at me blankly and say it takes them forever too.

That's no good. For slides, I use HTML Slidy. I added a CSS style for "bullets with image to the left", grab an image from the web, and have the image and bullets sized automatically. I just focus on the contents.

When writing about programming, I always need to worry where monospaced code starts and ends. In Word and PowerPoint, this seems to depend on the phases of the moon. In XHTML, it's obvious.

Why not Docbook? It seems too hard, and it restricts the choice of editors. I can do any formatting task that I need with a bit of CSS. If someone else needs Docbook from me, I can convert XHTML to it.

For XHTML editing, I started out with XMLMind, which is a good program. But I prefer open-source tools when possible, and now I use Amaya,

Your prefered way of interacting with co-workers?
A mixture of email, Skype, hallway chat, traditional meetings, and meeting over lunch or dinner. Nobody likes formal meetings, but they can be useful when managed carefully. No Twitter :-)

What's your favorite way of managing your todo's?
Remember the Milk or Emacs Org Mode

If you could make a wish for a job at your favorite company: What would that be?
I always envied Gilad Bracha's position as chief theologian at Sun, but of course he knows so much more about programming languages than I ever will that I'd probably just embarrass myself if I had such a job.

Java
You're programming in Java. Why?
I used to program in C and C++, and when Java came along, I thought "No garbage collection? cross-platform libraries that actually do stuff (i.e. GUIs, database)? Where do I sign?"

That was in 1996. It's hard to remember how far ahead of its time Java was of its commercial rivals.

Then Java became open-sourced, which it means that it will live forever once those wretched patents expire.

To make me move off the JVM, you'd have to offer me an open-source cross-platform alternative with more/better libraries than in the Java universe. Let me know if you find one.

As for the Java language, I use Scala for new projects when I can. It's more fun. What's important is that it runs on the JVM and interoperates with Java libraries.

What's least fun with Java?
The "stack trace from hell" in Java EE.

If you could change one thing with Java, what would that be?
Properties

What's your personal favorite in dynamic languages?
(This space intentionally left blank.)

Which programming technique has moved you forwards most and why?
I'd like to say "functional programming" because it is fun to build very generic and reusable mechanisms, but the truth is much more boring.

1) Strong typing.
In the bad old days of pre-ANSI C, I wasted an enormous amount of time with runtime errors. You could call fread with the parameters in the wrong order, and it compiled, ran, and flaked out. If you were lucky, you got a core dump. C++ changed my life. It took forever to shut up the compiler, but when a program ran, it actually had a fair chance of doing the right thing. My productivity multiplied.

2) VM bounds checks and garbage collection.
In the bad old days of C and C++, I wasted an enormous amount of time with memory allocation bugs. In Java, all that went away in an instant. My productivity multiplied.

I am lucky to have had this effect twice in my lifetime. Note that it came from changing from "really bad" to "ok", not from "good" to "great".

Where could similar improvements come from in the future? Here are a few suggestions.
- Get rid of the stack trace from hell
- Get rid of callbacks/event driven programming in client-side UIs and web apps
- Make concurrency less painful

What was the biggest project you've ever worked on?
A scientific word processor for DOS that I wrote as a graduate student--about 120K LOC of C code.

Which was the worst programming mistake you did?
To follow the official specifications when trying to port that word processor to Windows. I should have reverse engineered Word to find the undocumented OS calls that were necessary to get continuous line breaking at an acceptable speed. That mistake taught me something about the value of open specifications and open source.