f



java.lang vs java.util

Surprising to see something defined in java.lang 
<http://developer.android.com/reference/java/lang/Iterable.html> depend on 
something defined in java.util 
<http://developer.android.com/reference/java/util/Iterator.html>.

Surely the hierarchy should go the other way?
0
ldo (2177)
4/2/2011 4:11:38 AM
comp.lang.java.programmer 52714 articles. 1 followers. Post Follow

30 Replies
1109 Views

Similar Articles

[PageSpeed] 13

On 4/1/2011 9:11 PM, Lawrence D'Oliveiro wrote:
> Surprising to see something defined in java.lang
> <http://developer.android.com/reference/java/lang/Iterable.html>  depend on
> something defined in java.util
> <http://developer.android.com/reference/java/util/Iterator.html>.
>
> Surely the hierarchy should go the other way?

I think Iterable may make it into java.lang because of its significance
in the foreach statement.

Patricia
0
pats (3556)
4/2/2011 4:23:13 AM
On 04/02/2011 12:23 AM, Patricia Shanahan wrote:
> On 4/1/2011 9:11 PM, Lawrence D'Oliveiro wrote:
>> Surprising to see something defined in java.lang
>> <http://developer.android.com/reference/java/lang/Iterable.html> depend on
>> something defined in java.util
>> <http://developer.android.com/reference/java/util/Iterator.html>.
>>
>> Surely the hierarchy should go the other way?

Not if it wants to be consistent with
http://download.oracle.com/javase/6/docs/api/
don't'cha think?

And the so-called "hierarchy" of java.util and java.lang is that they are 
equal.  The language reserves for itself the entire panoply of java.* and 
javax.* packages.

> I think Iterable may make it into java.lang because of its significance
> in the foreach statement.

That seems to go against Java's history of conservatism with respect to 
backward compatibility.  And why should it?  java.lang and java.util are 
equal.  The language reserves for itself the entire panoply of java.* and 
javax.* packages.

-- 
Lew
0
noone7 (4050)
4/2/2011 5:52:39 AM
On Sat, 02 Apr 2011 17:11:38 +1300, Lawrence D'Oliveiro
<ldo@geek-central.gen.new_zealand> wrote, quoted or indirectly quoted
someone who said :

>Surprising to see something defined in java.lang 
><http://developer.android.com/reference/java/lang/Iterable.html> depend on 
>something defined in java.util 
><http://developer.android.com/reference/java/util/Iterator.html>.
>
>Surely the hierarchy should go the other way?

Android did it that way because Sun did it that way. Why?  It might
have something to do with Iterator/Iterable being introduced late,
after Enumeration.

To me, they both belong in java.lang.util
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
Doing what the user expects with respect to navigation is absurdly important for user satisfaction.
~ anonymous Google Android developer

0
see_website (5876)
4/2/2011 6:43:06 AM
In message <e9hdp69clnqs8hijq8skm1ig0sh4c464ai@4ax.com>, Roedy Green wrote:

> It might have something to do with Iterator/Iterable being introduced
> late, after Enumeration.

Why? They introduced other changes in java.lang.

> To me, they both belong in java.lang.util

Python shows how important iterators can be as a fundamental language 
concept.
0
ldo (2177)
4/2/2011 6:52:15 AM
On 11-04-02 02:52 AM, Lew wrote:
> On 04/02/2011 12:23 AM, Patricia Shanahan wrote:
>> On 4/1/2011 9:11 PM, Lawrence D'Oliveiro wrote:
>>> Surprising to see something defined in java.lang
>>> <http://developer.android.com/reference/java/lang/Iterable.html>
>>> depend on
>>> something defined in java.util
>>> <http://developer.android.com/reference/java/util/Iterator.html>.
>>>
>>> Surely the hierarchy should go the other way?
> 
> Not if it wants to be consistent with
> http://download.oracle.com/javase/6/docs/api/
> don't'cha think?
> 
> And the so-called "hierarchy" of java.util and java.lang is that they
> are equal.  The language reserves for itself the entire panoply of
> java.* and javax.* packages.
> 
>> I think Iterable may make it into java.lang because of its significance
>> in the foreach statement.
> 
> That seems to go against Java's history of conservatism with respect to
> backward compatibility.  And why should it?  java.lang and java.util are
> equal.  The language reserves for itself the entire panoply of java.*
> and javax.* packages.
> 
java.util from Day One has simply been a grab-bag package. The name
"util" already says "we didn't know where else to put it". It's a bad
example and a bad naming choice which has led to innumerable copycats in
the form of not only third-party org.foo.util packages, but the
inevitable follow-on, FooUtils classes (which are almost invariably
grab-bag classes).

I don't know if Patricia was actually _advocating_ such a move, but for
the lion's share of classes and interfaces in java.util, any other
package with a considered name is a better place to put them. There
might be a half-dozen classes and interfaces that could stay in
java.util...like just the "utilities" even.

AHS
-- 
That's not the recollection that I recall...All this information is
certainly in the hands of the auditor and we certainly await his report
to indicate what he deems has occurred.
-- Halifax, Nova Scotia mayor Peter Kelly, who is currently deeply in
the shit
0
4/2/2011 12:50:32 PM
On 02/04/2011 8:50 AM, Arved Sandstrom wrote:
> java.util from Day One has simply been a grab-bag package. The name
> "util" already says "we didn't know where else to put it". It's a bad
> example and a bad naming choice which has led to innumerable copycats in
> the form of not only third-party org.foo.util packages,...

I'm in the position of developing some of my own personal software, 
which I'm organising under ca.queensu.cs.dal (the first 3 of which might 
need to change depending on what my employer decides to say about it). 
So I have ...dal.edfmwk for one particular set of tightly correlated 
libraries, and ..dal.txt for a demo text editor, but I'd rather have 
....dal.something.specialized for all the various "grab bag" classes 
rather than having a dozen ...dal.specialized direct descendants.  Right 
now "something" is util, and the only other thing I can think of to 
replace it is equally generic: "lib".

