Issue #24: Java

Write Anywhere, Run Once

Back in the days when I had a day job in the .NET galaxy, I had a colleague who was a terrific C# developer… born in the island of Java. Given the looks I got from him, I think I was the first to point this irony fact to him. Or maybe I just pissed him off. In any case, here go some personal anecdotes around Java, stretching back 23 years.

First Java Applet

I have a folder in a backup disk somewhere. I find this folder every time I search for something else, which is how searching for stuff works. The files inside are dated “September 1997.” They have the *.java and *.class extensions, and all together can bring a small calculator to life. I usually write a calculator as a first app with the languages I learn, and this one was no exception.

Every time I used to find that folder I would launch the calculator with the appletviewer command. My applet, that could barely perform the four basic arithmetic operations, would invariably just run like the first day.

I compiled this applet on my PC with IBM’s Applet Development Kit for Windows 3.1. And 20 years later, the same binaries were running unchanged in a MacBook with Java 8. The calculator was based on the Abstract Window Toolkit, a pre-Swing UI framework that was simple and effective, and better yet, had a native look & feel in all platforms. The code was a mess of static methods and global variables, but it just worked™®©.

But Java applets were deprecated in Java 9, and completely removed from Java SE 11. And now I cannot run my calculator applet anymore, although I understand that one can still run them in Internet Explorer 11. Which makes me wonder how many intranets out there might still require Internet Explorer 11 with Java applet support.

Visual J++

There was once a programming environment made by Microsoft called Visual J++. It allowed one to write, debug, and run Java code on Windows. Visual J++ was the first serious, usable, complete IDE Java ever had, at least until IntelliJ IDEA appeared in 2001.

Visual J++ had a faster compiler, and the generated bytecode was much faster than what the official Java SDK for Windows produced. You could also access functionality inside of packages starting with the microsoft.* name, but of course that kind of broke the whole point of Java, which was to make cross-platform stuff that you could write once and run anywhere. So Sun got fed up and sued Microsoft, who a few years later gave Sun some cash and threw Visual J++ away.

Microsoft eventually came up with C# and .NET. These were respectively still very much like Java (the language) and Java (the virtual machine.) Both C# and Java had eerily similar “Hello, World!” implementations, even though C# used PascalCase instead of camelCase. Anders Hejlsberg, the creator of C#, had a long tradition with Pascal, having created Turbo Pascal and Delphi. Later on he went to Microsoft to produce Visual J++, C#, and lately TypeScript. The choice of PascalCase in C# is pervasive; not only classes start with uppercase, but also methods and whatnot. Oh, and the position of the opening curly bracket was the second major difference between them.

I actually used Visual J++ in my job once. Back in 1998, we needed to create a component to find out the width and height in pixels of the images that people were uploading to our ASP website running on IIS and Windows NT 4.0. See, our website allowed users to post messages, and those messages could have up to four pictures attached to them, so we wanted to know many things. First, are they actually uploading images, or are those zip archives, or Word files loaded with viruses? And then, what are the proportions of the image, so that the (pre-CSS) layout of our HTML looks good?

We needed to read two specific small integers (width and height) out of every image uploaded to the site. We did not find any COM component in the market to help us, so in August 1998 I tackled what was, until then, the most complex challenge I had ever had in programming. Design and code a component which, once fed a stream of bytes, would tell us whether the file was a GIF or a JPEG and, if that was the case, the screen size of the image contained therein.

For GIF files this is trivial, as the information is always in the same location in the file; for JPEG, it was a bit more complicated. So I asked for help in comp.graphics.algorithms (this was 11 years before Stack Overflow, after all) and with some trial and error, found out how to traverse a JPEG file to find those two integers. Lo and behold, I found out I had a copy of Visual J++ pre-installed in my work computer, so I used it. We later rewrote that in Visual Basic, I guess because we did not quite figure out how to make a COM component out of that Visual J++ project. Maybe it was not possible, I do not remember why.

After the release of .NET, Microsoft introduced a successor of Visual J++ (they never get tired huh) called J#, which compiled Java code into .NET (CLR) bytecode, but then again, it was discontinued a few years later.

Backslash

Fifteen years ago, Bruce Tate published “Beyond Java.” This title was the reaction against what seemed as a chokehold of Java and the JVM on the server side of the software development industry. Proposing alternatives such as Python, Smalltalk or Ruby, it remains as the book that spoke the zeitgeist of its era: the mid-2000’s were not a good time for Java.

