Fleeble Widget (fleeblewidget) wrote,
Fleeble Widget

Java, I hate you

Auto-boxing and unboxing isn't a bad idea - since Java behaves in odd ways at the boundary between primitive types and proper objects, why not simply have it magically convert one into the other behind the scenes as needed? Great!

However, the implementation of this great idea is half-arsed and ragged around the edges. For example, today I spent some time trying to figure out why I couldn't call the toArray method on a vector of doubles. Turns out this is because the Vector can only be built out of objects, so java helpfully turned double[] into Double[] for me when constructing the vector. However, when it comes time to go the other way, java doesn't feel like helping so I have to call toArray with Double as my argument. Which is fine, but now I have an array of Double and what I actually need is double. Which would also be fine, except this just happened:

./uk/co/nag/E02/E02bez.java:202: inconvertible types
found   : java.lang.Double[]
required: double[]
                                 (double[])h.toArray(new Double[h.si

Inconvertible? Really? That's breathtakingly aggravating.

What's extra annoying is that I'm currently hand-coding a java translation of one of our routines for a client in the banking sector, and all this pissing about translating one thing to another, with all the extra method calls, is likely to mean it ends up being slower than simply writing a wrapper around the Fortran version of the same code. Stupid language. I blame universities for making it popular. What's so wrong with C, people?
  • Post a new comment


    default userpic

    Your reply will be screened

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 1 comment