Do you have any suggestions?
0
dalamb (189)
4/2/2011 1:12:55 PM
"Arved Sandstrom" <asandstrom3minus1@eastlink.ca> wrote in message 
news:tYElp.789$rB2.37@newsfe21.iad...
> On 11-04-02 02:52 AM, Lew wrote:
>> On 04/02/2011 12:23 AM, Patricia Shanahan wrote:
>>> On 4/1/2011 9:11 PM, Lawrence D'Oliveiro wrote:
>>>> Surprising to see something defined in java.lang
>>>> <http://developer.android.com/reference/java/lang/Iterable.html>
>>>> depend on
>>>> something defined in java.util
>>>> <http://developer.android.com/reference/java/util/Iterator.html>.
>>>>
>>>> Surely the hierarchy should go the other way?
>>
>> Not if it wants to be consistent with
>> http://download.oracle.com/javase/6/docs/api/
>> don't'cha think?
>>
>> And the so-called "hierarchy" of java.util and java.lang is that they
>> are equal.  The language reserves for itself the entire panoply of
>> java.* and javax.* packages.
>>
>>> I think Iterable may make it into java.lang because of its significance
>>> in the foreach statement.
>>
>> That seems to go against Java's history of conservatism with respect to
>> backward compatibility.  And why should it?  java.lang and java.util are
>> equal.  The language reserves for itself the entire panoply of java.*
>> and javax.* packages.
>>
> java.util from Day One has simply been a grab-bag package. The name
> "util" already says "we didn't know where else to put it". It's a bad
> example and a bad naming choice which has led to innumerable copycats in
> the form of not only third-party org.foo.util packages, but the
> inevitable follow-on, FooUtils classes (which are almost invariably
> grab-bag classes).

Collections certainly deserve their own package.  And arrays should 
implement List, as they do in .NET.  (Arrays of objects, anyway -- there are 
obvious issues with arrays of primitives.) 

0
4/2/2011 2:57:33 PM
On 04/02/2011 12:11 AM, Lawrence D'Oliveiro wrote:
> Surprising to see something defined in java.lang
> <http://developer.android.com/reference/java/lang/Iterable.html>  depend on
> something defined in java.util
> <http://developer.android.com/reference/java/util/Iterator.html>.
>
> Surely the hierarchy should go the other way?

Iterator is needed for for-each loops, which were added several versions 
after java.util.Iterator was introduced. Iterablity, being a "language 
feature" was put in java.lang, but to be backwards-compatible with those 
who already implemented java.util.Iterator, they used that class. There 
actually is a note somewhere saying that the developers would prefer to 
not have to do this, but decided that backwards compatibility was more 
important than modularity aesthetics.

-- 
Beware of bugs in the above code; I have only proved it correct, not 
tried it. -- Donald E. Knuth
0
Pidgeot18 (1520)
4/2/2011 8:22:21 PM
In message <whFlp.2500$tC3.1742@newsfe01.iad>, David Lamb wrote:

> I'm in the position of developing some of my own personal software,
> which I'm organising under ca.queensu.cs.dal (the first 3 of which might
> need to change depending on what my employer decides to say about it).

Get your own domain name.
0
ldo (2177)
4/3/2011 12:37:38 AM
In message <in7dg0$pv$1@dont-email.me>, Mike Schilling wrote:

> Collections certainly deserve their own package.  And arrays should
> implement List, as they do in .NET.  (Arrays of objects, anyway -- there
> are obvious issues with arrays of primitives.)

Python does all this so much more cleanly...
0
ldo (2177)
4/3/2011 12:38:50 AM
On 02/04/2011 8:37 PM, Lawrence D'Oliveiro wrote:
> In message<whFlp.2500$tC3.1742@newsfe01.iad>, David Lamb wrote:
>
>> I'm in the position of developing some of my own personal software,
>> which I'm organising under ca.queensu.cs.dal (the first 3 of which might
>> need to change depending on what my employer decides to say about it).
>
> Get your own domain name.

Maybe eventually, but maybe not; software for educational purposes fits 
into the mandate. But that doesn't solve the part I was interested in at 
the moment, which was what to use instead of "util".

0
dalamb (189)
4/3/2011 12:05:00 PM
On 02/04/2011 2:52 AM, Lawrence D'Oliveiro wrote:
> In message<e9hdp69clnqs8hijq8skm1ig0sh4c464ai@4ax.com>, Roedy Green wrote:
>
>> It might have something to do with Iterator/Iterable being introduced
>> late, after Enumeration.
>
> Why? They introduced other changes in java.lang.
>
>> To me, they both belong in java.lang.util
>
> Python shows how important iterators can be as a fundamental language
> concept.

Iterators as a fundamental language construct have been around since the 
'70s.
0
dalamb (189)
4/3/2011 12:05:51 PM
On 11-04-02 10:12 AM, David Lamb wrote:
> On 02/04/2011 8:50 AM, Arved Sandstrom wrote:
>> java.util from Day One has simply been a grab-bag package. The name
>> "util" already says "we didn't know where else to put it". It's a bad
>> example and a bad naming choice which has led to innumerable copycats in
>> the form of not only third-party org.foo.util packages,...
> 
> I'm in the position of developing some of my own personal software,
> which I'm organising under ca.queensu.cs.dal (the first 3 of which might
> need to change depending on what my employer decides to say about it).
> So I have ...dal.edfmwk for one particular set of tightly correlated
> libraries, and ..dal.txt for a demo text editor, but I'd rather have
> ...dal.something.specialized for all the various "grab bag" classes
> rather than having a dozen ...dal.specialized direct descendants.  Right
> now "something" is util, and the only other thing I can think of to
> replace it is equally generic: "lib".
> 
> Do you have any suggestions?

Let's make sure it's not really a package consisting entirely of utility
classes, in which case calling the package "util" is sensible.
Rare...but sensible. A utility class (which one could justify calling
SomethingUtil[s]) generally has a bunch of static/class methods that do
common tasks applicable to (or useful for) a wide variety of objects.

You may genuinely have some classes in there that _are_ utility classes:
if so, separating _those_ out into a "util" package is OK. Other people
may use the name nonsensically, but you'll have it right.

