Java on Linux

[Written July 6, 2024]

Caveat: this is all IIRC.

During my undergraduate stint at university, I realized I could avoid debugging segfaults if I quit using languages that had segfaults, most prominently C and C++.

It was about 2002, and the big hype systems were on Java and XML. Java in particular looked like it was ready for great things: it shipped with GUI components, threads, and a bunch of data structure libraries. (I had not quite learned about the C++ STL yet; Data Structures courses were still about quarrying our own stone and hewing our wheels from them, as the Goddess intended Real Men to do.) From that point in time and experience, it looked like writing in Java would be the best way to create desktop software. One would write on Linux, and it would run on Windows, and even Mac! Right?

There was one serious problem: the JDK/JRE licensing. Linux distributors were not legally permitted redistribute the code, even in unmodified form. To install the JDK, one needed to go to Sun’s terrible web page, pick the only correct option from the confusing array of choices, and then hope their dialup didn’t go down in the next couple of hours. The system could not be used with a download manager. It was long before auto-detecting an OS from the User-Agent and offering the most likely download.

An author of a program in Java was permitted to bundle the JRE only, but of course that would bloat the download by a significant number of megabytes… but the alternative was to ask each and every user to go through the same horrible Java Download Experience.

[Actually, even if the Linux download problem could be solved, it wasn’t clear it would do much for Windows and Mac. One would need to keep track of the Java versions available in all deployments.]

As for alternatives, I didn’t know about the Blackdown JDK yet, and it wasn’t clear if GCJ worked. To run most Java software, one wanted the Sun (later Oracle) JRE. If one somehow developed Java code that ran on alternatives, nobody would know, and 100% of easy-to-find advice would be to “install the Sun JRE.” This was many, many years before OpenJDK happened.

Meanwhile, Sun and Microsoft got into a legal battle, which poisoned the well for some of the F/OSS community. “Don’t use Java. Anyone making the slightest mistake will be bankrupted by their lawyers!” The actual litigation was around “one can’t put Windows-specific stuff into Java™ and still call it Java™.” Microsoft dropped Java on the floor, saying, “if we can’t embrace–extend–extinguish, then what is even the point?” and made C# instead.

Immediately, a split appeared in the F/OSS world between the “C# is the most amazing thing ever! → let’s clone it” team and the “Microsoft will use C# to destroy us! → stop the cloners” team. Even among more pro-C# people, I don’t think anyone liked the idea of Windows Forms as “the GUI” for their Linux apps. Which is how we got GTK#, but that wasn’t a seamless experience on Windows!

Not to mention, Microsoft started iterating on C# and Mono was always behind.

RIP to the “write cross-platform apps on Linux” dream. The splintering of the options (Java vs. C# vs. “no!”) made all of the walls higher.

There wasn’t really anything else in that space. Other major languages, including Perl and Python, were interpreted. If one wanted “machine speed,” the answer was C, so at least there would be an ABI. Nothing else beyond C, C++, Python, and Perl had the ubiquity that would make it a “good default choice” for writing Linux software.

None of them had a great GUI story, either. There was wxWidgets so a program could stand out like a sore thumb on every platform, like Audacity; or developers wrote native GUI code, then sorted out which one to build at compile time. Python and Perl could interface to Tk if the author really liked to look archaic, or they could link up to (once again) platform-specific code.

I didn’t like any of the choices. I wanted to be cross-platform if I could, but I didn’t have the resources to learn Windows/Mac platform-specific stuff. Java was a non-starter due to the licensing issue, and C# looked sufficiently dangerous that I also avoided it.

Everything else appeared to have GUIs bolted onto the side. Even if I wanted to write native code and GTK+ 2 “supported Windows,” I had no clue to build and distribute a Windows program in a usable manner. I didn’t have an idea where to start learning that. My best option in those days would have been to “use Visual Basic.” (But the timing was bad; C# and VB.NET were already out, and VB6 was dead, dead, dead! According to Microsoft, who should know.)

I started developing for the Web instead. It came with a cross-platform GUI, even if it was really limited.

Since then, couple of new languages have come up in the world. There’s Rust, the best hope for replacing C for seriously low-level code like kernels, and there’s Go. They clearly have uses, but neither are particularly suited for GUI desktop software, certainly not in the way Java aimed for.

We also have Electron; people like to hate on Electron apps, but app developers seem happy enough with the tradeoff. Complaints about Electron should perhaps be framed as complaints about the lack of energy given to cross-platform GUI development in general… or as complaints about a Chrome/ium monoculture. Chrome is becoming the new IE6, in terms of “developers who refuse to code for anything else.”

On the other hand… it does have a cross-platform GUI. Which is the Web. Funny, that.

…but if I want to be honest with myself, I don’t know what I would program in any language. I might have all the ‘motivation’ to learn a language or a GUI toolkit, but if there’s nothing to learn it for, nothing can be built. The only complete thing I ever did with GTK was a Pidgin plugin (not yet called Pidgin, so that might have been GTK 1?)

In the pure programming direction, there’s a very small number of Project Euler problems that can be solved before I start wishing for something more practical to work on. Something that isn’t about optimizing code related to prime numbers.

Ironically, I ended up using someone else’s desktop Java software every work day: PHPStorm. On broadband, with the “bundle a huge runtime” story normalized by Electron, it doesn’t even feel particularly bloated anymore.