Why Java Sucks – Jonathan Gardner
Are we using the same Java?<p>&gt; GC Sucks So Badly, That You Should Avoid Using Memory<p>I&#x27;m assuming this is from before Java 8. The latest GC algorithms don&#x27;t do this.<p>&gt; Worst of Exceptions and Value Checking<p>Sometimes the correct thing to do is to throw an exception and other times it is to return a sensable value. An exception is an unrecoverable state, a null is a sensable value for when nothing exists. Something not existing and an unrecoverable state are two very different things.<p>&gt; Won&#x27;t cast an int to a long<p>Again, are we using the same language? This works. see code example at the end.<p>&gt; name clash: X and Y have the same erasure<p>This is not sensable behavior but entierly avoidable. Objects contain data and then process them, then return the processed data to another object. The Java way of doing this is to pass &quot;List&lt;Long&gt; listOfLongs&quot; and &quot;List&lt;String&gt; listOfStrings&quot; to the constructor of foo and to have funcLong() and funcString().<p>&gt; incompatible types<p>I&#x27;ve never seen this but I also suspect that this isn&#x27;t an issue as I&#x27;ve never run into it and I&#x27;ve had interfaces in interfaces.<p>&gt; static methods and members in a class<p>Static means the meaning of the method or object never changes. It will mean the same thing in every instance of usage. As such this makes sense. You never need to override a constant meaning as it will always mean the same thing.<p>&gt; The &quot;class&quot; type is an afterthought<p>What does he mean by this?<p>&gt; No control on member access<p>Use lombok. Not an issue and is fixed at compile time, not runtime.<p>&gt; RSI<p>This makes no sense. An IDE is a tool that Java is deisgned to make use of. Locking yourself in your cave and saying it&#x27;s bad isn&#x27;t going to pursuade anyone.<p>&gt; Camel Case<p>Nameing conventions aren&#x27;t a reason a language is bad.<p>&gt; Class-centric<p>That is the idea behind Java. The other concenrns not addressed by the title have been fixed by the Java 8 additions allowing you to treat one-method interfaces in Java 8.<p>&gt; Iterators SUCK!<p>That is an implementation but it&#x27;s fairly standard to just have tihs backed by some form of collection and see if there is data left in it. I usually use an index in an array and see if I have run past the end of the array.<p>&gt; foreach doesn&#x27;t take iterators<p>Yea this is crap.<p>&gt; Function Pointers -- Missing<p>Java 8<p>&gt; Constructors can&#x27;t call each other<p>Again see the code at the end.<p>&gt; Methods With the Same Name as Constructors<p>Yea that&#x27;s allowed, I don&#x27;t see what&#x27;s wrong with that. It&#x27;s a real function name so it should be allowed. I&#x27;ve never accidently made this error.<p>&gt; Run-time Dispatch: Fantasy<p>This is a design pattern issue but you&#x27;re meant to use the highest or lowest version of an abstraction. From there you can ideally handle it in a generic way or if not you can use if (x instanceof Object) to filter out specific cases.<p>&gt; No Globals means Frameworks<p>This is where decorators and static&#x2F;singleton classes come in handy. You can do some amazing things with decorators, singleton&#x2F;static classes, and if you need it a bit of reflection.<p>&gt; import is Useless<p>You can just use the fully-qualified name of the other class and it will work fine. I&#x27;ve had maybe one instance where my naming conflicted with another package but that was a rare case.<p>&gt; No List Literals<p>Arrays.asList<p>&gt; Inner classes Don&#x27;t Work<p>I don&#x27;t know what he means as this works perfectly fine for some design patterns. Inherit state? No way. Provide impelemntations of an abstract&#x2F;interface for a specific object? Yes way.<p>In ArrayList it is perfectly fine to make an ArrayListIterator as they are the same bits of ideas and as such should be in the same file.<p>I also prefer state enums to be defined in a class.<p>&gt; Java is So Hard People Prefer to Write Code in XML, Jython, Scala, and Clojure<p>I don&#x27;t do this only &quot;&quot;&quot;ENTERPRISE&quot;&quot;&quot; Java developers do this. There&#x27;s a lot of great work being done moving away from this mentality but there is still a lot to be done.<p>&gt; Speaking of the JVM...<p>I&#x27;d love some numbers on these claims.<p>&gt; DNS Client Implementation<p>Yea this is a problem. It&#x27;s in here for compatability. There are many libraries implementing this better at the moment.<p>&gt; Sun Microsystems May Sue You<p>I don&#x27;t know if this applies to OpenJDK.<p>&gt; Why Use Java at All?<p>Why use any language at all? Write binary and opcodes (like I&#x27;ve been doing in my CPU project). It&#x27;s very fun!<p>In seriousness Java gets concurency right and I&#x27;ve not found another language that lets me write concurrent code like this ever before. Very nice platform to run on and one of the worlds best VMs. Everything is simple and documented well. I don&#x27;t need to read a novel to get something working. I can think of a class, type that a control-space on my IDE, get a list of classes, find the one in the right package and move on. No google, no searching, just tooling and built in documentation. What&#x27;s even better is most of the language is implemented in Java! I have the sources downloaded so CNTRL+Click and I can see everything&#x27;s implementation! I&#x27;d love to see a python dev do that (I cant and I&#x27;ve been writing python for years).<p>I&#x27;ll be emailing the author at this email: jgardner @ XXX .net and giving him this comment. I hope he can rebute some of these points.<p><pre><code>   class Test {
   	private final int i;
   	public Test(int i) {
   		this.i = i;
   		this.test(i);
   	}
   	public Test() {
   		this(10);
   	}
   
   	private void test(long number) {}
   }</code></pre>