If it's a package containing a variety of non-utility classes that are
simply difficult to classify at the moment, let's agree to agree that
calling the enclosing package "util" is confusing and incorrect, since
it implies that the classes _are_ utility classes. If it's in this state
- a miscellany of classes - I'd be inclined to leave it as

....dal.specialized

which you've noted you don't like (I believe we're assuming that
"specialized" is actually a class name). I don't think there's anything
inherently wrong with that; it actually expresses the inability to group
them further correctly.

AHS

-- 
That's not the recollection that I recall...All this information is
certainly in the hands of the auditor and we certainly await his report
to indicate what he deems has occurred.
-- Halifax, Nova Scotia mayor Peter Kelly, who is currently deeply in
the shit
0
4/3/2011 12:33:28 PM
In message <FoZlp.4488$zn.74@newsfe19.iad>, David Lamb wrote:

> On 02/04/2011 2:52 AM, Lawrence D'Oliveiro wrote:
>
>> In message<e9hdp69clnqs8hijq8skm1ig0sh4c464ai@4ax.com>, Roedy Green
>> wrote:
>>
>>> It might have something to do with Iterator/Iterable being introduced
>>> late, after Enumeration.
>>
>> Why? They introduced other changes in java.lang.
>>
>>> To me, they both belong in java.lang.util
>>
>> Python shows how important iterators can be as a fundamental language
>> concept.
> 
> Iterators as a fundamental language construct have been around since the
> '70s.

And yet Java still has trouble with them.
0
ldo (2177)
4/3/2011 10:11:42 PM
On 11-04-03 07:11 PM, Lawrence D'Oliveiro wrote:
> In message <FoZlp.4488$zn.74@newsfe19.iad>, David Lamb wrote:
> 
>> On 02/04/2011 2:52 AM, Lawrence D'Oliveiro wrote:
>>
>>> In message<e9hdp69clnqs8hijq8skm1ig0sh4c464ai@4ax.com>, Roedy Green
>>> wrote:
>>>
>>>> It might have something to do with Iterator/Iterable being introduced
>>>> late, after Enumeration.
>>>
>>> Why? They introduced other changes in java.lang.
>>>
>>>> To me, they both belong in java.lang.util
>>>
>>> Python shows how important iterators can be as a fundamental language
>>> concept.
>>
>> Iterators as a fundamental language construct have been around since the
>> '70s.
> 
> And yet Java still has trouble with them.

What specific problem is it that you've been unable to tackle in Java
because of these purported shortcomings? I'm not interested in a novice
explanation like "I can solve this problem like this in Python, and when
I try to translate it line-by-line into Java I just can't do it"; I'm
curious as to what the actual problem is that you're struggling with in
Java. We realize you're quite new with the language; you can't be
expected to be expert yet.

AHS
-- 
That's not the recollection that I recall...All this information is
certainly in the hands of the auditor and we certainly await his report
to indicate what he deems has occurred.
-- Halifax, Nova Scotia mayor Peter Kelly, who is currently deeply in
the shit
0
4/3/2011 10:25:16 PM
In message <dt6mp.2629$0r7.144@newsfe12.iad>, Arved Sandstrom wrote:

> I'm not interested in a novice explanation like "I can solve this problem
> like this in Python, and when I try to translate it line-by-line into Java
> I just can't do it"

Not that I ever asked for a “line-by-line” translation, but keep right on 
with your prevaricating strawmen, why don’t you.
0
ldo (2177)
4/4/2011 12:49:12 AM
On 11-04-03 09:49 PM, Lawrence D'Oliveiro wrote:
> In message <dt6mp.2629$0r7.144@newsfe12.iad>, Arved Sandstrom wrote:
> 
>> I'm not interested in a novice explanation like "I can solve this problem
>> like this in Python, and when I try to translate it line-by-line into Java
>> I just can't do it"
> 
> Not that I ever asked for a “line-by-line” translation, but keep right on 
> with your prevaricating strawmen, why don’t you.

You've been quibbling about the inability to do things in Java more or
less like you can do them in Python, which is why I threw that in. If
that's not the issue here, why not answer the real question I had, where
I asked for a specific example (or two) of where you are having problems
with Java iterators?

It's really easy to come out with high-flying statements like "yet Java
still has trouble with them", referring to iterators. People say stuff
like that about practically every construct in any language, and 90+
percent of the time they're adopting a fad started by some pundit. I
expect even dudes like Gosling or Stroustrup or van Rossum to back up
statements like that with some meat; why shouldn't you?

AHS
-- 
That's not the recollection that I recall...All this information is
certainly in the hands of the auditor and we certainly await his report
to indicate what he deems has occurred.
-- Halifax, Nova Scotia mayor Peter Kelly, who is currently deeply in
the shit
0
4/4/2011 1:50:01 AM
In message <ct9mp.1376$YL5.219@newsfe05.iad>, Arved Sandstrom wrote:

> On 11-04-03 09:49 PM, Lawrence D'Oliveiro wrote:
>
>> In message <dt6mp.2629$0r7.144@newsfe12.iad>, Arved Sandstrom wrote:
>> 
>>> I'm not interested in a novice explanation like "I can solve this
>>> problem like this in Python, and when I try to translate it line-by-line
>>> into Java I just can't do it"
>> 
>> Not that I ever asked for a “line-by-line” translation, but keep right on
>> with your prevaricating strawmen, why don’t you.
> 
> You've been quibbling about the inability to do things in Java more or
> less like you can do them in Python, which is why I threw that in.

