Java

From Jonathan Gardner's Tech Wiki
Jump to: navigation, search

Introduction

My notes on Java, the programming language.

First things first

I hate Java with a passion. I hate it more than any other programming language. Not because it is the worst programming language out there, but because it has gotten away for so long being called a great programming language.

I've been documenting reasons why Java sucks. This is based on my first-hand experience as I dove into detail into the guts of Java and wrote thousands of lines of code in it.

My Recommendation: Don't Touch It

My recommendation: Don't use Java for anything, ever, under any circumstances. Java is inappropriate in all environments. It is never, ever appropriate for anything.

Why? It takes too much time to develop the code, the code is too brittle, and it does so little for the work you put into it.

How to Mitigate the Effects of Java

If you end up in a position where you have to write Java, then this is what I recommend:

  1. Publish a book on the "Lisp Design Pattern". Give talks throughout the company to Java dunderheads about the beauty of this design pattern. (Note: You may have to call it something fancy, like "Universal Design Pattern" or "Unified Theory of Design Patterns".)
  2. Implement a Lisp evaluator in Java or borrow one of the existing ones out there.
  3. Write your program in Lisp.


History of Java

I think I can summarize the history of Java, at least my perspective on it.

A long time ago, there was C and C++. And there was Sun Microsystems. Sun was losing money, fast, and they needed a way to stay relevant.

A young programmer who didn't know any better proposed writing a cross-platform language that Microsoft wouldn't hurl nuclear missiles at. If Sun could control the language and the implementation, then perhaps, perhaps, you could actually write a cross-platform language.

The problem was that Sun didn't know how to write programming languages. They got stuck in the implementation details. They forgot, or never learned, that the job of a programmer is to make the lives of the users of their software as easy as possible by solving the hard problems. Hardware guys don't think like this. The job of a hardware developer is to make things possible, and then let the software guys complain and moan about how terrible a solution it is, until they figure out a way to program around all the bad bits.

Anyway, millions and millions of dollars later, they had a turd that stunk to high heaven. It was so bad that even the people at Sun were complaining about its stench. So they shipped it just to get the thing out of their work area. They happened to ship it at the right time when people were looking for the kind of thing Java was supposed to do. But java couldn't do it.

Millions of dollars later, and a massive FUD campaign later, and Java had won the hearts and minds of the managers. Now, it had found its niche: The minds and imaginations of people who can't know any better or who don't care.

A loyal following built up from C++ rejects. "This is great!" they said. "All the chains and shackles of C++, and it's virtualized to boot! What more can we ask for!" And like a group of certain medieval monks, they beat their backs into a bloody mess while chanting, "Object-Oriented Programming is Superior to all. All must bow before it!"

This continued for some time until one day, Design Patterns appeared. For those who do not know what Design Patterns represent, it is the mechanization of programmers. See, in a normal programming language, any task that a programmer can do can be scripted with a smart enough program. Programmers literally program copies of themselves. But in Java, this was not only impossible, but incredibly difficult. So they wrote a book on how to program programmers to do the work their programs should do for them in the first place. Thus, Design Patterns.

Anyway, today Java is rapidly falling out of favor. The religious extremists have found comfort in .NET, complete with tyrannical overlord and empty promises. Those who struggled for years to reach the Zen-like state of a serious programmer discovered Lisp and soon were happily writing Lisp in Lisp-compatible languages like Python and Perl. Some even left to write Lisp in Haskell.

How to Convince Management to Not Adopt Java

I'm still working on this. But the argument can go something like this.

"Here are all the faults of Java. Note the big ones:

  • Java is so bad that you simply can't manage memory with it, making an in-memory cache with Java IMPOSSIBLE. This isn't a problem with other, more modern languages that manage their own memory.
  • Java doesn't have basic features that all modern languages have, such as proper exceptions and functions as a first-class citizen. This makes programming in Java extremely difficult compared to other more functional languages.
  • Java has been a tremendous drag on every project it's been used on. The only other language Java is superior is C++. Even plain old C is more effective to program in than Java.
  • Java is so bad that people write languages on top of it when they are forced to use it. This is the sign of a bad language, not a good one. If the language were any good, people would simply write more Java. But they aren't. They write XML, Jython, Scala, and Clojure. Each of these languages actually are much closer to Lisp than Java, suggesting that Lisp-like languages are more productive.

Finally:

  • If you said, "Build a skyscraper", you'd expect me to use the most modern and cost-efficient methods of doing so, right? Who knows best what those tools are---the architect and engineers, or the management? If you tell me to build a skyscraper and then put additional constraints about how I can build it, such as which technologies I can or can't use, that is going to raise costs.