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 Re: Java going in the other direction
The artcle at [link|http://java.sun.com/features/2003/05/bloch_qa.html|http://java.sun.com/.../05/bloch_qa.html] gives examples of the new features for java 1.5. I think the new features are an improvement (given what you are starting with) and will make java programming easier. Generics, autoboxing and the new iterator syntax in particular address a number of annoyances in the language.

However ...

On a lark, I converted his examples to Ruby, and in every case (except the enum example), the Ruby code was still smaller and more direct and expressive than the new JDK 1.5 examples. (I know most here are Python programmers ... I'm sure doing the same in Python would give similiar results).

Although JDK 1.5 is an improvement, it still doesn't match the flexibility and expressiveness of a good, dynamic language.
--
-- Jim Weirich jweirich@one.net [link|http://w3.one.net/~jweirich|http://w3.one.net/~jweirich]
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
New Smalltalk also
For example the frequency table example can be expressed in 1 line in Smalltalk

Collection>>#frequency
^self asBag

Doesn't get much better then that.

The improvements are sugar coating. All the improvements are compiler tricks to hide the underlying deficiencies of the language. Generics are just the compiler adding in a bunch of casts, at runtime you lose all the generic information.
New Speaking of autoboxing
If you auto-unbox null, should you get zero or a NullPointerException?

If I'm not mistaken, I think the current plans are to return 0.
New gasp
-drl
New This is what happens when the foundation sucks
You can try and beautify things, but you end up with major compromises. The introduction of primitive types into Java from the start was a huge mistake. It is a classic case of a premature optimization. The creators of Java were sure that primitives as Objects would cause performance problems and therefore went with primitives. They ignored existing languages which dealt with these issues such as Smalltalk, where the VM deals with the issue, or statically typed languages like ML or even ongoing research which produced PolyJ.
New Oh My!
How generous of them! The performance of Java is SO good due to their sacrifices on behalf of us!
-drl
New According to Joshua Bloch it hasn't been decided yet
[link|http://java.sun.com/features/2003/05/bloch_qa.html|New Language Features for Ease of Development]

"One thing worth noting: this program assumes that when you auto-unbox null, you get zero. It's still an open issue whether this will be the case. The alternative is to throw NullPointerException. Both alternatives have their advantages. Unboxing null to zero beautifies applications like the one above, but it can also sweep real errors under the rug. If anyone has any strong opinions, or better yet, convincing arguments on this issue, please pass them along to the JSR-201 expert group."
New This is just stupid
Null is only zero because historically C used zero to represent null.

Since null is meant to be a special value of object reference, why is it not just an object?

I suspect its simply because the J-heads are designing from inside the box.



"Packed like lemmings into shiny metal boxes.
Contestants in a suicidal race."
    - Synchronicity II - The Police
New I think you missed the point
The question is not how to represent null, but when extracting a integer from its boxed container, if the boxed container is missing (the reference is null), then should the result be zero (a reasonable default) or should it cause an exception (also a reasonable expectation).

This has nothing to do with the historical representation of a null pointer as zero.

Now, granted, the whole boxed primitive idea is a kludge to work around a lack of foresight in the original language design.

(an aside: I wonder how much performance will be lost through this autoboxing technique, especially compared with eliminating primitives altogether. I suspect (without proof) that the no-primitives technique done right would have be faster overall).
--
-- Jim Weirich jweirich@one.net [link|http://w3.one.net/~jweirich|http://w3.one.net/~jweirich]
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
New OK, maybe so
Because now I'm trying to figure out how you put a null integer into the container in the first place. My guess is if autoboxing is implemented, then nobody will bother with using the wrapper classes directly (since they can't even be used for arithmetic now anyhow).

IOW, you are never going to see this in brand new 1.5 code:

Integer i = new Integer(5).
List list = new ArrayList();
list.add(i);

when you can do:

List<int> list = new ArrayList<int>();
list.add(5);

So how do you put a null value into this list?

Is the problem this:

List<Object> list = new ArrayList<Object>();
list.add(new Integer(5)); // do you need to do this or should the autoboxing make it an Integer?

then the argument is

int i = list.get(0);

which should require a cast anyhow since the list type is Object.
Hmmmm. I'm not seeing it.



"Packed like lemmings into shiny metal boxes.
Contestants in a suicidal race."
    - Synchronicity II - The Police
New Re: OK, maybe so
ToddBlanchard: [...] figure out how you put a null integer into the container in the first place.

How about (stealing the example from the article) ...
Map<String, Integer> m = new TreeMap<String, Integer>();\nint i = m.get("not_yet_in_map");
Should "i" be zero, or should there be a null pointer exception thrown? (remember that get returns a null pointer of the key doesn't exist).
--
-- Jim Weirich jweirich@one.net [link|http://w3.one.net/~jweirich|http://w3.one.net/~jweirich]
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
New Well in this case
I think a KeyNotFoundException should be thrown.

This is just another case where Smalltalk's collection class protocols are vastly superior to J-crap.

i := dict at: 'not_there' ifAbsent: [ 0 ].

For java I would propose something similar on Map.

map.getValueIfAbsent('key_not_found',5);

failure to use this should throw a KeyNotFoundException.



"Packed like lemmings into shiny metal boxes.
Contestants in a suicidal race."
    - Synchronicity II - The Police
New Perhaps ... but ...
Todd: For java I would propose [...] map.getValueIfAbsent('key_not_found',5);

That's an interesting proposal ... but it still doesn't solve the basic question of unboxing nulls. But ... let's let the J-Heads worry about that.

Ruby handles missing hash values a bit differently. If the key is not in the hash, you get a default value (which is typically nil, but can be something else).

   h = Hash.new\n   h['not_there']  #=>  nil\n\n   g = Hash.new { 0 }\n   g['not_there']  #=>  0\n\n   j = Hash.new { fail "key not found" }\n   j['not_there']  #=> Exception

--
-- Jim Weirich jweirich@one.net [link|http://w3.one.net/~jweirich|http://w3.one.net/~jweirich]
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
New My point was
it should be impossible to "box" null (and I think it probably is). So the problem ought not to exist. So the problem isn't how do you unbox null, its "how do you provide a mechanism for signaling and handling this case".

I have found the requirement to provide a default "not found" value to be a useful bit of flypaper.

OTOH, Java currently returns null from maps where the key is missing so I suppose they will decide that backwards compatibility is more important than better behvior.




"Packed like lemmings into shiny metal boxes.
Contestants in a suicidal race."
    - Synchronicity II - The Police
New Not J-heads.
This is how Python, Perl, etc. work.

If you want to increment a value in a hash, and it hasn't been set yet, scripting languages assume it to be 0. This is extremely convenient for such things. However, there is an assumption about the nature of null being made.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Smalltalk as usual is consistent
nil is the Singleton instance of UndefinedObject and all Objects are initialized to it. This simplifies many things and is very powerful, for example, when trying to print something, you don't need code that explicitly checks for nil as UndefinedObject understands how to print itself. This also allows you to add all kinds of behaviour to nil objects if needed.
New Set Theory
In set theory, there is a gigantic difference between "nothing" (empty set) and "non-existence". Computer development idioms should have a way of dealing with this difference. The only tool I know that does is APL.
-drl
New Re: Set Theory
\nSet foo = null; // nonexistence\nSet foo = new HashSet(); // empty set\n

Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Here we go
I'm sure you'll argue, but what the fuck...you seemed determined to be contrary, as if every thing I say is a direct challenge to you personally.

Your example is exactly what I DIDN'T mean. Someone in J-world invented a piss-poor mimic of set theoretic ideas - so what? There can still be null pointers flying around and they can still cause destruction. In any case I think it's in a utility class definition so it's not natively part of the language, is it?

APL has no types. It has arrays. An array can be empty but still exist. THAT is a real "null". But, "null" has a size - 0. It's the size of null that is 0, NOT null itself.

Is that clear? I have the greatest respect for you skill but I'm damn sick of you and Peter just dismissing what I say as if I were some pimply ignorant teenager.

If you find a REAL example of an idiom that is built around sets other than APL, let me know.

(BTW historically APL was invented as a way to describe algorithms, not as a language - that is probably why it is such a perfect langauge.)
-drl
New Re: Here we go
You asked. I provided. Go take a flying leap if you didn't want a response. I'm sick of your crusty, argumentative "I'm the authority" diatribes around here.

You originally said:
In set theory, there is a gigantic difference between "nothing" (empty set) and "non-existence".
No kidding, Sherlock. I showed you how that difference is represented in Java.

An array can be empty but still exist.

\nSet foo = new Set();\nSystem.out.println(foo.size()); // prints 0\n
This is your "nothing" or "empty set".

Your "non-existence" in Java is represented by a null. The terminology may not be the same, but the same functionality is there.

I'm damn sick of you and Peter just dismissing what I say as if I were some pimply ignorant teenager.
Then quit writing stupid ignorant blather as if you were some pimply ignorant teenager. Or learn to express yourself better (another sign of adulthood). Or STFU. Your choice. This is my last response to you until you grow up, ace.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Amazing
When you declared Set s=null, you made a set and assigned it a value. The fact that you made a set means that it exists.

This is COMPLETELY DIFFERENT than the way an APL array can be empty - it's not even remotely the same thing. If something is non-existent in APL and you try to refer to it, the interpreter stops (other things being default equal). That would never happen in any case, because one just doesn't make that kind of error.

As far as Conrad's SQL statement, this isn't even worth commenting on, because SQL is not a development idiom.

If you were me. you'd be frustrated talking to walls as well.
-drl
New Re: Amazing
If something is non-existent in APL and you try to refer to it, the interpreter stops (other things being default equal).
If you have a null object in Java, and you try to use it, the interpreter stops.

Not the same != can't be used the same. I'm really not catching what you're on about here. "If something is non-existent". How do you represent something that is non-existent in APL then?
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Re: Amazing
It's a very subtle and difficult point.

You can't model non-existence with something that exists and has a special value, no matter what it is. So "Set s=null" is emptiness, not non-existence. Strong typing means that everything you refer to HAS to exist. Set s = new HashSet() is not emptiness, because s now has an identifiable property. It's like an empty glass of water - s is the glass, not the water.

In APL, an empty array is in an intermediate area - it exists but has no properties. BY DEFINITION, size 0 = empty. So you can safely deal with emptiness because your in no danger of causing an NPE. Here's an example:

[link|http://www.csm.astate.edu/~rossa/cs3543/apl.html|http://www.csm.astat...a/cs3543/apl.html]

I have to run but will get back to this interesting topic. Please, let's bury the hatchet - IN CONRAD!
-drl
New Wow. My first exposure to APL
and Brainf*ck seems to be not too bad at all.

But you are right. APL's empty is closer to Smalltalk's Null than Java's null. Correct me somebody, but I think Smalltalk's Null can be made to behave exactly like APL empty if so desired. E.g. 0*nil would now yeild doNotUnderstand exception, but you can handle some messages in Null and in Number to make it evaluate to nil.
--

Less Is More. In my book, About Face, I introduce over 50 powerful design axioms. This is one of them.

--Alan Cooper. The Inmates Are Running the Asylum
New Same as in Objective C
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Re: Amazing
deSitter: It's a very subtle and difficult point.

Its even more subtle than that. Its not merely empty vs non-empty, but APL doesn't distinguish between a single number and an array of length one.* In other words, the number 1 can be treated as a number, or as an array of a single element.

Now this is makes for some convient shortcuts in programming (much like returning a zero when unboxing a null pointer), but I don't think it is mathematically very accurate. In Math**, a set of things and a thing are not the same thing***.

Footnotes:

* Assuming I correctly remember what little APL I ever knew.

** Assuming I correctly remember what little set theory I ever knew.

*** Do I get extra points for using the word thing(s) three times in one sentence?
--
-- Jim Weirich jweirich@one.net [link|http://w3.one.net/~jweirich|http://w3.one.net/~jweirich]
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
New Heh.
*** Do I get extra points for using the word thing(s) three times in one sentence?


Only if you publish it as "Thing Theory". :D

Many fears are born of stupidity and ignorance -
Which you should be feeding with rumour and generalisation.
BOfH, 2002 "Episode" 10
New ROFL
-drl
New No
>>>>>>>>>>>>>>
When you declared Set s=null, you made a set and assigned it a value. The fact that you made a set means that it exists.
<<<<<<<<<<<<<<

No.

When I do the above, I've declared a variable (a nest, a hook) that can be assigned a set (set can be placed in the nest, hung on a hook). I did not create any sets. Not even 0-sized sets. "null" is not a set.
--

He walks around, talking to himself. On the phone.
New Hey Ross, it's only a model.
Like sets are. Remember your Goedel. None of this matters. ;-)

But I am curious, how do you represent in code, in any language, the complement of "the set of all sets"? ;0)

And, set a property to be "Cardinality".
bcnu,
Mikem

The soul and substance of what customarily ranks as patriotism is moral cowardice and always has been...We have thrown away the most valuable asset we had-- the individual's right to oppose both flag and country when he (just he, by himself) believed them to be in the wrong. We have thrown it away; and with it all that was really respectable about that grotesque and laughable word, Patriotism.

- Mark Twain, "Monarchical and Republican Patriotism"
New Hey, watch this!
This is me not biting on the flagrant troll.
===

Implicitly condoning stupidity since 2001.
New Unlike DrooK, I'll bite: Ever heard of SQL, ya nitwit?!?
New See comment above, applies here as well
Your problem is the same as the two above you - your math background sucks.

That's it, I will no longer converse with jerks.

-drl
New Better stop talking to yourself then.
Your problem is the same as the two above you - your math background sucks.
Bachelor of Science, Comp Sci, 1992. Bachelor of Science, Algorithmic Mathematics, 1992. A good portion of that was set theory.

Your problem is that your programming background sucks. You also seem to have difficulty realizing that math terms are often not the same as the equivalent comp sci term. Deal with it. Or when you start talking about nulls and sets, make it clear you are talking about math, and not programming. They aren't the same. Or if that's the total point, say so.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
Expand Edited by admin May 13, 2003, 04:51:56 PM EDT
New Your problem is the same you had a year (or was it two?) ago
If anyone is "convers[ing] with jerks" here, it isn't you -- it is *you* who are being a total asshole, again.

The only question now is: Will it take you months and months to stop, this time too?

Marlowe and Norm sure aren't the only two manic-depressives here.


   [link|mailto:MyUserId@MyISP.CountryCode|Christian R. Conrad]
(I live in Finland, and my e-mail in-box is at the Saunalahti company.)
Your lies are of Microsoftian Scale and boring to boot. Your 'depression' may be the closest you ever come to recognizing truth: you have no 'inferiority complex', you are inferior - and something inside you recognizes this. - [link|http://z.iwethey.org/forums/render/content/show?contentid=71575|Ashton Brown]
     The awakening begins - (tuberculosis) - (140)
         Quotes from Uncle Bob - (admin) - (12)
             Maybe it's just me... - (Simon_Jester) - (5)
                 Static languages make the code brittle ... - (bluke)
                 History revisionism - beware !!! (IMHO) - (dmarker) - (3)
                     Re: History revisionism - beware !!! (IMHO) - (JimWeirich) - (2)
                         Another issue was the potential popularity of a lang - (dmarker) - (1)
                             Re: Another issue was the potential popularity of a lang - (JimWeirich)
             Gee...I thought it was a friendly discussion... - (jb4) - (4)
                 Re: Gee...I thought it was a friendly discussion... - (JimWeirich) - (3)
                     Manifest typing....a la Fortran. - (Simon_Jester)
                     Thanks, Jim. Nicely put. -NT - (jb4) - (1)
                         Re: Ditto - Thanks, Jim. -NT - (dmarker)
             Next experiment: try it without OO -NT - (tablizer)
         Java going in the other direction - (bluke) - (109)
             Re: Java going in the other direction - (JimWeirich) - (34)
                 Smalltalk also - (bluke)
                 Speaking of autoboxing - (ChrisR) - (32)
                     gasp -NT - (deSitter) - (2)
                         This is what happens when the foundation sucks - (bluke) - (1)
                             Oh My! - (deSitter)
                     According to Joshua Bloch it hasn't been decided yet - (bluke) - (28)
                         This is just stupid - (tuberculosis) - (27)
                             I think you missed the point - (JimWeirich) - (5)
                                 OK, maybe so - (tuberculosis) - (4)
                                     Re: OK, maybe so - (JimWeirich) - (3)
                                         Well in this case - (tuberculosis) - (2)
                                             Perhaps ... but ... - (JimWeirich) - (1)
                                                 My point was - (tuberculosis)
                             Not J-heads. - (admin) - (1)
                                 Smalltalk as usual is consistent - (bluke)
                             Set Theory - (deSitter) - (18)
                                 Re: Set Theory - (admin) - (12)
                                     Here we go - (deSitter) - (11)
                                         Re: Here we go - (admin) - (10)
                                             Amazing - (deSitter) - (9)
                                                 Re: Amazing - (admin) - (6)
                                                     Re: Amazing - (deSitter) - (5)
                                                         Wow. My first exposure to APL - (Arkadiy) - (1)
                                                             Same as in Objective C -NT - (admin)
                                                         Re: Amazing - (JimWeirich) - (2)
                                                             Heh. - (tseliot) - (1)
                                                                 ROFL -NT - (deSitter)
                                                 No - (Arkadiy)
                                                 Hey Ross, it's only a model. - (mmoffitt)
                                 Hey, watch this! - (drewk)
                                 Unlike DrooK, I'll bite: Ever heard of SQL, ya nitwit?!? -NT - (CRConrad) - (3)
                                     See comment above, applies here as well - (deSitter) - (2)
                                         Better stop talking to yourself then. - (admin)
                                         Your problem is the same you had a year (or was it two?) ago - (CRConrad)
             I remeber Pascal in the very same way - (jb4) - (72)
                 Just had this conversation - (tseliot) - (45)
                     Freep said the same thing - (tuberculosis) - (43)
                         Still waiting for ... - (jb4) - (42)
                             Depends on constraints - (tuberculosis) - (41)
                                 Platforms: - (jb4) - (40)
                                     Don't even get me started - (tuberculosis) - (30)
                                         I'll get you started, alright! - (jb4) - (29)
                                             No I'm not - (tuberculosis) - (28)
                                                 The problem is, you're trying to treat a bool as a number - (jb4) - (25)
                                                     No, I'm trying to branch on a condition - (tuberculosis) - (24)
                                                         21st Century Schitzoid Man - (jb4) - (23)
                                                             You are fighting the language - (tuberculosis) - (22)
                                                                 Tell you what... - (jb4)
                                                                 Can I put my oar in? - (static) - (20)
                                                                     Yeah sure - (tuberculosis) - (19)
                                                                         Such flowerly language toward such a misguided conclusion - (jb4) - (18)
                                                                             Yeah right - (tuberculosis) - (17)
                                                                                 (++true == false) - (ChrisR) - (1)
                                                                                     Just add a little gasoline, and stir!_____;-) - (jb4)
                                                                                 OK, Now I see wht your problem is - (jb4) - (5)
                                                                                     I thought you were going to give up on this - (tuberculosis) - (4)
                                                                                         How sensible is this?!? - (jb4) - (3)
                                                                                             Not convinced - (tuberculosis) - (2)
                                                                                                 Nor am I - (jb4) - (1)
                                                                                                     You guys should be using Modula-2. :-P (new thread) - (Another Scott)
                                                                                 And an answer to your question. - (jb4) - (8)
                                                                                     Wrong answer - (tuberculosis) - (7)
                                                                                         Wrong answer back - (jb4)
                                                                                         They've turned it into Pascal - (deSitter) - (5)
                                                                                             Circular definition. - (CRConrad) - (4)
                                                                                                 Re: Circular definition. - (deSitter) - (3)
                                                                                                     Self-contradiction, and logically inconsistent definition. - (CRConrad) - (2)
                                                                                                         Can someone start a new thread please? -NT - (drewk) - (1)
                                                                                                             What for, aren't the long ones the best? -NT - (CRConrad)
                                                 Comments on supposed idiocy - (JimWeirich) - (1)
                                                     Re: Comments on supposed idiocy - (tuberculosis)
                                     Don't even get me started - (tuberculosis)
                                     You didn't mention types of programs -NT - (tuberculosis) - (7)
                                         Sorry, thot I was clear earlier... - (jb4) - (6)
                                             Still doesn't tell me enough - (tuberculosis) - (5)
                                                 Re: Still doesn't tell me enough - (jb4) - (4)
                                                     The VM's are all written in very portable C - (tuberculosis) - (3)
                                                         Re: The VM's are all written in very portable C - (deSitter) - (2)
                                                             Funny you should mention it - (tuberculosis) - (1)
                                                                 Re: Funny you should mention it - (deSitter)
                     Minor modification - (jb4)
                 Just because *you* don't see it... - (pwhysall)
                 In fact.. - (deSitter) - (15)
                     Heh... - (jb4) - (14)
                         Re: Heh... - (deSitter) - (13)
                             BS - (admin) - (3)
                                 BS - (deSitter) - (2)
                                     When I see you spouting it, I'm going to call you on it. - (admin) - (1)
                                         Fair enough! -NT - (deSitter)
                             Do you have a clue why Linux is easily ported? - (ben_tilly) - (8)
                                 Re: Do you have a clue why Linux is easily ported? - (deSitter) - (7)
                                     No, that is not quite what you claimed - (ben_tilly) - (6)
                                         Well, to me -NT - (deSitter)
                                         Well, to me "moot" means.. - (deSitter) - (4)
                                             Why does your position appear to be shifting? - (ben_tilly) - (3)
                                                 Modus operandi - (admin) - (1)
                                                     Re: Modus operandi - (deSitter)
                                                 Re: Why does your position appear to be shifting? - (deSitter)
                 Wasn't Pascal written as a teaching tool? - (drewk) - (8)
                     Yes - (bluke)
                     Re: Wasn't Pascal written as a teaching tool? - (JimWeirich) - (6)
                         Re: Wasn't Pascal written as a teaching tool? - (Yendor) - (4)
                             Forward Declarations - (JimWeirich) - (3)
                                 Hmm, was Turbo Pascal different about that? -NT - (drewk)
                                 Been too long - (Yendor)
                                 Nope, you're right. - (jb4)
                         Not when I learned it - (drewk)
             Same bandaid as C++ templates - (tuberculosis)
         Re: The awakening begins - (systems) - (16)
             A couple answers - (tuberculosis) - (12)
                 ICLRPD - (drewk)
                 Do I C another one...? - (CRConrad) - (10)
                     Aren't they like seals? - (tuberculosis) - (9)
                         Yes they are. - (admin)
                         No - they're "almost, but not entirely, unlike" seals. - (CRConrad) - (7)
                             NFC. -NT - (admin) - (1)
                                 Does the phrase "Splitting Hairs" come to mind. :-) -NT - (ChrisR)
                             birds are feathered and hairy - (boxley) - (4)
                                 It's all feathers. - (admin) - (3)
                                     Re: It's all feathers. - (deSitter) - (2)
                                         Re, "PS": Yeah, sure - so, whatchathink HAIRS are?!? -NT - (CRConrad) - (1)
                                             Never really thought about it.. - (deSitter)
             Sometimes there aren't right answers - (ben_tilly) - (1)
                 Down with Determinants! :) -NT - (deSitter)
             Please indicate what you changed in an Edit. Thanks. :-) -NT - (Another Scott)

A vacation you’ll talk about for years to come, at AA meetings.
191 ms