Which reminds me, I’m still waiting for someone to show how they can do this
<http://groups.google.co.nz/groups?selm=ik1en0$gng$1@lust.ihug.co.nz> better 
in Java.
0
ldo (2177)
4/4/2011 4:05:19 AM
On 11-04-04 01:05 AM, Lawrence D'Oliveiro wrote:
> In message <ct9mp.1376$YL5.219@newsfe05.iad>, Arved Sandstrom wrote:
> 
>> On 11-04-03 09:49 PM, Lawrence D'Oliveiro wrote:
>>
>>> In message <dt6mp.2629$0r7.144@newsfe12.iad>, Arved Sandstrom wrote:
>>>
>>>> I'm not interested in a novice explanation like "I can solve this
>>>> problem like this in Python, and when I try to translate it line-by-line
>>>> into Java I just can't do it"
>>>
>>> Not that I ever asked for a “line-by-line” translation, but keep right on
>>> with your prevaricating strawmen, why don’t you.
>>
>> You've been quibbling about the inability to do things in Java more or
>> less like you can do them in Python, which is why I threw that in.
> 
> Which reminds me, I’m still waiting for someone to show how they can do this
> <http://groups.google.co.nz/groups?selm=ik1en0$gng$1@lust.ihug.co.nz> better 
> in Java.

Until you provide a design document you may wait for a while. Asking for
people to work off that link is to ask them to do a low-level port of
your Python solution (which may be overly elaborate for the problem) to
Java, without knowing the specifics of the problem. You'd be asking _us_
to do what you just now claimed is a "prevaricating strawman".

This is the only example you can think of - evidently one where you
yourself haven't tried to express it in Java - where iterators in Java
are giving you a hard time? Even hypothetically maybe perhaps?

AHS
-- 
That's not the recollection that I recall...All this information is
certainly in the hands of the auditor and we certainly await his report
to indicate what he deems has occurred.
-- Halifax, Nova Scotia mayor Peter Kelly, who is currently deeply in
the shit
0
4/4/2011 10:04:37 AM
On 11-04-04 01:05 AM, Lawrence D'Oliveiro wrote:
> In message <ct9mp.1376$YL5.219@newsfe05.iad>, Arved Sandstrom wrote:
> 
>> On 11-04-03 09:49 PM, Lawrence D'Oliveiro wrote:
>>
>>> In message <dt6mp.2629$0r7.144@newsfe12.iad>, Arved Sandstrom wrote:
>>>
>>>> I'm not interested in a novice explanation like "I can solve this
>>>> problem like this in Python, and when I try to translate it line-by-line
>>>> into Java I just can't do it"
>>>
>>> Not that I ever asked for a “line-by-line” translation, but keep right on
>>> with your prevaricating strawmen, why don’t you.
>>
>> You've been quibbling about the inability to do things in Java more or
>> less like you can do them in Python, which is why I threw that in.
> 
> Which reminds me, I’m still waiting for someone to show how they can do this
> <http://groups.google.co.nz/groups?selm=ik1en0$gng$1@lust.ihug.co.nz> better 
> in Java.

Until you provide a design document you may wait for a while. Asking for
people to work off that link is to ask them to do a low-level port of
your Python solution (which may be overly elaborate for the problem) to
Java, without knowing the specifics of the problem. You'd be asking _us_
to do what you just now claimed is a "prevaricating strawman".

This is the only example you can think of - evidently one where you
yourself haven't tried to express it in Java - where iterators in Java
are giving you a hard time? Even hypothetically maybe perhaps?

AHS
-- 
That's not the recollection that I recall...All this information is
certainly in the hands of the auditor and we certainly await his report
to indicate what he deems has occurred.
-- Halifax, Nova Scotia mayor Peter Kelly, who is currently deeply in
the shit
0
4/4/2011 10:06:11 AM
In message <nKgmp.2643$0r7.2582@newsfe12.iad>, Arved Sandstrom wrote:

> On 11-04-04 01:05 AM, Lawrence D'Oliveiro wrote:
>
>> In message <ct9mp.1376$YL5.219@newsfe05.iad>, Arved Sandstrom wrote:
>> 
>>> On 11-04-03 09:49 PM, Lawrence D'Oliveiro wrote:
>>>
>>>> In message <dt6mp.2629$0r7.144@newsfe12.iad>, Arved Sandstrom wrote:
>>>>
>>>>> I'm not interested in a novice explanation like "I can solve this
>>>>> problem like this in Python, and when I try to translate it
>>>>> line-by-line into Java I just can't do it"
>>>>
>>>> Not that I ever asked for a “line-by-line” translation, but keep right
>>>> on with your prevaricating strawmen, why don’t you.
>>>
>>> You've been quibbling about the inability to do things in Java more or
>>> less like you can do them in Python, which is why I threw that in.
>> 
>> Which reminds me, I’m still waiting for someone to show how they can do
>> this
>> <http://groups.google.co.nz/groups?selm=ik1en0$gng$1@lust.ihug.co.nz>
>> better in Java.
> 
> Until you provide a design document you may wait for a while.

See, that’s what I mean by lack of agility. It’s not enough to figure out 
what the code does, you need some kind of specification document filled out 
in tedious detail and no doubt signed off in triplicate before you will 
write a single line of code.

And they wonder who I’m referring to when I talk about “corporate code-
cutter drones” ...
0
ldo (2177)
4/4/2011 11:10:04 AM
Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> wrote:
> 
> See, that’s what I mean by lack of agility. It’s not enough to figure out 
> what the code does, you need some kind of specification document filled out 
> in tedious detail and no doubt signed off in triplicate before you will 
> write a single line of code.

No, you just need to tell us what the code is _intended_ to do, since
that will affect how it can best be represented in an implementation.

An actual implementation includes both intended behaviour and 
incidental behaviour, but without knowing which is which any translation
of the implementation to a different language or environment will be
awkward.
 
-- 
Leif Roar Moldskred
0
leifm1143 (162)
4/4/2011 11:20:57 AM
On 04/04/2011 12:05 AM, Lawrence D'Oliveiro wrote:
> Which reminds me, I’m still waiting for someone to show how they can do this
> <http://groups.google.co.nz/groups?selm=ik1en0$gng$1@lust.ihug.co.nz>  better
> in Java.

public void dumpToCSV(Writer out, Connection conn) throws IOException {
   Statement stmt = conn.createStatement();
   ResultSet res = stmt.executeQuery(query);
   FormattedResulter.printCSV(res, out);
}

I'm sure somebody essentially wrote the class that does the last line 
for me, which, quite frankly, is correct enough given the information 
you've provided. If you cry foul, I'd like to point out that you gave 
only a very vague description of what goes on in the python code, plus 
you've clearly used other libraries in your own code.

