StringBuilder Difficulties

M

markspace

var a = new MyVeryLongClassName<Foo,BarBaz>();

which appears even better than the Java 7 <> (diamond) operator. Note
Gosu supports explicit variable type declarations, also.


Right. I understand it's possible. I just don't think its necessary.
The arguments presented just aren't enough to make me run off and switch
languages, or complain to Oracle about it. I don't think any of these
suggestions where even offered to Project Coin a while back.

I understand too that some of you all might just be making conversation
about Java. Fair enough. But understand I'm just making conversation
back, and for the most part my conversation has been to shrug and say
it's not really convincing.
 
G

Gene Wirchenko

[snip]

Oh, I asked about that. One apparently can not pass a function
pointer parameter as in C. The ways that were posted involved lookup
every time AFIACS and I judged that it might swamp what I was
measuring (checking if a character were in a set). So, to my chagrin,
I had to go with cut-and-paste.

Without experimenting to find out, of course ....

You are putting the cart before the horse.

THE WHOLE POINT of this exercise was experimentation to test the
speed of the lookup. Until I got the code I was asking about running,
of course, I would not know.
Maybe I misunderstood what you meant by "lookup" above --
I understood you to be referring to whatever has to be done
to find the method to be called, as opposed to looking up
individual characters in a list/set. As far as I can tell,

It was the latter.
your benchmark concerns different approaches to the latter,
but assumes that looking up the method (i.e., using the Java
substitute for function pointers) will somehow skew the results
to the point where it shouldn't/can't be used. (You may actually
be right about that, much as it pains me to say so, because all
that duplicate code is, in my opinion and possibly yours as well,
both aesthetically displeasing and a source of potential trouble.)

Well, I only need one. That code will get tossed shortly.
[snip]
I am pretty much past the intro stage and into the pain stage
where there is not so much help.

That people are not willing to offer further help when many of their
previous suggestions have been rejected should not be a total surprise.
<shrug>

My phrase "not so much help" does not refer to this newsgroup.
You can find texts and Websites on starting with Java. There is also
advanced material. In the middle is a sour spot. I am at the low end
of that sour spot.

Ah. Interesting. I don't seem to have a clear memory of how I got
from the beginning level to wherever I am now (intermediate?). I do
remember, though, learning quite a bit from following semi-random
discussions in this newsgroup. But that was, hm, a decade or so ago,
and it's not clear it would still work. <shrug>

In my experience, it is a common pattern. After the beginner
level, there are few tutorials and yet, one does not know enough to
easily blow away the difficulties.

Sincerely,

Gene Wirchenko
 
S

Silvio

I'd like to see some actual examples from actual code, rather than these
obvious straw-man arguments.

Drop it. I spent 10 years programming Java (pre- and post-generics) and
moved to Scala three years ago. It's no contest, believe me.

But as always, comparison of individual language features is pointless
and only gives wrong impressions. One would have to compare a larger
peace of Java and the equivalent Scala code (of good quality and with
enough explanation) to get a good idea of how they compare.

In my experience Scala rewrites of Java code shrink to 25%-50% of the
original size.
In my opinion the result is also much more readable and self-describing
but the amount of logic-per-line-of-code is so much higher that others
feel exactly the opposite way.

To each his own. There is no point in starting another language war, and
I do not think super* was trying to do that.

Gr. Silvio
 
B

blmblm

On 5 Jul 2011 19:12:39 GMT, (e-mail address removed)

[snip]
What I found is that HashSet was noticeably faster on all the
systems where I ran the benchmarks. Unless you need for the set
to be sorted (and it's not apparent from your code that you do),
why not .... ? (I'm curious too about why you chose TreeSet in
the first place. ? )

1) I can output the set in order without having to do anything else.
My real program has a lot of debugging info dumping. (Read as "checks
that I have not done something wrong".)


Ah. Well, yes, then you probably do need a SortedSet, though
considering that you initially build the set from a string that's in
order, maybe you could use that (the string) instead. Just sayin',
maybe.

2) When I read "hash", I think "collision", and I get nervous.
Nothing I read reassured me that that could not happen.


Why would that make you nervous? If you're worried about
correctness, um, as far as I know hash tables are supposed to
deal with collisions in some way that preserves the overall "map"
semantics. Performance may suffer if there are a lot of collisions,
but -- benchmark on the system(s) of interest and check?

3) I had to pick something. If it works, I can change it later. If
it does not, I have not solved my problem yet. The former is safer.


Sure. Then again, if you were only concerned about getting something
that works, why try various alternatives .... <shrug>
 
