(no subject)

Date: 2006-04-11 09:36 am (UTC)
From: [identity profile] filecoreinuse.livejournal.com
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.

Autoboxing

Date: 2006-04-11 09:41 am (UTC)
emperor: (Default)
From: [personal profile] emperor
Ewww. Couldn't they just have made the primitive types proper objects and had done with it?

Re: Autoboxing

Date: 2006-04-11 09:44 am (UTC)
From: [identity profile] duncanneko.livejournal.com
Given the memory overhead on objects in Java (~4-8 bytes, plus the pointer to the object, depending on your JVM), I'm somewhat glad they didn't.

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)
From: [identity profile] filecoreinuse.livejournal.com
Well all primitive types could be passed by reference implicity like FORTRAN... *ducks*.

Re: Autoboxing

Date: 2006-04-11 10:10 am (UTC)
pm215: (Default)
From: [personal profile] pm215
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.

Re: Autoboxing

Date: 2006-04-11 01:22 pm (UTC)
From: [identity profile] sevenstring.livejournal.com
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.

Re: Autoboxing

Date: 2006-04-11 11:20 pm (UTC)
From: [identity profile] hsenag.livejournal.com
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).

Re: Autoboxing

Date: 2006-04-11 10:41 am (UTC)
From: [identity profile] crazyscot.livejournal.com
Grumble mumble embedded system JVM port mumble. Nurse, my pills.

Re: Autoboxing

Date: 2006-04-11 11:03 am (UTC)
From: [identity profile] duncanneko.livejournal.com
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...

Re: Autoboxing

Date: 2006-04-11 11:17 am (UTC)
From: [identity profile] crazyscot.livejournal.com
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.

Nurse! I called for my pills!

Re: Autoboxing

Date: 2006-04-11 11:58 am (UTC)
From: [identity profile] uisgebeatha.livejournal.com
Um....

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)
From: [identity profile] duncanneko.livejournal.com
In that case, I will just sit back here and look sympathetic. Yes, that's sympathetic, honest...

Ugh >_

November 2025

S M T W T F S
      1
2345678
91011121314 15
1617 181920 2122
23242526272829
30      

Most Popular Tags

Expand Cut Tags

No cut tags