-- 
Beware of bugs in the above code; I have only proved it correct, not 
tried it. -- Donald E. Knuth
0
Pidgeot18 (1520)
4/4/2011 11:58:14 AM
On 4/4/2011 4:10 AM, Lawrence D'Oliveiro wrote:
> In message<nKgmp.2643$0r7.2582@newsfe12.iad>, Arved Sandstrom wrote:
>
>> On 11-04-04 01:05 AM, Lawrence D'Oliveiro wrote:
>>
>>> In message<ct9mp.1376$YL5.219@newsfe05.iad>, Arved Sandstrom wrote:
>>>
>>>> On 11-04-03 09:49 PM, Lawrence D'Oliveiro wrote:
>>>>
>>>>> In message<dt6mp.2629$0r7.144@newsfe12.iad>, Arved Sandstrom wrote:
>>>>>
>>>>>> I'm not interested in a novice explanation like "I can solve this
>>>>>> problem like this in Python, and when I try to translate it
>>>>>> line-by-line into Java I just can't do it"
>>>>>
>>>>> Not that I ever asked for a “line-by-line” translation, but keep right
>>>>> on with your prevaricating strawmen, why don’t you.
>>>>
>>>> You've been quibbling about the inability to do things in Java more or
>>>> less like you can do them in Python, which is why I threw that in.
>>>
>>> Which reminds me, I’m still waiting for someone to show how they can do
>>> this
>>> <http://groups.google.co.nz/groups?selm=ik1en0$gng$1@lust.ihug.co.nz>
>>> better in Java.
>>
>> Until you provide a design document you may wait for a while.
>
> See, that’s what I mean by lack of agility. It’s not enough to figure out
> what the code does, you need some kind of specification document filled out
> in tedious detail and no doubt signed off in triplicate before you will
> write a single line of code.
>
> And they wonder who I’m referring to when I talk about “corporate code-
> cutter drones” ...

You will never get fluent in Java if you think Python code is a
reasonable specification for your Java code.

This is a problem I've seen many times in people moving from language to
language. Every language has its own idioms, its own ways of expressing
things. Translation from code in language X to code in language Y leads
to very stilted, awkward code in Y. In effect, the code is written in a
dialect of Y that contains only those features of Y that correspond
closely to features of X. Such a dialect can be very frustrating.

It is not unique to Python and Java. I've seen it, for example, in
people moving from assembly language to C. I expect it would happen to
someone who had got too locked in on Java who tried to write Python code
from Java code, rather than by finding out what the code is intended
to achieve.

I've sometimes had to try to reconstruct a specification from code, but
it is a messy process, liable to include things that are not required
and miss other requirements. Why do that, when there is someone who
presumably knows exactly what it is meant to do?

Having a design document other than the code itself does not mean
"filled out in tedious detail and no doubt signed off in triplicate". It
means having one at about the level of detail you would have had in your
own mind before writing the Python code.

I do not think that you will be happy with Java if your main criterion
for good code is short code. Java's main advantages to my mind are
readability, portability, and a tendency to catch typos at compile time.
It is not a compact language.

Patricia
0
pats (3556)
4/4/2011 12:58:40 PM
On Mon, 04 Apr 2011 06:20:57 -0500, Leif Roar Moldskred
<leifm@dimnakorr.com> wrote:

>An actual implementation includes both intended behaviour and 
>incidental behaviour, but without knowing which is which any translation
>of the implementation to a different language or environment will be
>awkward.
And all too often the actual implementation omits intended behaviour
as well.

rossum

0
rossum48 (719)
4/4/2011 2:22:52 PM
On 04/04/2011 7:10 AM, Lawrence D'Oliveiro wrote:
> In message<nKgmp.2643$0r7.2582@newsfe12.iad>, Arved Sandstrom wrote:
>> Until you provide a design document you may wait for a while.
>
> See, that’s what I mean by lack of agility. It’s not enough to figure out
> what the code does, you need some kind of specification document filled out
> in tedious detail and no doubt signed off in triplicate before you will
> write a single line of code.

I wouldn't have phrased it Arved's way, but I'd ask a similar question. 
  It's unlikely that directly translating a piece of code from one 
language to another will give you the best way of solving "the problem" 
in the 2nd language.  Many of us have experience writing code in 
multiple different languages, and have learned that one solves problems 
in different ways depending on what facilities the language provides.

We need to know what "the problem" is that you're trying to solve in a 
particular way in the 1st language.  It's nothing to do with being 
corporate drones: it's about knowing from long experience that 
understanding what someone else is talking about takes work on both sides.
0
dalamb (189)
4/4/2011 10:41:20 PM
On 04/04/2011 7:58 AM, Joshua Cranmer wrote:
> On 04/04/2011 12:05 AM, Lawrence D'Oliveiro wrote:
>> Which reminds me, I’m still waiting for someone to show how they can
>> do this
>> <http://groups.google.co.nz/groups?selm=ik1en0$gng$1@lust.ihug.co.nz>
>> better
>> in Java.
>
> public void dumpToCSV(Writer out, Connection conn) throws IOException {
> Statement stmt = conn.createStatement();
> ResultSet res = stmt.executeQuery(query);
> FormattedResulter.printCSV(res, out);
> }
>
> I'm sure somebody essentially wrote the class that does the last line
> for me, which, quite frankly, is correct enough given the information
> you've provided. If you cry foul, I'd like to point out that you gave
> only a very vague description of what goes on in the python code, plus
> you've clearly used other libraries in your own code.
>

Sigh.  It would be perfectly fair for Lawrence to ask what the body of 
printCSV looks like, if that's where the core iteration functionality 
belongs (I haven't and won't read the python code 'cause I'm a novice in 
that language).
0
dalamb (189)
4/4/2011 10:46:52 PM
Patricia Shanahan wrote:
> You will never get fluent in Java if you think Python code is a
> reasonable specification for your Java code.
>
> This is a problem I've seen many times in people moving from language to
> language. Every language has its own idioms, its own ways of expressing
> things. Translation from code in language X to code in language Y leads
> to very stilted, awkward code in Y. In effect, the code is written in a
> dialect of Y that contains only those features of Y that correspond
> closely to features of X. Such a dialect can be very frustrating.
>
> It is not unique to Python and Java. I've seen it, for example, in