M

markspace



No. Your buddy there is making ridiculous claims and he's got nothing
to back them up.

I spent 10 years programming Java (pre- and post-generics) and
moved to Scala three years ago. It's no contest, believe me.


I don't care. I've got 20 years experience in this industry with nearly
every type of programming language you can imagine and my fingers
haven't fallen off yet. Look, if you like Scala better, bully for you.
But I haven't seen anything yet to convince me to change, and this
thread on that subject has been nothing but hyperbole and FUD.

I have no reason to change, and "drop it" surely is not a logical
argument that's going to cause me to change languages, or even consider it.

But as always, comparison of individual language features is pointless


This much I will agree on. I was hoping to find some actual
information. So far that is 100% lacking.

In my experience Scala rewrites of Java code shrink to 25%-50% of the
original size.


Just curious: binary or source? I'm unclear which you mean.

To each his own. There is no point in starting another language war, and
I do not think super* was trying to do that.


All he has to do is supply some logical Java examples. In a Java
newsgroup, I think that's on topic.
 
G

Gene Wirchenko

On 5 Jul 2011 19:12:39 GMT, (e-mail address removed)

[snip]
What I found is that HashSet was noticeably faster on all the
systems where I ran the benchmarks. Unless you need for the set
to be sorted (and it's not apparent from your code that you do),
why not .... ? (I'm curious too about why you chose TreeSet in
the first place. ? )

1) I can output the set in order without having to do anything else.
My real program has a lot of debugging info dumping. (Read as "checks
that I have not done something wrong".)


Ah. Well, yes, then you probably do need a SortedSet, though
considering that you initially build the set from a string that's in
order, maybe you could use that (the string) instead. Just sayin',
maybe.

I set the string value that way so that the binary search would
work.
Why would that make you nervous? If you're worried about
correctness, um, as far as I know hash tables are supposed to
deal with collisions in some way that preserves the overall "map"
semantics. Performance may suffer if there are a lot of collisions,
but -- benchmark on the system(s) of interest and check?

I would need to know what the behaviour is supposed to be. I
have something that works for now. Optimisation comes after getting
it working.
Sure. Then again, if you were only concerned about getting something
that works, why try various alternatives .... <shrug>

1) Just in case there was a BIG difference. 2) To learn more
about Java. At some point though, I have to do something useful with
it.

My preprocessor is shaping up nicely. I have to write the symbol
define command code, handle the include command, and handle output to
a file. That is about it. Which means that there are probably only
about three other things that I will come up.

Sincerely,

Gene Wirchenko
 
S

Stefan Robacki

Silvio said:
Drop it. I spent 10 years programming Java (pre- and post-generics) and
moved to Scala three years ago. It's no contest, believe me.

But as always, comparison of individual language features is pointless
and only gives wrong impressions. One would have to compare a larger
peace of Java and the equivalent Scala code (of good quality and with
enough explanation) to get a good idea of how they compare.

In my experience Scala rewrites of Java code shrink to 25%-50% of the
original size.
In my opinion the result is also much more readable and self-describing
but the amount of logic-per-line-of-code is so much higher that others
feel exactly the opposite way.

To each his own. There is no point in starting another language war, and
I do not think super* was trying to do that.

Gr. Silvio

You are trolled, Both.

Meet Paul Derbyshire, forever nefarious as Seamus McRae
the Vietnam veteran who threatened to sue any critic of
his postings.
Paul is also of a bother right now in comp.lang.lisp
I have posted the signal there.

From: KitKat <[email protected]>
Newsgroups: comp.lang.java.programmer
Subject: Re: Why "lock" functionality is introduced for all the objects?
Date: Tue, 05 Jul 2011 15:30:17 -0400
Organization: Nestle
Lines: 52
Message-ID: <[email protected]>

The history for this chap is found easily on
Google Groups, there is no pain in knowing him.
The fellow is quite crazy harmless in Usenet.

http://groups.google.com/groups/search?as_q=derbyshire+
carleton&as_epq=&as_oq=&as_eq=&num=100&scoring=&lr=&
as_sitesearch=&as_qdr=&as_mind=1&as_minm=1&as_miny=
2011&as_maxd=1&as_maxm=1&as_maxy=2011&as_ugroup=&
as_usubject=&as_uauthors=&safe=off

derbyshire carleton
Results 1 - 100 of about 5,730 for derbyshire carleton.

I have seen many lists of names put to Paul Derbyshire
as the clown poster. I have built my own for the
close use of others. Exists there are many more.

