Sunday, October 10, 2010

More Java Bashing...

Over the past few weeks, I've had to do some coding for some project in Java. As I've already mentioned before, there are heaps of things that I don't like about Java. Today, I'll be expanding on this list, in light of some things I've run into in my latest project.




1) Why can we NOT declare 'static' functions in interfaces that must be implemented by all classes that implement these. If we treat interfaces as "contracts" of all the functionality that a class and/or objects instantiated from that class must implement, then statics (i.e. class functionality) should be able to fall under that category too.

2) As a workaround to 1), I tried making those methods instance-methods instead, but that now means that I need to instantiate an instance of some classes first. Instantiating dummy classes from 'generics' (i.e. type-parameters) as 'real' classes though is not possible, requiring jumping around in some hoops to get this all working.

3) It seems that the Java tools (javac, java, etc.) use different "path separators" on Windows and Linux (please read to the end of this before jumping to conclusions about which separators I'm talking about). I found this the hard way when writing "buildscripts" that worked by calling javac and supplying the source-directories with -sourcepath ...srcdirs... Now, the "path separators" I was talking about, are the symbols used to separate two paths to source files, NOT the ones between directory names. That is, under Windows, you use ";" (e.g. "ui;db;src"), while on Linux you'd have to use ":" (e.g. "ui:db:src"). Grr!

4) Why oh why couldn't the designers of Java make up their minds on how to get the size/length/number of elements in a container! It's like there were several nomadic tribes of coders roaming around at Sun, each speaking a different dialect of Java-design
- strings use length()
- arrays use length
- collections use size()
- seems to even use size
Ewww...

Perhaps I'm biased from coding in my favourite language, Python, where these are all just treated the same by using len(someContainer), but IMO they are all a similar concept that should really be able to be used with a single syntax.

5) What the heck were some of the designers smoking when they came up with the convoluted "Calendar" crap for dealing with Time/Dates. I'll admit that I'm not really too experienced in this area of business (I'd really prefer that I didn't have to deal with it at all), but trying to make sense of this API is quite tricky. To me, it smells like they tried mixing Time+Date into "Calendar", though they also still provide a "DateTime" class to the side. Then, they go and say that actually, Calendar is really an abstract class, and you really need to instantiate a "GregorianCalendar" to do anything useful/sane. Uh huah... so I have to go around squawking "GregorianCalendar" everytime I want to represent a date. So, err... how do I just get a print of the current date+time, and add days/weeks to the provided times?

6) Java's idea of "warnings" being terminal problems that MUST be fixed TODAY means that a lot of things take longer than they should.

No comments:

Post a Comment