why_java_sucks_reversed(37) Language: English

An answer to Why Java Sucks

----------------------------------------------------------------------[ Meta ]--

name		why_java_sucks_reversed
section		37
description	An answer to Why Java Sucks
tags		java reply blog
encoding	utf8
compliance	informal
lang		en
creation	01/2014
copyright	Copyright (c) 2014 Ma_Sys.ma.
		For further info send an e-mail to Ma_Sys.ma@web.de

--------------------------------------------------------------[ Introduction ]--

The page url(http://tech.jonathangardner.net/wiki/Why_Java_Sucks) lists some
interesting arguments _against_ Java -- one of my favorite programming
languages. It suggests to write down reasons for liking Java in the section
"`Why Use Java at All?"' which I thought to be a good idea to follow especially
with respect to evaluating other programming languages. The page specifically
suggests the reader to try

 * Python
 * Lisp
 * Scheme
 * Haskell
 * C
 * other functional programming languages

Although the page wants me to try _all_ of these languages before continuing to
consider Java, I only tried Python, C and Prolog so far.

-----------------------------------------------[ What's wrong in the article ]--

Some of the points mentioned are wrong (probably not wrong but now wrong, i.\,e.

 * Casting `int` to `long` is possible. The given example works for me.
 * ``Inner classes don't work.'' Inner classes work for me.


	// $ javac Test.java
	// $ java Test
	// 0
	// $
	public class Test {
		private static class Sub {
			void myFunc(long arg) {
		public static void main(String[] args) {
			Sub s = new Sub();

---------------------------------------------------------[ Different opinion ]--

Many of the drawbacks of Java mentioned in the page are rather based on opinion.
Sometimes I prefer what is described as ``bad'':

GC problems
	A GC is nice to have. It just seems that the author's JVM is buggy
	(might even apply to many JVMs -- they are possibly all buggy but that
	does not make the language bad).
	Exceptions have to be catched. That is _good_. Also, the problem with
	methods returning `null` as error is a problem of the programmer who
	wrote the class. The Java Standard Libary has such functions as well but
	with newer Java versions they have added better alternatives.
Name clash
	Why would one want to implement _different_ functions with the _same_
	name for `List<Long>` and `List<String>`? If there is only slight
	difference in handling, it might be better to do generic list processing
	and do `instanceof` checks afterwards.
static methods and members, No globals means frameworks
	I have been able to avoid the Singleton Pattern as well as addtional
	Frameworks. My programs still work and I do not find that limited. In
	the worst case, you can start passing around an object -- still much
	cleaner than global variables.
No control on member access and import problems
	In Java the same statement which does the same thing. It does not depend
	on anything at a completely different location in the code. If you set
	a member variable directly, no method is interferring. If you call a
	class name, it must be the class you expect. I find that good design and
	using the same class name in many packages rather bad (Java Standard
	Library does it itself, I know...)
	You do not need to use camel case. It is just common convention.
	What's wrong with additional classes -- decoupling parts of your program
	is always a good idea, isn't it?
Iterators SUCK!
	I do not want to know, how the standard library implements the
	Collection classes, but I would never want my code to throw any
	exception except for errors. Just waiting for the exception to mark
	the end is bad design in my opinion.
Function Pointers
	The lack of function pointers is no problem if one designs object
	oriented which Java expects.

--------------------------------------------------------------------[ Agreed ]--

 * incompatible types -- that seems to be a bug.
 * foreach doesn't take iterators
 * Methods With the Same Name as Constructors -- bad design.
 * Run-time Dispatch: Fantasy -- bad design
 * DNS Client Implementation -- bug

------------------------------------------------------[ Why Use Java at All? ]--

My points for Java
 * Java is typed. When using variables, I _always_ have a definite idea about
   it's type.
 * Java is platform-independent. Good Java programs run everywhere you can find
   a compliant JVM.
 * Java has a large and good standard library eventhough it still could be
 * Java is as I expect it: C-like syntax, no superflous language constructs.
   Java is case-sensitive. Good Java is easy to read.
 * Java programs are highly debuggable. With the VisualVM you can monitor Java
   programs live and find out why they consume too much memory or such. Other
   languages require the user to start a debugger which consumes so much
   processor time and memory that the application to debug never reaches the
   probelmatic state you want to debug.
 * Java faciliates the use of classes and objects stronger than most other
   languages I know. Object orientation is only compromised by the use of
   the Singleton Pattern and ``Global variables through frameworks''. But that
   is the programmer's fault: I do not do it.
 * Java is stable: Large amounts of data can be processed with almost no
   limitatinons except for the hardware. I have experienced many C-programs
   crash with large data inputs while Java programs often tend to use more
   memory but are still able to process that much data. In a way it is the
   C programmers fault, but Java easifies writing stable programs.
 * Java programs are small as long as you stay with the standard library and
   probably one or the other special library required for your application.
   (Surely this applies to Python as well).

My points against Java
 * `byte` in Java is signed. That is bad, because there are always casts to
   `int` involved if you want to manage bytes directly.
 * The standard library has aged a bit and is only slowly replaced by better
 * Java programmers tend to throw half of the standard library away for
   alternatives which are not ultimately better but _always_ add hundreds of
   megabytes to their program.
 * ``Java is So Hard People Prefer to Write Code in XML, Jython, Scala, and
   Clojure'' -- a sad truth
 * Documentation with HTML-documentation-comments often hurts code-readability.
 * Java lacks simple system integration -- The Java native interface is really
   difficult to handle: A task like ``Create a virtual filesystem serving the
   documents directly from the database'' becomes a real problem.

Compared to other programming languages, I still like Java very much.

	Python is not typed and I do not understand how not declaring variables
	at a central place could be a benefit -- it helps me understand the
	code. Also, I do not like that Python does not allow me to use newlines
	whenever whitespace is required. Sometimes, a `\\` is requried to break
	longer lines and sometimes it is not...
Functional programming
	Functional programming is certainly interesting and large programs can
	be built with it but _I_ do not know how to do that. Also, the thought
	of mainly processing data with recursion is difficult for me: I try to
	_aviod_ recursion whenever possible.
	Actually, I like C very much, but often I prefer to have a good standard
	library for just about everything. Besides, I like object oriented
	programming to structure my program. I am always losing track when
	writing programs with more than 400 lines and a few files of C. Finally,
	the memory managing costs time and often leads to segfaults which then
	need to be debugged which again costs time...

Zum Seitenanfang