The company I worked for back in 2006 was busy rewriting their flagship app (written in C++) into Java. The project had been going on since 2005, and when I left in 2007, they still had not produced a single working screen to show to their customers or upper management. To consider that this failure was due to the choice of the programming language is not fair, given that such an enterprise is, in general, a strategic mistake; actually, there were many other problems in that organization. But as a younger developer I misplaced my anger into the language, and thus push it aside, vowing never to use it if I could.

I suppose another factor that played against Java in those times was the rise of the Agile Manifesto. Used to very fast write-debug-release cycles with VBScript and ASP in 1997, having to restart Tomcat after every modification of a JSP page made the whole Java developer experience an abysmally horrid one.

I found a large echo in the industry for my distaste of Java. Just to illustrate the backslash against Java, even a popular website such as TheServerSide.com decided to spin TheServerSide.net up, mostly (I guess) as a way to prevent the clash of matter and antimatter and the outburst of vitriol in the comments section of every article.

More or less at the same time, many Java developers started to use anything but Java (the language) in their Java (the virtual machine) applications: there came Clojure for functional programming purists, Scala for scalable backend services, JRuby, JavaScript or Jython for scripting, Groovy for build systems, and more: Smalltalk, BASIC, ColdFusion, Pascal, Ballerina… You can even run PHP inside the JVM if you really want, using a plugin called Quercus.

Then Android came up, and as a way to bring all those J2ME developers into the party, they chose Java (the programming language.) Clever enough, the original team decided not to use Java (the virtual machine), but to rewrite it, to make those mobile apps faster and snappier in smaller and cheaper devices. By that time Sun was swallowed by Oracle, and Oracle’s lawyers had enough spare cash to sue Google about this. Last time I checked they were still yelling at each other.

Looking back in time, the biggest problem of developing early apps for Android was not Java per se; in the opinion of this author, it was Eclipse. Thankfully Google decided to ask somebody else for help and thus Android Studio was born in 2014. Three years later Kotlin came along, and these days nobody notices that Java (the virtual machine) is somehow at the heart of those 2.5 billion smartphones out there. What mobile developers did notice was that, thanks to the decline in quality of Apple’s Xcode, writing an Android application in 2018 had become a much more enjoyable experience than writing an iOS one. And Kotlin, a lightweight and modern language for Java (the virtual machine) coming from the same folks that made Android Studio, is not a small part of that success.

The fact that Java (the virtual machine, in its various forms) ended up being more popular than Java (the language) most probably make Steve Yegge, Joel Spolsky, and Paul Graham nod in approval (or dismay.)

JavaOps

In spite of all the backslash, Java seems to be back in popularity these days. It’s like a small renaissance of the language, somehow, happening right now in front of our eyes.

Java SE 14 was released in March, bringing many features expected by developers.

Thanks to Quarkus (not to mix with Quercus, mentioned previously) developers can deploy lightweight Java services on a Kubernetes clusters, with exactly the “write-debug-release” developer experience I expected back in 2006.

Conferences like QCon, Devoxx, and GOTO all feature Java-related tracks, not to mention Oracle’s Code One, JAX, or jconf.dev, entirely dedicated to the Java ecosystem.

Kevin Henney just compiled “97 Things Every Java Programmer Should Know” in a new book. Joshua Bloch recently published the 3rd edition of his classic, and there are many, many more books published every year about the language and its uses.

For those who miss J# there is IKVM, an implementation of Java (the virtual machine) that runs in the .NET and Mono implementations of the CLR. Or if you prefer, JLang extends the Polyglot compiler to translate Java into LLVM IR.

For what it is worth, Java remains an uncannily popular language, holding the second position (at the time of this writing) in all TIOBE, RedMonk, and PYPL rankings.

Ironically enough, Microsoft publishes one of the most downloaded extension packs for Visual Studio Code, the Java Extension Pack. Maybe it is a redemption, now that .NET has become an actual cross-platform thing.

And in spite of all this buzz, the official Java website remains faithful to its origins in 1995, a Geocities-era looking, corporate-born contraption.

Cover photo by Caspar Camille Rubin on Unsplash.

Adrian Kosmaczewski is a software consultant and evangelist. He is a published writer, trainer and speaker. He holds a Master's degree from the University of Liverpool.