Nebulous <[email protected]>
Jerry Gerrone <[email protected]>
Extravagan <[email protected]>
De Lurker <[email protected]>
Sulfide Eater <[email protected]>
Series Expansion <[email protected]>
"Spock" <[email protected]>
Orange Green <[email protected]>
Willy Wonka <[email protected]>
<supercalifragilisticexpialadiamaticonormalizeringelimatisticantations@averylongandannoyingdomainname.com>
Zapotec <[email protected]>
Nancy 4 <[email protected]>
thoolen <[email protected]>
3x+rav4gan <[email protected]>
KitKat <[email protected]>
Seamus MacRae <[email protected]>
 
S

Silvio

No. Your buddy there is making ridiculous claims and he's got nothing to
back them up.

Well, his remark that there are languages that demonstrate that static
typing does not have to cause so much verbosity as Java does is quite
easy to back up and he did name some examples.
I don't care. I've got 20 years experience in this industry with nearly
every type of programming language you can imagine and my fingers
haven't fallen off yet. Look, if you like Scala better, bully for you.
But I haven't seen anything yet to convince me to change, and this
thread on that subject has been nothing but hyperbole and FUD.

Who said anything about you changing languages? The only thing super*
said was that he disagreed with your statement about static typing.
I have no reason to change, and "drop it" surely is not a logical
argument that's going to cause me to change languages, or even consider it.

I did not mean that in a demeaning way. I simply meant that saying Java
is reasonably compact in general in comparison to said languages is a
stand that is hard to defend.

I am not urging anyone to change anything. Besides all the languages on
the side I moved from C to C++ in '85 and then moved to Java in '97, and
finally to Scala. Nothing religious, simply a matter of either a "better
for me" language for the same platform (C -> C++, Java -> Scala) and one
move to a different platform (C++ -> Java).
This much I will agree on. I was hoping to find some actual information.
So far that is 100% lacking.




Just curious: binary or source? I'm unclear which you mean.

Not binary, there the inverse relation seems to exist. Scala source code
is 2-4 times smaller, the binary output could easily be 2 times bigger.
But I have not thoroughly verified that since I really care little about
binary size as long as it stays within reasonable ranges.
All he has to do is supply some logical Java examples. In a Java
newsgroup, I think that's on topic.

I partly agree but I am not sure a newsgroup is a very good place to
exchange and discuss large pieces of code.

To be honest, type inference can reduce typing but the impact on size
caused by TI alone is usually not dramatic. However, the mental aspect
of not having to type redundant things like

Map<Int,String> myMap = new Map<Int,String>();
myMap.put(123,"Java");
String myVal = myMap.get(123);

and simply use

val myMap = new Map[Int,String]
myMap(123) = "Scala"
val myVal = myMap(123)

is very important to me. The 'val' keyword implies constants (in the
Java 'const' sense), I could have used 'var' to create a mutable variable.

IMHO, type inference in Scala is mostly important in combination with
other language features. The notational compactness that closures in
Scala can help realize is very much relying on type inference.

