In this case I used the word 'modulo' kinda means 'excepting' so it should have read "everything is a reference rather than a value type (except where it isn't, except auto-boxing)". Auto boxing is when a primitive type like int automagically gets converted to an object type (like Math.Int if my memory of Java holds up) when it is used like an object. See http://java.sun.com/j2se/1.5.0/docs/guide/language/autoboxing.html.
Well, obviously you want your compiler/VM to be smart enough to spot when it can actually just use an int to represent the Integer object. But you don't want to expose it to the programmer.
Quite. If Haskell and Lisp compilers can unbox types automatically, then surely it's not much of a stretch to expect Java compilers to do it. The job is much easier with Java than in Lisp, because you don't have to deal with dynamic typing as well as everything else.
There's a difference between "will unbox automatically if it happens to spot it can" and "will definitely unbox here". People trying to optimise Haskell code for speed often end up using explicitly unboxed types (a GHC extension).
I spent almost all of last week microsecond-optimising our new swearword-filter ;_;
Just because Java isn't the best language for optimising, doesn't mean one shouldn't. Well, I'm sure as hell not learning C++ to the same level, anyway...
This (third-party) JVM was written in C++. Yours truly had to port it to our proprietary embedded platform which, at the time, had insufficient RAM for it to be really useful to folk. It didn't come with class libraries, so we used GNU Classpath, which led to some amusing bugs whereby the JVM's JCLASS objects had some fields which mismatched (and hence corrupted) the corresponding members of java.lang.Class.
I feel like I've just caused the downfall of Java just by blundering into something I don't know very much about. Bah, well I like Java because it is nice to me and doesn't break that often. *shakes fist at the C non-believers*
C makes me cry, so really my grand master plan of poking C++ for the dissertation isn't that good really, is it? ;_;
(no subject)
Date: 2006-04-11 09:36 am (UTC)Autoboxing
Date: 2006-04-11 09:41 am (UTC)Re: Autoboxing
Date: 2006-04-11 09:44 am (UTC)Of course, this can lead to the "why are you writing memory-optimised code in Java" argument, but I'm ignoring that for now.
Re: Autoboxing
Date: 2006-04-11 09:50 am (UTC)Re: Autoboxing
Date: 2006-04-11 10:10 am (UTC)Re: Autoboxing
Date: 2006-04-11 01:22 pm (UTC)Re: Autoboxing
Date: 2006-04-11 11:20 pm (UTC)Re: Autoboxing
Date: 2006-04-11 10:41 am (UTC)Re: Autoboxing
Date: 2006-04-11 11:03 am (UTC)Just because Java isn't the best language for optimising, doesn't mean one shouldn't. Well, I'm sure as hell not learning C++ to the same level, anyway...
Re: Autoboxing
Date: 2006-04-11 11:17 am (UTC)Nurse! I called for my pills!
Re: Autoboxing
Date: 2006-04-11 11:58 am (UTC)I feel like I've just caused the downfall of Java just by blundering into something I don't know very much about. Bah, well I like Java because it is nice to me and doesn't break that often. *shakes fist at the C non-believers*
C makes me cry, so really my grand master plan of poking C++ for the dissertation isn't that good really, is it? ;_;
Re: Autoboxing
Date: 2006-04-11 12:00 pm (UTC)Ugh >_