It's not even unique to computer languages.

> people moving from assembly language to C. I expect it would happen to
> someone who had got too locked in on Java who tried to write Python code
> from Java code, rather than by finding out what the code is intended
> to achieve.
>
> I've sometimes had to try to reconstruct a specification from code, but
> it is a messy process, liable to include things that are not required
> and miss other requirements. Why do that, when there is someone who
> presumably knows exactly what it is meant to do?
>
> Having a design document other than the code itself does not mean
> "filled out in tedious detail and no doubt signed off in triplicate". It
> means having one at about the level of detail you would have had in your
> own mind before writing the Python code.
>
> I do not think that you will be happy with Java if your main criterion
> for good code is short code. Java's main advantages to my mind are
> readability, portability, and a tendency to catch typos at compile time.
> It is not a compact language.

There is a perhaps apocryphal tale of an early natural-language translation 
program taking "out of sight, out of mind" from English to Russian, then back 
to English as "invisible and crazy".

-- 
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg
0
noone7 (4050)
4/6/2011 7:34:48 PM
On Wed, 06 Apr 2011 15:34:48 -0400, Lew <noone@lewscanon.com> wrote:

>There is a perhaps apocryphal tale of an early natural-language translation 
>program taking "out of sight, out of mind" from English to Russian, then back 
>to English as "invisible and crazy".
"Invisible idiot"

rossum

0
rossum48 (719)
4/7/2011 9:22:16 AM
In message <M-SdnY_NR6QUXQTQnZ2dnUVZ_qidnZ2d@earthlink.com>, Patricia 
Shanahan wrote:

> You will never get fluent in Java if you think Python code is a
> reasonable specification for your Java code.

I did C++ and TCL before I did Python. I did Perl and Java before that. And 
C before that.

I am as fluent in Java as I want to be—the main learning curve right now is 
the Android APIs. The day I can rely on most Android devices to have a 
Python implementation built-in, guess what I’ll be doing...

> I do not think that you will be happy with Java if your main criterion
> for good code is short code.

My criterion is not short code, but MAINTAINABLE code. Data-driven code is 
best: then you can usually make changes just to data tables, with minimal 
need to change any actual code. This needs a language that can easily 
construct elaborate data structures, preferably with a functional notation.

That Python example I posted illustrates this: it needs to pull out a long 
list of fields from one table. But any change to that list of fields only 
needs to be made in one place; all the rest of the code for constructing the 
query and formatting the output will automatically adjust to that.
0
ldo (2177)
5/5/2011 2:32:56 AM
Reply:

Similar Artilces:

java.lang.ExceptionInInitializerError: java.lang.ArrayIndexOutOfBoundsException
Hi, I am new to DB2. I am getting this error while loading the DB2Driver. I don't have any idea about where i might have gone wrong. please help me. Below is the stack trace. Stack Trace: java.lang.ExceptionInInitializerError: java.lang.ArrayIndexOutOfBoundsException at COM.ibm.db2.jdbc.app.DB2Driver.SQLAllocEnv(Native Method) at COM.ibm.db2.jdbc.app.DB2Driver.<init>(DB2Driver.java:245) at COM.ibm.db2.jdbc.app.DB2Driver.<clinit>(DB2Driver.java:130) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Cla...