That, combined with stuff like mixins, pattern matching and sensible
parametrized types (I always hated Java's generics) made me go for
Scala. I must admit that the more compact syntax in general was my early
attractor.

That's just me, I advice people who are happy with Java to keep on doing
what they are doing.
Not saying you are one off them, but a lot of Java programmers react
like being stung by a bee as soon as someone brings up advantages of a
different JVM language like Scala or Clojure and immediately start
defending Java blindly.

Java is still a valuable workhorse for me. Our legacy product (which
most of our customers currently still use) needs to be maintianed and is
all Java.
For new stuff I personally prefer a different JVM language.

Cheers,

Silvio
 
T

thoolen

On 06/07/2011 5:55 AM, eye wrote:
1> Newsgroups: comp.lang.java.programmer

1> <[email protected]> posted as rebuttal of good advice:

What does your classic unsubstantiated and erroneous claim have to do
with Java, eye? Silvio's post is itself good advice and quite
reasonable, eye.

1> There is no short "polite" way to put this and even more so
1> to a person coming out of Amsterdam,you guys have a
1> reputation for a thick skull and a short wick/fuse
1> in Usenet circles :-/

What does your racist opinion have to do with Java, eye?

1> I am telling you it would be most wise for you to
1> take very keen notice of the posts warning of
1> Derbyshire's activity in groups, even go to
1> some trouble of verifying the information
1> from links.. if you have the skills.

Who is "Derbyshire", eye? There is nobody in this newsgroup using that
alias.

1> Paul is trolling you **and** any other sucker he can rope
1> into his little games.

Who is "Paul", eye? There is nobody in this newsgroup using that alias.

1> You can put that in a Swiss Bank and get credit off it.

What does your money laundering operation have to do with Java, eye?

1> What you can do is STFU when you see the
1> X-Complaints-To: (e-mail address removed) in a post, anywhere.

What does your bad advice have to do with Java, eye?

First you make a slur against the Dutch, then advise killfiling all
users of a particular internet service provider. Suffering from bigotry
problems, eye?

1> At the end of the day that action will help the group
1> you post to and pretty much hundreds of posters in over
1> a dozen groups he haunts, taunting the suckers who
1> believe the post worth a response.

What does your haunting of newsgroups have to do with Java, eye?

1> There is my message.

What does your message have to do with Java, eye? From where I'm sitting
it looks like an off-topic flame and racist incitement to hatred,
targeted at an absentee victim and posted where it's neither welcome nor
relevant, eye.
 
T

thoolen

On 06/07/2011 12:04 AM, Stefan Robacki wrote:
2> Newsgroups: comp.lang.java.programmer

2> You are trolled, Both.

What does your trolling have to do with Java, Robacki?

2> Meet Paul Derbyshire, forever nefarious as Seamus McRae
2> the Vietnam veteran who threatened to sue any critic of his postings.

Who are "Paul Derbyshire" and "Seamus McRae", Robacki? There is nobody
in this newsgroup using either alias.

2> Paul is also of a bother right now in comp.lang.lisp

Who is "Paul", Robacki? There is nobody in this newsgroup using that alias.

2> I have posted the signal there.

What does your classic unsubstantiated and erroneous claim have to do
with Java, Robacki? The only thing you have posted to comp.lang.lisp is
an off-topic troll nearly identical to this one, Robacki.

2> From: KitKat <[email protected]>
2> Newsgroups: comp.lang.java.programmer
2> Subject: Re: Why "lock" functionality is introduced for all the objects?
2> Date: Tue, 05 Jul 2011 15:30:17 -0400
2> Organization: Nestle
2> Lines: 52
2> Message-ID: <[email protected]>

What about KitKat's on-topic post regarding Java object monitors,
Robacki? Unless you mean to point to an example of useful and good-faith
participation in this newsgroup to contrast with your own "contribution"
here of an off-topic troll, Robacki.

2> The history for this chap is found easily on Google Groups, there is no
2> pain in knowing him.

Who is "this chap", Robacki? There is nobody in this newsgroup using
that alias.

2> The fellow is quite crazy harmless in Usenet.

What does your harmless craziness have to do with Java, Robacki?

What does your ridiculously long URL have to do with Java, Robacki?

2> derbyshire carleton
2> Results 1 - 100 of about 5,730 for derbyshire carleton.

What do the names of two English towns have to do with Java, Robacki?

2> I have seen many lists of names put to Paul Derbyshire
2> as the clown poster. I have built my own for the
2> close use of others. Exists there are many more.

Who is "Paul Derbyshire", Robacki? There is nobody in this newsgroup
using that alias.

2> Nebulous <[email protected]>

Who is "Nebulous", Robacki? There is nobody in this newsgroup using that
alias.

2> Jerry Gerrone <[email protected]>

Who is "Jerry Gerrone", Robacki? There is nobody in this newsgroup using
that alias.

2> Extravagan <[email protected]>

Who is "Extravagan", Robacki? There is nobody in this newsgroup using
that alias.

2> De Lurker <[email protected]>

Who is "De Lurker", Robacki? There is nobody in this newsgroup using
that alias.

2> Sulfide Eater <[email protected]>

Who is "Sulfide Eater", Robacki? There is nobody in this newsgroup using
that alias.

2> Series Expansion <[email protected]>

Who is "Series Expansion", Robacki? There is nobody in this newsgroup
using that alias.

2> "Spock" <[email protected]>

Who is "Spock", Robacki? There is nobody in this newsgroup using that
alias. Perhaps you should be looking in the movie theater or on TV
instead of in comp.lang.java.programmer, Robacki.

2> Orange Green <[email protected]>

Who is "Orange Green", Robacki? There is nobody in this newsgroup using
that alias.

2> Willy Wonka <[email protected]>

Who is "Willy Wonka", Robacki? There is nobody in this newsgroup using
that alias. Perhaps you should be looking in the book store instead of
in comp.lang.java.programmer, Robacki.

2> <supercalifragilisticexpialadiamaticonormalizeringelimatisticantati

What does that have to do with Java, Robacki?

2> Zapotec <[email protected]>

Who is "Zapotec", Robacki? There is nobody in this newsgroup using that
alias.

2> Nancy 4 <[email protected]>

Who is "Nancy 4", Robacki? There is nobody in this newsgroup using that
alias.

2> thoolen <[email protected]>

What does my email address have to do with Java, Robacki?

2> 3x+rav4gan <[email protected]>

Who is "3x+rav4gan", Robacki? There is nobody in this newsgroup using
that alias.

2> KitKat <[email protected]>

What does KitKat's email address have to do with Java, Robacki?

2> Seamus MacRae <[email protected]>

Who is "Seamus MacRae", Robacki? There is nobody in this newsgroup using
that alias.
 
S

supercalifragilisticexpialadiamaticonormalizeringe

Ah. Well, yes, then you probably do need a SortedSet, though
considering that you initially build the set from a string that's in
order, maybe you could use that (the string) instead.

Or a LinkedHashFoo of some stripe.
 
E

eye

Well, his remark that there are languages that demonstrate that static
typing does not have to cause so much verbosity as Java does is quite
easy to back up and he did name some examples.

There is no short "polite" way to put this and even more so
to a person coming out of Amsterdam,you guys have a
reputation for a thick skull and a short wick/fuse
in Usenet circles :-/

I am telling you it would be most wise for you to
take very keen notice of the posts warning of
Derbyshire's activity in groups, even go to
some trouble of verifying the information
from links.. if you have the skills.
Paul is trolling you **and** any other sucker he can rope
into his little games. You can put that in a Swiss Bank
and get credit off it.

What you can do is STFU when you see the
X-Complaints-To: (e-mail address removed) in a post, anywhere.
At the end of the day that action will help the group
you post to and pretty much hundreds of posters in over
a dozen groups he haunts, taunting the suckers who
believe the post worth a response.

There is my message.
 
S

supercalifragilisticexpialadiamaticonormalizeringe

Ah. Well, yes, then you probably do need a SortedSet, though
considering that you initially build the set from a string that's in
order, maybe you could use that (the string) instead.

Or a <[email protected]> madness of some stripe.
 
T

thoolen

On 06/07/2011 12:04 AM, Stefan Robacki wrote:
4> Newsgroups: comp.lang.java.programmer

4> You are trolled, Both.

%^#*&^L!&** %^#* trolling %^#*&^L!&** with Java, Robacki?

4> Meet Paul Derbyshire, forever nefarious as Seamus McRae
4> the Vietnam veteran who threatened to sue any critic of his postings.

Who are "Paul Derbyshire" and "Seamus McRae", Robacki? %^#*&^L!&**
in this newsgroup %^#*&^L!&** either alias.

4> Paul is also of a bother right now in comp.lang.lisp

%^#*&^L!&** "Paul", Robacki? %^#*&^L!&** in this newsgroup %^#*&^L!&** that alias.

4> I have posted the signal there.

%^#*&^L!&** %^#* classic unsubstantiated and erroneous claim %^#*&^L!&**
with Java, Robacki? The only thing you have posted to comp.lang.lisp is
an off-topic troll nearly identical to this one, Robacki.

4> From: KitKat <[email protected]>
4> Newsgroups: comp.lang.java.programmer
4> Subject: Re: Why "lock" functionality is introduced for all the objects?
4> Date: Tue, 05 Jul 2011 15:30:17 -0400
4> Organization: Nestle
4> Lines: 52
4> Message-ID: <[email protected]>

What about KitKat's on-topic post regarding Java object monitors,
Robacki? Unless you mean to point to an example of useful and good-faith
participation in this newsgroup to contrast with %^#* own "contribution"
here of an off-topic troll, Robacki.

4> The history for this chap is found easily on Google Groups, there is no
4> pain in knowing him.

%^#*&^L!&** "this chap", Robacki? %^#*&^L!&** in this newsgroup %^#*&^L!&**
that alias.

4> The fellow is quite crazy harmless in Usenet.

%^#*&^L!&** %^#* harmless craziness %^#*&^L!&** with Java, Robacki?

%^#*&^L!&** %^#* ridiculously long URL %^#*&^L!&** with Java, Robacki?

4> derbyshire carleton
4> Results 1 - 100 of about 5,730 for derbyshire carleton.

%^#*Q^$ the names of two English towns %^#*&^L!&** with Java, Robacki?

4> I have seen many lists of names put to Paul Derbyshire
4> as the clown poster. I have built my own for the
4> close use of others. Exists there are many more.

%^#*&^L!&** "Paul Derbyshire", Robacki? %^#*&^L!&** in this newsgroup
%^#*&^L!&** that alias.

4> Nebulous <[email protected]>

%^#*&^L!&** "Nebulous", Robacki? %^#*&^L!&** in this newsgroup %^#*&^L!&** that
alias.

4> Jerry Gerrone <[email protected]>

%^#*&^L!&** "Jerry Gerrone", Robacki? %^#*&^L!&** in this newsgroup %^#*&^L!&**
that alias.

4> Extravagan <[email protected]>

%^#*&^L!&** "Extravagan", Robacki? %^#*&^L!&** in this newsgroup %^#*&^L!&**
that alias.

4> De Lurker <[email protected]>

%^#*&^L!&** "De Lurker", Robacki? %^#*&^L!&** in this newsgroup %^#*&^L!&**
that alias.

4> Sulfide Eater <[email protected]>

%^#*&^L!&** "Sulfide Eater", Robacki? %^#*&^L!&** in this newsgroup %^#*&^L!&**
that alias.

4> Series Expansion <[email protected]>

%^#*&^L!&** "Series Expansion", Robacki? %^#*&^L!&** in this newsgroup
%^#*&^L!&** that alias.

4> "Spock" <[email protected]>

%^#*&^L!&** "Spock", Robacki? %^#*&^L!&** in this newsgroup %^#*&^L!&** that
alias. Perhaps %^#*&^L!&**in the movie theater or on TV
%^#*&^L!&** in comp.lang.java.programmer, Robacki.

4> Orange Green <[email protected]>

%^#*&^L!&** "Orange Green", Robacki? %^#*&^L!&** in this newsgroup %^#*&^L!&**
that alias.

4> Willy Wonka <[email protected]>

%^#*&^L!&** "Willy Wonka", Robacki? %^#*&^L!&** in this newsgroup %^#*&^L!&**
that alias. Perhaps %^#*&^L!&**in the book store %^#*&^L!&**
in comp.lang.java.programmer, Robacki.

4> <supercalifragilisticexpialadiamaticonormalizeringelimatisticantati

%^#*&^L!&** that %^#*&^L!&** with Java, Robacki?

4> Zapotec <[email protected]>

%^#*&^L!&** "Zapotec", Robacki? %^#*&^L!&** in this newsgroup %^#*&^L!&** that
alias.

4> Nancy 4 <[email protected]>

%^#*&^L!&** "Nancy 4", Robacki? %^#*&^L!&** in this newsgroup %^#*&^L!&** that
alias.

4> thoolen <[email protected]>

%^#*&^L!&** my email address %^#*&^L!&** with Java, Robacki?

4> 3x+rav4gan <[email protected]>

%^#*&^L!&** "3x+rav4gan", Robacki? %^#*&^L!&** in this newsgroup %^#*&^L!&**
that alias.

4> KitKat <[email protected]>

%^#*&^L!&** KitKat's email address %^#*&^L!&** with Java, Robacki?

4> Seamus MacRae <[email protected]>

%^#*&^L!&** "Seamus MacRae", Robacki? %^#*&^L!&** in this newsgroup %^#*&^L!&**
that alias.
 
T

thoolen

On 06/07/2011 5:55 AM, eye wrote:
66> Newsgroups: comp.lang.java.programmer

66> <[email protected]> posted as rebuttal of good advice:

%^#*Q^%^#*Q^$*#! classic unsubstantiated and erroneous claim %^#*Q^$*#!
with Java, eye? Silvio's post is itself good advice and quite
reasonable, eye.

66> There is no short "polite" way to put this and even more so
66> to a person coming out of Amsterdam,you guys have a
66> reputation for a thick skull and a short wick/fuse
66> in Usenet circles :-/

%^#*Q^%^#*Q^$*#! racist opinion %^#*Q^$*#! with Java, eye?

66> I am telling you it would be most wise for you to
66> take very keen notice of the posts warning of
66> Derbyshire's activity in groups, even go to
66> some trouble of verifying the information
66> from links.. if you have the skills.

I am "Derbyshire", eye? %^#*Q^$666 in this newsgroup using that
alias.

66> Paul is trolling you **and** any other sucker he can rope
66> into his little games.

%^#*Q^$*#! "Paul", eye? %^#*Q^$666 in this newsgroup %^#*Q^$666

66> You can put that in a Swiss Bank and get credit off it.

%^#*Q^$ %^#*Q^$*#! laundering operation %^#*Q^$*#! with Java, eye?

66> What you can do is STFU when you see the
66> X-Complaints-To: (e-mail address removed) in a post, anywhere.

%^#*Q^%^#*Q^$*#! bad advice %^#*Q^$*#! with Java, eye?

First I make a slur against the Dutch, then ask for killfiling all
users of a particular internet service provider. I suffer from bigotry
problems, yes?

66> At the end of the day that action will help the group
66> you post to and pretty much hundreds of posters in over
66> a dozen groups he haunts, taunting the suckers who
66> believe the post worth a response.

%^#*Q^%^#*Q^$*#! haunting of newsgroups %^#*Q^$*#! with Java, eye?

66> There is my message.

%^#*Q^%^#*Q^$*#! message %^#*Q^$*#! with Java, eye? As I'm sitting
on my ass laughing like an off-topic flame and racist inciting asshole
it is my hatred, targeted at an absentee victim and posted where it's
neither welcome nor relevant. I am expert at this function of madness.
 
T

tholen

1> Newsgroups: comp.os.os2.advocacy

1> Possible, sure. Although the M.O. of "super" doesn't really match
1> Paul's much, imo. Maybe we've trolled even if it's not Paul.

The M.O. of "Stefan Robacki" matches those of Tim Harrison, Sulfide
Eater, Chad Carmichael, Extravagan, Meerkats, Purpleswandir, Heike
Svensson, Derek Yancey, Zxcvbnm, Greg Kelly, Willy Wonka, Nougat
Surprise, Mister Whiskers, John Harbl, Alice, Cthun, Boojum, Katie
Gerrolds, Julie Faramis, Henry Harrison, Nancy 4, and
supercalifragilisticexpialadiamaticonormalizeringelimatisticantations,
markspace. Notice how your follow-up got redirected to
comp.os.os2.advocacy.

1> He's been here under several names. Normally I can spot the
obvious
1> posting style. "Super" was at least half-way cogent; Paul
usually
1> isn't. Also "Super" obviously isn't alone in his feelings on this
subject.

Why not just spot the NNTP-Posting-Host, markspace?

1> Anyway, language comparisons are a bad idea, but Java improvements
are
1> fine with me, as long as they make some sort of sense. I'm still
not
1> conviced this one does make sense, but I'll listen if anyone has
some
1> decent arguments. So far, the arguments have been kinda dreky.

What do those arguments have to do with OS/2, markspace?
 
B

blmblm

On 2 Jul 2011 18:33:52 GMT, (e-mail address removed)

[snip]

Oh, I asked about that. One apparently can not pass a function
pointer parameter as in C. The ways that were posted involved lookup
every time AFIACS and I judged that it might swamp what I was
measuring (checking if a character were in a set). So, to my chagrin,
I had to go with cut-and-paste.

Without experimenting to find out, of course ....

You are putting the cart before the horse.

THE WHOLE POINT of this exercise was experimentation to test the
speed of the lookup. Until I got the code I was asking about running,
of course, I would not know.
Maybe I misunderstood what you meant by "lookup" above --
I understood you to be referring to whatever has to be done
to find the method to be called, as opposed to looking up
individual characters in a list/set. As far as I can tell,

It was the latter.
your benchmark concerns different approaches to the latter,
but assumes that looking up the method (i.e., using the Java
substitute for function pointers) will somehow skew the results
to the point where it shouldn't/can't be used. (You may actually
be right about that, much as it pains me to say so, because all
that duplicate code is, in my opinion and possibly yours as well,
both aesthetically displeasing and a source of potential trouble.)

Well, I only need one. That code will get tossed shortly.

Yes. But you did ask ....

[snip]
In my experience, it is a common pattern. After the beginner
level, there are few tutorials and yet, one does not know enough to
easily blow away the difficulties.

Maybe you could start a new thread asking for suggestions on what
to read -- I don't have any myself, but someone probably does.
 
B

blmblm

On 5 Jul 2011 19:12:39 GMT, (e-mail address removed)

[snip]

What I found is that HashSet was noticeably faster on all the
systems where I ran the benchmarks. Unless you need for the set
to be sorted (and it's not apparent from your code that you do),
why not .... ? (I'm curious too about why you chose TreeSet in
the first place. ? )

1) I can output the set in order without having to do anything else.
My real program has a lot of debugging info dumping. (Read as "checks
that I have not done something wrong".)


Ah. Well, yes, then you probably do need a SortedSet, though
considering that you initially build the set from a string that's in
order, maybe you could use that (the string) instead. Just sayin',
maybe.

I set the string value that way so that the binary search would
work.

Ah, okay.
I would need to know what the behaviour is supposed to be.

Maybe there's something I'm not understanding, but as far as I
know hash tables (including the Java HashMap class that, according
to the API, is used by HashSet) are required to do something that
allows storing multiple distinct keys that have the same hash code
("collisions"). The implementation that comes to mind is one that
has some sort of list for each possible hashcode value. Obviously(?)
performance suffers if very many of these lists have more than one
or a few elements, but correctness (in the sense of considering
keys to be equal based only on what equals() returns and not on
what hashCode() returns) is preserved.

I don't think I'm explaining this very well. Maybe the following
short test program will do better -- it's a totally contrived example
of using a HashSet to store elements that are distinct but have the
same hash code:

import java.util.*;

public class HashSetTest {

public static class Foo {
public final int n;

public Foo(int n) {
this.n = n;
}

@Override
public int hashCode() {
return 0;
}

@Override
public boolean equals(Object obj) {
if (obj instanceof Foo) {
return n == ((Foo) obj).n;
}
else {
return false;
}
}
}

public static void main(String[] args) {
Set<Foo> s = new HashSet<Foo>();
// add what should be ten distinct elements
for (int i = 0; i < 10; ++i) {
s.add(new Foo(i));
}
// add what should be duplicate elements
for (int i = 0; i < 10; ++i) {
s.add(new Foo(i));
}
// iterate over all elements of s -- this "foreach" syntax
// is possible AFAIK with all classes that implement Collection
for (Foo foo : s) {
// note use of C-like printf
System.out.printf("foo with value %d, hashcode %d\n",
foo.n, foo.hashCode());
}
}
}

When I run this I get 10 lines of output, indicating to me that
whether two elements are considered duplicates depends on equality
as determined by the equals() method rather than on hashcode.

Or maybe I'm once again totally misunderstanding you, and your actual
concern is something else ....
I
have something that works for now. Optimisation comes after getting
it working.

Well, yeah, sure, but this rather seems at odds with your having
done benchmarking of various ways of looking up a character in a
set of characters.

Anyway if at some point it seems that performance of your lookup
isn't good enough, it might be worthwhile to explore HashSet, if
you can think of some way to get the debugging information you need
that doesn't depend on being able to retrieve elements from the set
in sorted order. (E.g., maybe you could do a one-time operation
that retrieves all the elements, sorts them, and saves the result.)

Or, as supercali* suggests in another post, you could use a
LinkedHashSet. Replace HashSet with LinkedHashSet in the above test
program to see the difference. This would require you to build your
set from elements in the right order, but assuming building the set
is a one-time thing, it should be easy enough to sort the elements
before adding them, or so I would think.
1) Just in case there was a BIG difference.

In my experiments HashSet was about twice as fast as TreeSet. Of
course if you needed the sortedness, HashSet is off the table, but
LinkedHashSet (which I did not know about!) seems like it would do
what you need and is about as fast as HashSet on the systems where
I tried it.

The code using java.util.regex.* wasn't as fast on the old system
where I did my initial experiments, but on a newer system it seems
to give performance comparable to (Linked)HashSet.

Just sayin'.
2) To learn more
about Java. At some point though, I have to do something useful with
it.

Sure. I'm dimly aware that I'm probably flogging a horse that has long
since shuffled off this mortal coil.
My preprocessor is shaping up nicely. I have to write the symbol
define command code, handle the include command, and handle output to
a file. That is about it. Which means that there are probably only
about three other things that I will come up.

And then you can go back to coding in a language you like better? :)
 
B

blmblm

Or a LinkedHashFoo of some stripe.

Gene seems to be saying elsethread that in his real code he might
be initializing from something that isn't in order. But assuming he
could put it in order before initializing the set, then yes, it seems
like a LinkedHashSet would do what he wants.

I added it to my benchmark suite, reran timing experiments, and found
LinkedHashSet to give performance very similar to that of HashSet.

A day in which I learned something new -- not bad. Thanks!
 
G

Gene Wirchenko

On 6 Jul 2011 16:59:57 GMT, (e-mail address removed)

[snip]
Gene seems to be saying elsethread that in his real code he might
be initializing from something that isn't in order. But assuming he
Yup.

could put it in order before initializing the set, then yes, it seems

Why bother? SortedSet does the work for me.
like a LinkedHashSet would do what he wants.

[snip]

Sincerely,

Gene Wirchenko
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top