java.lang vs java.util

  • Thread starter Lawrence D'Oliveiro
  • Start date
L

Lew

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.
 
R

Roedy Green

L

Lawrence D'Oliveiro

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.
 
A

Arved Sandstrom

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.


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
 
D

David Lamb

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?
 
M

Mike Schilling

Arved Sandstrom said:
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.)
 
J

Joshua Cranmer

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.
 
L

Lawrence D'Oliveiro

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.
 
L

Lawrence D'Oliveiro

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...
 
D

David Lamb

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".
 
D

David Lamb

Why? They introduced other changes in java.lang.


Python shows how important iterators can be as a fundamental language
concept.

Iterators as a fundamental language construct have been around since the
'70s.
 
A

Arved Sandstrom

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) 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
 
A

Arved Sandstrom

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
 
L

Lawrence D'Oliveiro

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.
 
A

Arved Sandstrom

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
 
A

Arved Sandstrom

Which reminds me, I’m still waiting for someone to show how they can do this
<http://groups.google.co.nz/[email protected]> 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
 
A

Arved Sandstrom

Which reminds me, I’m still waiting for someone to show how they can do this
<http://groups.google.co.nz/[email protected]> 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top