Tuesday, October 12, 2010

Java! What the Hell (No Support for Unsigned) (UTF-8 Encoding Bug)

Recently I got some work again in Java and it's around 5 years back when I last developed any application in Java. A lot of changes are here but I got a lot of issues with Java after coming from C#. In two worlds 'Java Sucks' if you are coming from C#. This was not the thought for me when I switched from Java to C#.


1. I required to deal with a lot with the binary data that has unsigned bytes but woh ho Java doesn't support unsigned int, unsigned byte. On asking one of my Java colleague (he loves java and hates C# as most of the people from Java background do) he said are you programming for some ancient age. Now no body uses unsigned things. What the solution this is? However wrote a tiny library to solve it. If you require it just drop me a mail I can send it.

2. Java Encoding Issue (UTF-8 with BOM): Java has a bug in the bug database from Sep-2001 that has been closed with no-fix and the reasoning behind it is:


The assumption we made to implement this RFE is that the change would not
break existing real world application, this assumption is obvious
not true, see #6378911. We decided to back out the change we've made
and closed this RFE as "will not fix", for compatibility reason.
Posted Date : 2006-02-18 02:33:09.0

What are you talking about?
I got some C# files that were getting laxically analyzed and parsed using ANTLR 3.2 in a Linux system using Java. And what I got an out of memory exception (heap out of space). What the hell I did. I am loading a 4kb file and its going out of memory. It was the encoding issue. However I managed to get the resolution here:

Now I think C# is much more richer and friendly language than Java.

Please don't mind it and take personally if you love Java and I am not here to remark on any language capabilities but its my personal choice to work with C#.