java.lang.StringIndexOutOfBoundsException: String index out of range: 23 at java.lang.String.charAt(String.java:460)
Hi All I am having the torque3.1.jar and postgresql-7.4. I have compiled the new jdbc driver called as postgresql.jar and have placed it in the lib directory from where the ant scripts catch the jars. Whenever i try to access through torque gestList = BaseGestlistPeer.doSelect(new Criteria()); this error arises java.lang.StringIndexOutOfBoundsException: String index out of range: 23 at java.lang.String.charAt(String.java:460) at org.postgresql.jdbc2.ResultSet.toTimestamp(ResultSet.java:1653) at org.postgresql.jdbc2.ResultSet.getTimestamp(ResultSet.java...

java.lang.Set with elements of type java.lang.Set
Roughly I do something along the lines of: Set set = new HashSet(); Set elem = new HashSet(); set.add(elem); // now we change the elem and add it again to the set elem.add(some object here); set.add(elem); I found out the hard way that 'set' may now contain 'elem' either once or twice, the reason being that 'elem.add()' changes the hashCode of elem such that it is not noticed that it is in 'set' already on the 2nd 'set.add()'. Question: What I would actually want is an IdentityHashSet() set = new IdentityHashSet() but this does not...

to use import java.lang.* or import java.lang.Math or none at all?
Hi guys, i knew that by default all java.lang classes will be imported by the compiler during compilation. but, to make it easier for the computer, should i specify which class i really will be using? does this action will boost the performance during compilation and runtime or not a matter at all? the answer to this post will definitely affect my programming style in the future when i'm considering "to import or not to import"... hmm,,, thanks in advance. JPractitioner wrote: > i knew that by default all java.lang classes will be imported by the > compiler during compilation. but, to make it easier for the computer, > should i specify which class i really will be using? does this action > will boost the performance during compilation and runtime or not a > matter at all? Whether and how you import classes has exactly zero effect at runtime. Imports (with or without wildcards) are only a kind of abbreviation provided by the compiler to save us the effort of typing in fully-qualified type names every time. In theory explicit importing should make compilation faster -- by a very tiny amount. I've never heard anyone claim that they've even managed to measure a difference let alone found a case where it made a practical difference. So the question comes down to how to write your code for maximum clarity. One school of thought asserts that you should always import each class explicitly (rather than by a wildcard). There's a fai...

Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object
I downloaded jdk-6u7-solaris-sparcv9.tar.Z and installed it by these commands: # zcat jdk-6u7-solaris-sparc.tar.Z | tar -xf - # pkgadd -d . SUNWj6rtx SUNWj6dvx SUNWj6dmx # /usr/jdk/instances/jdk1.6.0/bin/sparcv9/java -version Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object # ls /usr/jdk/instances/ jdk1.5.0 jdk1.6.0 # uname -a SunOS sun1 5.10 Generic sun4u sparc SUNW,Sun-Blade-2500 Please help to fix the error. Thanks. TsanChung wrote: > I downloaded jdk-6u7-solaris-sparcv9.tar.Z and installed it by these > commands: > # zcat jdk-6u7-so...

Java in Java
Is it possible to download a Java app (applet etc?) and run it inside a desktop Java app? -- Dirk http://www.transcendence.me.uk/ - Transcendence UK http://www.theconsensus.org/ - A UK political party http://www.onetribe.me.uk/wordpress/?cat=5 - Our podcasts on weird stuff Dirk Bruere at NeoPax wrote: > Is it possible to download a Java app (applet etc?) and run it inside a > desktop Java app? > Quite likely, but you won't necessarily get the same security model, unless you were careful about it. -- Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/&g...

Error occurred during intialization of VM java/lang/NoClassDefFoundError: java/lang/Object
Good day to all, I have installed the j2se/netbeans binary bundle on red hat 9. I can run everything perfectly as root but when I try to compile with any other user I get: Error occurred during intialization of VM java/lang/NoClassDefFoundError: java/lang/Object When I saw this it seemed like a permissions problem but I checked the permissions and everything seemed fine. All users have execute permissions of javac and java. I have read other threads dealing with the same or similar problem but have not reached any solution yet. I would appreciate if anyone that has run into this type o...

Java Java
Have my first Open Source Linux Java Project. Working on a second right now. Coming out with a distro called OPEN*WINDOWS. It will be at www.black-and-company.com tab wrote: > Have my first Open Source Linux Java Project. > Working on a second right now. > > Coming out with a distro called OPEN*WINDOWS. > > It will be at www.black-and-company.com > Wasn't that the whole point of Lindows? Oh, right, we didn't care for that either. tab wrote: > Have my first Open Source Linux Java Project. > Working on a second right now. > > Coming out with a ...

java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
Hi, I'm trying to use the httpclient within Jython (see http://jakarta.apache.org/commons/httpclient/ for more information on the httpclient). My Jython version is: Jython 2.1 on java1.4.2_04 (JIT: null) My Java version is: java version "1.4.2_04" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode) My CLASSPATH includes: jdom.jar xerces.jar jython.jar jt400.jar log4j-1.2.8.jar commons-httpclient-2.0.jar When I just try to perform the import statements from example code I get the error pasted below....

CheckBox in Column of JTable: Exception: java.lang.String cannot be cast to java.lang.Boolean
Hello, I have discovered a hidden error. My project was working for awhile, but then I started to get the below error. My error comes from the fact that I'm using a checkbox in a jtable, and I'm using the below "getColumnClass". Thank you, compile: run: Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean at javax.swing.JTable$BooleanRenderer.getTableCellRendererComponent(JTable.java:5412) at javax.swing.JTable.prepareRenderer(JTable.java:5735) at javax.swing.plaf.basic.BasicTableU...

warning: [deprecation] in java.util.Date(java.lang.String) has been deprecated
Dear Java Programmers, When compiling my Java program I get the following warning: "warning: [deprecation] in java.util.Date(java.lang.String) has been deprecated" on for example this statement: new Date("09/23/2003") The code is used to generate the dates on a webpage. Depending on the language of the webpage the generated format is different. For example English (see "Date" and "Choose publication" on the page opened): http://home.scarlet.be/kenya-belgium/list_5_en/a_kenyan_birthday_party_and_a_belgian_birthday_party.html French: http://home.scarlet....

modifying java.lang.String.java
Hi, I'm trying to modify java.lang.String.java and add the modified String.class to rt.jar [THIS IS FOR MYSELF ONLY AND WILL NOT BE DEPLOYED]. I cannot add "private final boolean tainted[] = new boolean[5];" to String.java. If I do, it still compiles and I can add it to rt.jar and compile a test program against it. However, the JVM crashes with a strange message: java.lang.IllegalArgumentException: name can't be empty at java.security.BasicPermission.init(Unknown Source) at java.security.BasicPermission.<init>(Unknown Source) at java....

XML-RPC
Hello, I am getting an error "XML-RPC - java.lang.ClassCastException: java.util.Date" when I call the "XmlRpcClient" execute method. I believe the underlying classes are having trouble parsing the result from the time.xmlrpc.com/RPC2:80 XML-RPC service. I apologize that I could not navigate the Apache bug reporting and search system. I hope someone can recognize what is up with this. Thank you in advance for any help, Michael import java.util.Vector; import java.util.Hashtable; import org.apache.xmlrpc.*; public class GetTime { private final static String serv...

Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object (ant/tomcat/spring)
Hi, I've been trying to get Spring working with ant and tomcat. Ant was building just fine, but I came in today and tried to build it and got this: Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object ?!?! Makes no sense to me. There _is_ an older version of java installed on my machine; but JAVA_HOME and ANT_HOME are set to the correct paths, and <which java>and <java -version> produce the correct version. Any help would greatly alleviate my frustration! Thanks in advance... Courtney ...

Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object (ant/tomcat/spring)
Hi, I've been trying to get Spring working with ant and tomcat. Ant was building just fine, but I came in today and tried to build it and got this: Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object ?!?! Makes no sense to me. There _is_ an older version of java installed on my machine; but JAVA_HOME and ANT_HOME are set to the correct paths, and <which java>and <java -version> produce the correct version. Any help would greatly alleviate my frustration! Thanks in advance... Courtney ...

Poll: Is a Java Method an Instance of the Java Class java.lang.reflect.Method? Please reply with YES or NO.
Hi, Poll: Is a Java Method an Instance of the Java Class java.lang.reflect.Method? Please put YES or NO as the first word in your reply. Add comments after it if you wish. I'll make a YES/NO count after some time. Kind regards, Paka Paka Small wrote: > Poll: Is a Java Method an Instance of the Java Class > java.lang.reflect.Method? It's not subject to vote. It's defined by the language. You might as well ask, "Is 'int' a primitive or a reference type?". Your vote will not change reality. > Please put YES or NO as the first word in your reply. Add c...

java.lang.IllegalStateException: No Java compiler available
tearing my hair out on this one.Thuis started as an upgrade issue till i realised that my un-usedtomcat5 installation didn't work either with my test jsp.I have, in desparation, un-installed all java / tomcat libs and re-installed only those required to get thetomcat6-6.0.14-1jpp.noarch.rpm (and the band-waggon) loadedfirst I installed java_app_platform_sdk-5_02-linux.binthis shows (after I set alternatives to point to the /opt/SDK/jdkdirecrtory)[root@squirrel ~]# javac -versionjavac 1.6.0java shows the same.I have set the following in profileCLASSPATH=$JDKHOME:$JDKHOME/lib/tools.jarJAVA_H...

java.lang.OutOfMemoryError: Java heap space
Is there any free utilities I can use to view the memory used by all objects so I can track down the offending code? thanks Tim Maybe JConsole will help you out enough. Cheers. Opalinski opalpa@gmail.com http://www.geocities.com/opalpaweb/ Thanks, I figured out how to use hprof and it seems that something went nuts around date formatting - this trace is repeat hundereds of times... sun.text.resources.DateFormatZoneData.getContents(DateFormatZoneData.java:164) sun.text.resources.DateFormatZoneData.loadLookup(DateFormatZoneData.java:144) TRACE 304641: java.text.DateFormat$Field.&l...

java.lang.IncompatibleClassChangeError when running java tests
Hi, When execute the junit test we get: java.lang.IncompatibleClassChangeError at se.company.wcdma.rbs.boam.pms.impl.RBScanner.preperAndPush(RBScanner.java:526) at se.company.wcdma.rbs.boam.pms.impl.RBScanner.scan(RBScanner.java:766) at se.company.wcdma.rbs.boam.mao.rmo.iub.tb.sut.IubDataStreamMoImplTest.testNewCounters(IubDataStreamMoImplTest.java:254) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at ...

java.io.File to java.lang.String
What's the best way to get the contents of a file represented by ajava.io.File object into a String? Benjamin wrote:> What's the best way to get the contents of a file represented by a> java.io.File object into a String?> You don't specify what you consider best so how about simple as best? Now for my curiosity, why would you want to do this?import java.io.*;public class test { public static void main(String[] args) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); File f = new File(args[0]); FileInputStream fis = new ...

How to define java.lang.Object using java IDL
Hi all, I have a function like: boolean method(java.lang.Object param). How can I define this using java IDL? In another words, I need to pass an instance of java.lang.Object from Client to Server using CORBA. Is this possible? I would be nice simply to typecast the Object at Server-side into whatever needed. How about without typecasts, is this possible in any way, for example using a helper function like: java.lang.Object anyToJavaLangObject(Any value) Code examples ?!? Thanks in advance Juha Rossi ...

java.lang.UnsatisfiedLinkError: no lsxbe in java.library.path
Hello i got following exception: java.lang.UnsatisfiedLinkError: no lsxbe in java.library.path My source code looks like the examples of the Notes homepage. import lotus.domino.*; public class Main extends NotesThread{ public static void main(String argv[]){ System.err.println(System.getProperty("java.library.path")); // System.load("C:/Programme/lotus/notes/lsxbe.dll"); Main t = new Main(); t.start(); } public void runNotes(){ try{ Session s = NotesFactory.createSession("localhos...

java.lang.SecurityException: Prohibited package name: java
I created an applet which just attaches an extended TransferHandler to a gui and it worked fine on my computer... Online however I got this error: java.lang.SecurityException: Prohibited package name: java at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at sun.applet.AppletClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.applet.AppletClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.applet.AppletClassLoader.loadCode(Unkno...

User-defined java objects : java.lang.OutOfMemoryError
Hello, I am interfacing Java with Matlab, using my proper Java Classes. After 3 runs I have the following message : java.lang.OutOfMemoryError and of course my application crash. I tried to clear the objects I have created, but not successfully. The memory used by Matlab stays reasonable (given by command 'whos' when running). So that I don't understand where do the memory fail : is that from the Java Virtual Machine ? How can I resolve this problem ? Some help would be really appreciated... Thank's ...

Web resources about - java.lang vs java.util - comp.lang.java.programmer

Java - Wikipedia, the free encyclopedia
This article is about the Indonesian island. For the programming language, see Java (programming language) . For other uses, see Java (disambiguation) ...

Indonesian Air Force plane crashes in residential East Java
An Indonesian Air Force plane has crashed in East Java.

Good riddance to the Java plugin
... cut down dramatically on the number of computers infected with malicious software. Good news: Oracle says the next major version of its Java ...

Contract Analyst Programmer (JAVA/J2EE/SQL) 160205/AP/541
Defining Technology for Australia's IT Leaders.

Indonesian Air Force plane crashes in residential East Java
An Indonesian Air Force plane has crashed in East Java.

Deal: learn to code in Java and make Android apps for $29
... a variety of different Android-related subjects. Included classes: Learn Android Lollipop Development (& Marshmallow!) The Complete Java Developer ...

Java “RAT-as-a-Service” backdoor openly sold through website to scammers
The JSocket website: open for business on the open Web (at least right now). (credit: Sean Gallagher) A family of Java-based malware that has ...

Oracle issues an emergency patch to Java for Windows
Security problems are not new to Java, though it is, admittedly, not the only platform that suffers from these problems. Now Oracle has acknowledged ...

Malaysian white coffee is NYC's hottest new java - Business Insider
Kopitiam, a Malaysian café, is making white coffee, a Malaysian favorite that is still basically unknown in the US.

Oracle plans to kill an attacker's favorite: the Java browser plug-in
Oracle will retire the Java browser plug-in, frequently the target of Web-based exploits, about a year from now. Remnants, however, will likely ...

Resources last updated: 2/21/2016 6:54:55 AM