IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New I'd like to see it.
I can always use more ammo.

I wouldn't be nearly as annoyed if the wrappers weren't so impossibly lame. Could we have the ability to just *compare* numbers for equality? Maybe just the int types?

I am out of the country for the duration of the Bush administration.
Please leave a message and I'll get back to you when democracy returns.
New Some shortcomings of primitives
1. Here are some really good ones about reflection and primitives.

Java's reflection code has incorporated an assortment of kludges to be able to handle primitives. A few examples:
a. There are times when using the reflection API "magic" happens with regard to primitive types and wrapper classes. Sometimes, we expect a primitive but instead get an instance of a wrapper. Conversely, at times we must remember to wrapper primitives before passing them as arguments to reflection methods.

Given the following code:

public class Tester {
public boolean test (int i) {
return i > 3;
}
}


The method takes an int and returns a boolean. Yet to invoke it via reflection I need to pass it an Integer object and I receive back a Boolean object. Here is the code:

Object[] args = new Object[1];
args[0] = new Integer(3);
Boolean result = (Boolean)m.invoke(t,args);

In short, if I invoke test via a normal method call I pass it an int (primitive) and it returns a boolean (primitive). If I invoke test via reflection I need to pass it an Integer (object) and it returns a Boolean object, does that make sense????

b. Every object is an instance of a class and I can obtain the Class instance at runtime by calling getClass(). However, primitives, have no class and therefore the following is not allowed:

int i = 1;
i.getClass();


However, I can get a Class object for a primitive in a number of ways. For example:

class Test {
public int i;
}
Test test = new Test();
Class c = test.getClass();
Field fieldi = c.getField("i");
Class classOfI = fieldI.getType();


I now have a a Class object for int!!

classOfI.getName(); //returns int

We can ask it its name, and we find that we have a Class named "int." Realizing part of the problem, the developers of Class included a message to ask if the Class is a primitive:

classForI.isPrimitive() // returns true

But, how can a Class be a primitive? What does that mean???

There are other ways to get a Class object. We can say:
Class class = int.class;
and obtain a Class object whose name is int. Yet we cannot do the following:

Class.forName("int");

this does work for regular classes such as:

Class.forName("java.lang.String");

In short Java's reflection code has incorporated a series of kludges to be able to handle primitives. We have classes that are primitives, somethings work somethings don't, etc.

2. Because of primitive types polymorphism and thus a big piece of
good object-oriented design is defeated and we need to code special
cases for primitives. For example: String needs 8 different valueOf
methods to deal with all the primitive types. Here is the code:
public static String valueOf(Object obj) {
return (obj == null) ? "null" : obj.toString();
}

This should be all that is needed, an Object decides how it is printed (in fact even this method has a problem in that it needs to explicitly check for null and handle it, in a real OO language like Smalltalk, nil knows how to print itself). However for primitives we need to take a procedural approach, the decidison is made by code separate from data.
public static valueOf(boolean b) {
return b ? true: false;
}




3.Primitive variables cannot be used wherever objects can be used;
You can't have a collection of int's

Expand Edited by bluke Dec. 8, 2002, 07:39:19 AM EST
New Yep, seen all those.
FWIW, I've been having an email exchange with Gilad Bracha - one of the sponsors of this thing who, as it turns out, is one of the creators of Strongtalk (bought by Sun and killed).

His explanation is that, yes this is lame, but you can't lead them out of the darkness all at once - you have to do it incrementally and this is one more step on the path.

His response:
"The JSR has been very well received - Java people love it. Only Smalltalkers complain."

But I wasn't complaining about his JSR - rather that its a bit of a bandaid on a sucking chest wound. And of course Java people love it - Java people love Java.
I am out of the country for the duration of the Bush administration.
Please leave a message and I'll get back to you when democracy returns.
Expand Edited by tuberculosis Dec. 9, 2002, 05:24:46 AM EST
New Unfortunately people like Gosling ...
are not headed in the same direction. Here is a quote from Gosling
[link|http://java.sun.com/features/2002/03/gosling.html|ABOUT JAVA TECHNOLOGY An Interview with James Gosling ]

"JAVA DEVELOPER CONNECTION PROGRAM (JDC): If you could start again, would you make everything an object rather than the current int, boolean, byte, etc, viz-a-viz object disconnect?

JAMES GOSLING: No, actually I tend to go the other way, which is to say, a way to make classes behave more like primitives, so that they can be optimized and become extremely efficient, and maybe have a way to do autoboxing so that they sort of go back and forth between being objects. There are a lot of subtle problems around autoboxing that always make me nervous, and the big one being questions around identity. "

I agree with you that Java as it stands today is unsalvageable, they just keep adding more and more stuff on top of a very lousy foundation.
New Heh. There's a reason for that.
And of course Java people love it - Java people love Java.


Java people love Java because it's the only alternative to .ASP they can get past the managers. So let me them love it.

Many fears are born of stupidity and ignorance -
Which you should be feeding with rumour and generalisation.
BOfH, 2002 "Episode" 10
     Java - a baby step towards Smalltalk -a giant leap towards C - (tuberculosis) - (25)
         Re: Java - a baby step towards Smalltalk -a giant leap - (deSitter) - (3)
             Read the link - (tseliot)
             Java gravitating towards C#? - (ChrisR) - (1)
                 Re: Java gravitating towards C#? - (deSitter)
         They won't admit they were wrong - (bluke) - (19)
             I had a "discussion" with a C++ programmer - (admin) - (11)
                 Re: I had a "discussion" with a C++ programmer - (tuberculosis) - (10)
                     Re: I had a "discussion" with a C++ programmer - (neelk) - (9)
                         Roll your own... - (ChrisR) - (8)
                             Interesting summary - (ben_tilly)
                             Needle... - (neelk) - (6)
                                 What is the underlying motivation? - (tuberculosis) - (5)
                                     Re: What is the underlying motivation? - (neelk) - (4)
                                         Suggestion... - (ben_tilly)
                                         Have fun - (tuberculosis) - (2)
                                             Re: Have fun - (neelk) - (1)
                                                 Sounds cool - compare it to Strongtalk? - (tuberculosis)
             I'd like to see it. - (tuberculosis) - (4)
                 Some shortcomings of primitives - (bluke) - (3)
                     Yep, seen all those. - (tuberculosis) - (2)
                         Unfortunately people like Gosling ... - (bluke)
                         Heh. There's a reason for that. - (tseliot)
             Java 1 wasn't *that* bad - (wharris2) - (1)
                 Wasn't bad??? - (bluke)
         The Java-Language-Design Research Algorithm, Unleashed - (bluke)

Well, the place was crowded. We were packed in like sardines. They were all there to listen to the Big Band sounds of Tommy Dorsal. What sole! Tommy was rocking the place with a very popular tuna: "Sal-mon Chanted Evening," and the stage was surrounded by screaming groupers; probably there to see the bass player.
57 ms