Java is a general-purpose computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible. It is intended to let application developers “write once, run anywhere” (WORA), meaning that compiled Java code can run on all platforms that support Java without the need for recompilation. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of computer architecture. As of 2015, Java is one of the most popular programming languages in use, particularly for client-server web applications, with a reported 9 million developers. Java was originally developed by James Gosling at Sun Microsystems (which has since been acquired by Oracle Corporation) and released in 1995 as a core component of Sun Microsystems’ Java platform.
Or whatever. That’s what Wikipedia says. We all know how much Java sucks. Let’s list down a few of the reasons I personally hate java. Some of this reasons might have been fixed by the latest releases in Java. I stopped caring some time ago so I did not notice that they were fixed. But after so long, it’s a bit late. So. here goes:
- Java has unused keywords, such as goto and const. Keywords that are locked and we cannot use, but Java does not use them either.
- There are no delegates like C# or function pointers like C/C++. You need something like that? Why would Java care? It’s your problem.
- There’s int types and Integer objects, float types and Float objects. So you can have efficient data types, or object-oriented data types. Not confusing at all.
- There’s no operator overloading… except for strings. So for pseudo-numeric classes, like BigInteger, you have to do things like
which is really ugly.
- Catch clauses can contain only one exception, causing a programmer to rewrite the same code N times if he/she wants to react the same way to N different exceptions.
- The return statement is not valid within initialization blocks.
- No var-Keyword for infering local types (like in C#). Example:
1RandomNamespace.ClassWithReallyLongNameBecauseCodingStandardsRequestIt<org.omg.CosNaming.NamingContextExtPackage> foo = new RandomNamespace.ClassWithReallyLongNameBecauseCodingStandardsRequestIt<org.omg.CosNaming.NamingContextExtPackage>();
Could easily be just:
1var foo = new SomeNamespace.ClassWithReallyLongNameAndTypeParameter<org.omg.CosNaming.NamingContextExtPackage>();
Still kind of big but not as big as Java wants it. Same goes for function calls:
1SomeRandomTypeThatIDoNotCare result = getResult();
could easily be
1var result = getResult();
Functions in the standard library do not use consistent naming, acronym and capitalization conventions, making it hard to remember exactly what the items are called:
java.net has URLConnection and HttpURLConnection : why not UrlConnection or HTTPURLConnection or HttpUrlConnection?
java.util has ZipOutputBuffer and GZIPOutputBuffer : why not ZIPOutputBuffer or GnuZipOutputBuffer or GzipOutputBuffer or GZipOutputBuffer?
This is actually part of the standard, you write all of them in uppercase if it has 3 or less letters, and only the first if it has more so, RPGGame and not RpgGame, and TLSConnection but you should use Starttls. So…..
- Arrays are objects but don’t properly implement .toString() (if you try to print an array, it just prints hash code gibberish) or .equals() (arrays of the same contents don’t compare equal, which causes a headache if you try to put arrays into collections).
- The Date API is considered deprecated, but still used everywhere. The replacement Calendar is not.
- Why is Stack a class, but Queue an interface?
- Stack belongs to old collection API and should not be used anymore. Use Deque(interface) and ArrayDeque(implementation) instead.
- Useful methods like sorting, binary search, etc. were not part of Collection classes, but part of separate “utility classes” like Collections and Arrays
I hated Java Applets from the get go. It makes me so happy that they are literally dead.
- Saying that Java is nice because it works on every OS is like saying that anal sex is nice because it works on every gender.
- Code is cluttered with type conversions. Arrays to lists, lists to arrays, java.util.Date to java.sql.Date, etc.
- The Java thread pig farm
Node.js users constantly ridicule Java server platform saying that the Java thread factory is one big pig farm that adds 2MB of additional fat to the server RAM profile each and every time someone clicks on any supported Web link. During its initial days, Java threads were extremely lightweight when comapared to competing