Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #29201 > unrolled thread

Java blunders

Started byRoedy Green <see_website@mindprod.com.invalid>
First post2014-07-22 11:41 -0700
Last post2014-07-30 10:22 -0500
Articles 20 on this page of 145 — 24 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-22 11:41 -0700
    Re: Java blunders Daniele Futtorovic <da.futt.news@laposte.net> - 2014-07-22 21:12 +0200
      Re: Java blunders Arne Vajhøj <arne@vajhoej.dk> - 2014-07-22 19:46 -0400
        Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-23 04:14 -0700
    Re: Java blunders Joerg Meier <joergmmeier@arcor.de> - 2014-07-22 23:47 +0200
      Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-23 04:23 -0700
        Re: Java blunders Martin Gregorie <martin@address-in-sig.invalid> - 2014-07-23 12:32 +0000
          Re: Java blunders Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-07-23 08:55 -0400
            Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-23 06:21 -0700
          Re: Java blunders Arne Vajhøj <arne@vajhoej.dk> - 2014-07-23 19:53 -0400
            Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-23 18:49 -0700
        Re: Java blunders Arne Vajhøj <arne@vajhoej.dk> - 2014-07-23 19:52 -0400
    Re: Java blunders Arne Vajhøj <arne@vajhoej.dk> - 2014-07-22 19:44 -0400
      Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-23 04:27 -0700
        Re: Java blunders Arne Vajhøj <arne@vajhoej.dk> - 2014-07-23 19:55 -0400
          Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-23 18:53 -0700
            Re: Java blunders Joerg Meier <joergmmeier@arcor.de> - 2014-07-24 11:24 +0200
              Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-25 06:34 -0700
            Re: Java blunders Arne Vajhøj <arne@vajhoej.dk> - 2014-07-24 19:31 -0400
              Re: Java blunders Gene Wirchenko <genew@telus.net> - 2014-07-25 13:22 -0700
                Re: Java blunders Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-07-25 17:17 -0400
                  Re: Java blunders Martin Gregorie <martin@address-in-sig.invalid> - 2014-07-25 23:12 +0000
                  Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-26 09:06 -0700
                    Re: Java blunders Martin Gregorie <martin@address-in-sig.invalid> - 2014-07-26 20:11 +0000
                      Re: Java blunders Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-07-26 17:27 -0400
                        Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-27 10:49 -0700
                      Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-27 10:10 -0700
                        Re: Java blunders Gene Wirchenko <genew@telus.net> - 2014-07-28 13:53 -0700
                          Re: Java blunders Stuart <DerTopper@web.de> - 2014-07-30 08:05 +0200
                            Re: Java blunders Sebastian <news@seyweiler.dyndns.org> - 2014-07-30 11:12 +0200
                      Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-27 10:13 -0700
                        Re: Java blunders Martin Gregorie <martin@address-in-sig.invalid> - 2014-07-27 18:28 +0000
                          Re: Java blunders Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-07-27 14:46 -0400
                            Re: Java blunders Martin Gregorie <martin@address-in-sig.invalid> - 2014-07-27 21:18 +0000
                              Re: Java blunders Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-07-27 18:10 -0400
                                Re: Java blunders Martin Gregorie <martin@address-in-sig.invalid> - 2014-07-28 01:25 +0000
                                  Re: Java blunders Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-07-28 08:02 -0400
                                Re: Java blunders Mike Amling <mamling@chaff.us> - 2014-07-31 13:26 -0500
                                  Re: Java blunders Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-07-31 14:48 -0400
                          Re: Java blunders "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2014-07-28 13:22 +0100
                            Re: Java blunders Martin Gregorie <martin@address-in-sig.invalid> - 2014-07-28 12:52 +0000
                            Re: Java blunders Joerg Meier <joergmmeier@arcor.de> - 2014-07-28 23:38 +0200
                              Re: Java blunders Martin Gregorie <martin@address-in-sig.invalid> - 2014-07-28 23:17 +0000
                                Re: Java blunders Silvio <silvio@internet.com> - 2014-07-29 13:34 +0200
                                  Re: Java blunders Martin Gregorie <martin@address-in-sig.invalid> - 2014-07-29 12:45 +0000
                                    Re: Java blunders Silvio <silvio@internet.com> - 2014-07-29 17:10 +0200
                                      Re: Java blunders Martin Gregorie <martin@address-in-sig.invalid> - 2014-07-29 16:29 +0000
                                        Re: Java blunders lipska the kat <lipskathekat@example.com> - 2014-07-29 20:15 +0100
                                          Re: Java blunders Martin Gregorie <martin@address-in-sig.invalid> - 2014-07-29 22:02 +0000
                                        Re: Java blunders Silvio <silvio@internet.com> - 2014-07-29 22:43 +0200
                                          Re: Java blunders Martin Gregorie <martin@address-in-sig.invalid> - 2014-07-29 22:10 +0000
                        Re: Java blunders Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2014-07-27 19:18 -0500
                        Re: Java blunders Gene Wirchenko <genew@telus.net> - 2014-07-28 13:54 -0700
                      Re: Java blunders Arne Vajhøj <arne@vajhoej.dk> - 2014-07-31 23:07 -0400
                        Re: Java blunders James Hostick <james.hostick@gmail.com> - 2014-08-01 22:10 -0700
              Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-26 08:31 -0700
                Re: Java blunders Martin Gregorie <martin@address-in-sig.invalid> - 2014-07-26 21:04 +0000
                  Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-27 10:51 -0700
                  Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-28 08:50 -0700
                    Re: Java blunders Joerg Meier <joergmmeier@arcor.de> - 2014-07-28 23:42 +0200
                Re: Java blunders Arne Vajhøj <arne@vajhoej.dk> - 2014-07-31 23:04 -0400
            Re: Java blunders Josip Almasi <joe@vrspace.org> - 2014-07-28 22:23 +0200
              Re: Java blunders Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-07-28 16:39 -0400
                Re: Java blunders Josip Almasi <joe@vrspace.org> - 2014-07-29 00:11 +0200
                Re: Java blunders Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2014-07-30 12:07 +0300
                  Re: Java blunders Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-07-30 08:05 -0400
      Re: Java blunders Wanja Gayk <brixomatic@yahoo.com> - 2014-07-25 01:34 +0200
        Re: Java blunders Arne Vajhøj <arne@vajhoej.dk> - 2014-07-24 19:43 -0400
    Re: Java blunders Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2014-07-22 21:02 -0500
      Re: Java blunders Leif Roar Moldskred <leifm@huldreskog.lan> - 2014-07-23 02:01 -0500
        Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-23 18:58 -0700
        Re: Java blunders thinbluernime <thinbluernime3@gmail.com> - 2014-07-25 03:55 +0000
          Re: Java blunders Leif Roar Moldskred <leifm@huldreskog.lan> - 2014-07-25 00:32 -0500
            Re: Java blunders thinbluernime <thinbluernime3@gmail.com> - 2014-07-26 07:28 +0000
              Re: Java blunders "Gavino" <invalid@invalid.invalid> - 2014-07-26 19:43 +0200
          Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-25 06:36 -0700
            Re: Java blunders "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2014-07-25 15:47 +0100
              Re: Java blunders David Postill <david.postill@gmail.com> - 2014-07-25 18:29 +0200
              Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-26 09:27 -0700
          Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-25 06:37 -0700
      Re: Java blunders Joerg Meier <joergmmeier@arcor.de> - 2014-07-23 13:17 +0200
        Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-23 06:27 -0700
      Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-23 04:44 -0700
        Re: Java blunders Silvio <silvio@internet.com> - 2014-07-23 16:23 +0200
          Re: Java blunders Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-07-23 12:02 -0400
            Re: Java blunders Silvio <silvio@internet.com> - 2014-07-24 11:37 +0200
              Re: Java blunders Josip Almasi <joe@vrspace.org> - 2014-07-28 22:37 +0200
          Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-23 09:33 -0700
            Re: Java blunders thinbluernime <thinbluernime3@gmail.com> - 2014-07-25 03:57 +0000
          Re: Java blunders Arne Vajhøj <arne@vajhoej.dk> - 2014-07-23 21:38 -0400
            Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-23 18:59 -0700
              Re: Java blunders Martin Gregorie <martin@address-in-sig.invalid> - 2014-07-24 07:33 +0000
            Re: Java blunders Silvio <silvio@internet.com> - 2014-07-24 11:47 +0200
              Re: Java blunders Arne Vajhøj <arne@vajhoej.dk> - 2014-07-24 19:34 -0400
                Re: Java blunders Silvio <silvio@internet.com> - 2014-07-25 08:48 +0200
                  Re: Java blunders Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-07-25 08:07 -0400
                    Re: Java blunders "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2014-07-25 13:54 +0100
                  Re: Java blunders Arne Vajhøj <arne@vajhoej.dk> - 2014-07-31 22:53 -0400
              Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-25 07:04 -0700
          Re: Java blunders Josip Almasi <joe@vrspace.org> - 2014-07-28 22:01 +0200
        Re: Java blunders Josip Almasi <joe@vrspace.org> - 2014-07-28 21:56 +0200
      Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-23 06:28 -0700
        Re: Java blunders Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2014-07-23 08:33 -0500
      Re: Java blunders Arne Vajhøj <arne@vajhoej.dk> - 2014-07-23 21:34 -0400
        Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-23 19:06 -0700
        Re: Java blunders Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2014-07-23 22:11 -0500
          Re: Java blunders Martin Gregorie <martin@address-in-sig.invalid> - 2014-07-24 07:36 +0000
            Re: Java blunders Arne Vajhøj <arne@vajhoej.dk> - 2014-07-24 19:39 -0400
              Re: Java blunders "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2014-07-25 13:40 +0100
          Re: Java blunders Arne Vajhøj <arne@vajhoej.dk> - 2014-07-24 19:38 -0400
            Re: Java blunders Gene Wirchenko <genew@telus.net> - 2014-07-25 13:30 -0700
    Re: Java blunders taqmcg@gmail.com - 2014-07-23 11:26 -0700
      Re: Java blunders Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-07-23 15:14 -0400
        Re: Java blunders thinbluernime <thinbluernime3@gmail.com> - 2014-07-25 04:07 +0000
          Re: Java blunders Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-07-25 08:35 -0400
            Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-26 09:41 -0700
          Re: Java blunders Wanja Gayk <brixomatic@yahoo.com> - 2014-08-03 16:41 +0200
            Re: Java blunders Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-08-03 11:31 -0400
      Re: Java blunders Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2014-07-23 22:41 -0500
        Re: Java blunders taqmcg@gmail.com - 2014-07-24 10:09 -0700
          Re: Java blunders "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2014-07-25 13:22 +0100
          Re: Java blunders Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2014-07-25 20:34 -0500
            Re: Java blunders "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2014-07-28 13:33 +0100
              Re: Java blunders Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2014-07-28 08:35 -0500
          Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-26 09:44 -0700
            Re: Java blunders Martin Gregorie <martin@address-in-sig.invalid> - 2014-07-26 23:36 +0000
    Re: Java blunders Gene Wirchenko <genew@telus.net> - 2014-07-23 20:48 -0700
      Re: Java blunders Silvio <silvio@internet.com> - 2014-07-24 11:56 +0200
        Re: Java blunders Silvio <silvio@internet.com> - 2014-07-24 16:07 +0200
          Re: Java blunders Gene Wirchenko <genew@telus.net> - 2014-07-25 13:38 -0700
            Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-26 10:02 -0700
      Re: Java blunders Arne Vajhøj <arne@vajhoej.dk> - 2014-07-24 19:29 -0400
        Re: Java blunders Gene Wirchenko <genew@telus.net> - 2014-07-25 13:45 -0700
      Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-26 10:53 -0700
    Re: Java blunders Wanja Gayk <brixomatic@yahoo.com> - 2014-07-25 01:28 +0200
    Re: Java blunders "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2014-07-25 14:16 +0100
    Re: Java blunders Joerg Meier <joergmmeier@arcor.de> - 2014-07-25 17:39 +0200
    Re: Java blunders Roedy Green <see_website@mindprod.com.invalid> - 2014-07-26 16:21 -0700
    Re: Java blunders Josip Almasi <joe@vrspace.org> - 2014-07-28 23:59 +0200
      Re: Java blunders Josip Almasi <joe@vrspace.org> - 2014-07-29 00:41 +0200
        Re: Java blunders Josip Almasi <joe@vrspace.org> - 2014-07-29 01:54 +0200
      Re: Java blunders Arne Vajhøj <arne@vajhoej.dk> - 2014-07-31 22:38 -0400
      Re: Java blunders Arne Vajhøj <arne@vajhoej.dk> - 2014-07-31 22:39 -0400
    Re: Java blunders w.tom.adams@gmail.com - 2014-07-30 07:57 -0700
      Re: Java blunders Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2014-07-30 10:22 -0500

Page 4 of 8 — ← Prev page 1 2 3 [4] 5 6 7 8  Next page →


#29477

FromArne Vajhøj <arne@vajhoej.dk>
Date2014-07-31 23:04 -0400
Message-ID<53db03bf$0$299$14726298@news.sunsite.dk>
In reply to#29336
On 7/26/2014 11:31 AM, Roedy Green wrote:
> On Thu, 24 Jul 2014 19:31:29 -0400, Arne Vajhøj <arne@vajhoej.dk>
> wrote, quoted or indirectly quoted someone who said :
>
>> A new concatenation operator would not solve that problem
>> in all cases.
>
> Assume there were two distinct + operators.
>
> They might both have the same precedence, or perhaps addition would be
> higher than concatenation (or even if the IDE just used two different
> glyphs after it analysed).
>
> Please show me a expression that would still be confusing.

Practically all.

The problem scenario is:

"abc" + 2 + 2

wher epeople that do not understand expression evaluation believes it
will be evaluated as:

"abc" + (2 + 2)

Now we introduce a new concatenation operator - let us just for
fun use >< with same precedence as +:

"abc" >< 2 + 2

And what now?

The people that has not understood expression evaluation will just
believe that it will be evaluated as:

"abc" >< 2 + 2

and still be wrong.

Of course you could make + have higher precedence than ><, but then
people that expect:

("abc" >< 2) + 2

would be wrong.

I will postulate that you can not come up with a set of operators
and precedence that will avoid misunderstandings by people that
do not understand expression evaluation and precedence.

Arne

[toc] | [prev] | [next] | [standalone]


#29404

FromJosip Almasi <joe@vrspace.org>
Date2014-07-28 22:23 +0200
Message-ID<lr6bfm$1vr$1@gregory.bnet.hr>
In reply to#29251
On 07/24/2014 03:53 AM, Roedy Green wrote:
> On Wed, 23 Jul 2014 19:55:09 -0400, Arne Vajhøj <arne@vajhoej.dk>
> wrote, quoted or indirectly quoted someone who said :
>
>> But is it a problem in real world programming?
>>
>> I have never seen a problem due to this.
>
>
> The most common error is like this:
>
> out.println ( "the answer is " +
> a + b
> + ".");
>
> you must write that as:
>
> out.println ( "the answer is " + (a + b) + ".");

I think you guys missed worst thing with java concatenation, and it's 
got nothing to do with operator.
It's about how operator gets interpreted:

out.println ( new StringBuffer("the answer is ").append(new 
StringBuffer(a + b)).append(new StringBuffer("."));

It's three new objects, all synchronized.
OK I haven't read the spec for a while but that's it IIRC, spec requires 
it that way.
And if you want to avoid the garbage, you need to

StringBuilder shit = new StringBuilder();
shit.append("the answer is ");
shit.append(a + b);
shit.append(".");
and another line to get the string.

And bye bye code readability. Can I have strcat back please...
... err, with automated malloc/free if you please;)

Now, if || or some other new concat op solves that, I'm all for it.
Otherwise, I prefer +.

Regards...

[toc] | [prev] | [next] | [standalone]


#29406

FromEric Sosman <esosman@comcast-dot-net.invalid>
Date2014-07-28 16:39 -0400
Message-ID<lr6cdv$se9$1@dont-email.me>
In reply to#29404
On 7/28/2014 4:23 PM, Josip Almasi wrote:
> On 07/24/2014 03:53 AM, Roedy Green wrote:
>> On Wed, 23 Jul 2014 19:55:09 -0400, Arne Vajhøj <arne@vajhoej.dk>
>> wrote, quoted or indirectly quoted someone who said :
>>
>>> But is it a problem in real world programming?
>>>
>>> I have never seen a problem due to this.
>>
>>
>> The most common error is like this:
>>
>> out.println ( "the answer is " +
>> a + b
>> + ".");
>>
>> you must write that as:
>>
>> out.println ( "the answer is " + (a + b) + ".");
>
> I think you guys missed worst thing with java concatenation, and it's
> got nothing to do with operator.
> It's about how operator gets interpreted:
>
> out.println ( new StringBuffer("the answer is ").append(new
> StringBuffer(a + b)).append(new StringBuffer("."));

     Why do you think this is so?  javac 1.8.0_11 compiles it to
the equivalent of

	out.println(new StringBuilder()
	    .append("the answer is ")
	    .append(a + b)
	    .append(".")
	    .toString());

... and I think all javac's have done so for a long time (but I
don't have them available for checking).

> It's three new objects, all synchronized.

     ... for suitable values of "three" (i.e., 2) and "all" (0).

> OK I haven't read the spec for a while but that's it IIRC, spec requires
> it that way.

     StringBuilder replaced StringBuffer for this purpose in Java 1.5,
just under ten years ago.  I guess that counts as "a while."  ;-)

> And if you want to avoid the garbage, you need to
>
> StringBuilder shit = new StringBuilder();
> shit.append("the answer is ");
> shit.append(a + b);
> shit.append(".");
> and another line to get the string.

     Um, er, no.

-- 
esosman@comcast-dot-net.invalid

[toc] | [prev] | [next] | [standalone]


#29415

FromJosip Almasi <joe@vrspace.org>
Date2014-07-29 00:11 +0200
Message-ID<lr6hqe$4bs$1@gregory.bnet.hr>
In reply to#29406
On 07/28/2014 10:39 PM, Eric Sosman wrote:
> On 7/28/2014 4:23 PM, Josip Almasi wrote:
>> I think you guys missed worst thing with java concatenation, and it's
>> got nothing to do with operator.
>> It's about how operator gets interpreted:
>>
>> out.println ( new StringBuffer("the answer is ").append(new
>> StringBuffer(a + b)).append(new StringBuffer("."));
>
>      Why do you think this is so?

OK you had me look at the spec:)
String concatenation is implemented through the StringBuilder(or 
StringBuffer) class and its append method.

> javac 1.8.0_11 compiles it to
> the equivalent of
>
>      out.println(new StringBuilder()
>          .append("the answer is ")
>          .append(a + b)
>          .append(".")
>          .toString());
>
> ... and I think all javac's have done so for a long time (but I
> don't have them available for checking).
>
>> It's three new objects, all synchronized.
>
>      ... for suitable values of "three" (i.e., 2) and "all" (0).
>
>> OK I haven't read the spec for a while but that's it IIRC, spec requires
>> it that way.
>
>      StringBuilder replaced StringBuffer for this purpose in Java 1.5,
> just under ten years ago.  I guess that counts as "a while."  ;-)


Indeed:)

I stand corrected.

Regards...

[toc] | [prev] | [next] | [standalone]


#29437

FromJukka Lahtinen <jtfjdehf@hotmail.com.invalid>
Date2014-07-30 12:07 +0300
Message-ID<lvy4vb8b9w.fsf@saunalahti.fi>
In reply to#29406
Eric Sosman <esosman@comcast-dot-net.invalid> writes:

> On 7/28/2014 4:23 PM, Josip Almasi wrote:
>> It's about how operator gets interpreted:
>> out.println ( new StringBuffer("the answer is ").append(new
>> StringBuffer(a + b)).append(new StringBuffer("."));

>     Why do you think this is so?  javac 1.8.0_11 compiles it to
> the equivalent of
> 	out.println(new StringBuilder()
> 	    .append("the answer is ")
> 	    .append(a + b)
> 	    .append(".")
> 	    .toString());

You could drop one append call by using another constructor:
    out.println(newStringBuilder("the answer is ")
        .append(a + b)
        .append(".")
        .toString());

-- 
Jukka Lahtinen

[toc] | [prev] | [next] | [standalone]


#29439

FromEric Sosman <esosman@comcast-dot-net.invalid>
Date2014-07-30 08:05 -0400
Message-ID<lran2h$a5t$1@dont-email.me>
In reply to#29437
On 7/30/2014 5:07 AM, Jukka Lahtinen wrote:
> Eric Sosman <esosman@comcast-dot-net.invalid> writes:
>
>> On 7/28/2014 4:23 PM, Josip Almasi wrote:
>>> It's about how operator gets interpreted:
>>> out.println ( new StringBuffer("the answer is ").append(new
>>> StringBuffer(a + b)).append(new StringBuffer("."));
>
>>      Why do you think this is so?  javac 1.8.0_11 compiles it to
>> the equivalent of
>> 	out.println(new StringBuilder()
>> 	    .append("the answer is ")
>> 	    .append(a + b)
>> 	    .append(".")
>> 	    .toString());
>
> You could drop one append call by using another constructor:
>      out.println(newStringBuilder("the answer is ")
>          .append(a + b)
>          .append(".")
>          .toString());

     You could, but javac doesn't.

     You could also drop the toString() call by using a different
println() overload -- but again, javac doesn't.

-- 
esosman@comcast-dot-net.invalid

[toc] | [prev] | [next] | [standalone]


#29283

FromWanja Gayk <brixomatic@yahoo.com>
Date2014-07-25 01:34 +0200
Message-ID<MPG.2e3bb641a36fba8129@202.177.16.121>
In reply to#29212
In article <53cef75d$0$291$14726298@news.sunsite.dk>, Arne Vajhøj 
(arne@vajhoej.dk) says...

> You are really asking for the ability to use var/val and let the 
compiler
> determine the type via type interference.

Who ever came up with "val" and "var" in Scala and similar languages 
shouldbe hit with a stick every time someone misreads or mistypes one 
for the other.
Why the hell wasn't it possible to name them "var" and "const", so they 
look very different because they behave very different?

Kind regards,
Wanja

-- 
..Alesi's problem was that the back of the car was jumping up and down 
dangerously - and I can assure you from having been teammate to 
Jean Alesi and knowing what kind of cars that he can pull up with, 
when Jean Alesi says that a car is dangerous - it is. [Jonathan Palmer]

--- news://freenews.netfront.net/ - complaints: news@netfront.net ---

[toc] | [prev] | [next] | [standalone]


#29286

FromArne Vajhøj <arne@vajhoej.dk>
Date2014-07-24 19:43 -0400
Message-ID<53d19a2d$0$295$14726298@news.sunsite.dk>
In reply to#29283
On 7/24/2014 7:34 PM, Wanja Gayk wrote:
> In article <53cef75d$0$291$14726298@news.sunsite.dk>, Arne Vajhøj
> (arne@vajhoej.dk) says...
>
>> You are really asking for the ability to use var/val and let the
> compiler
>> determine the type via type interference.
>
> Who ever came up with "val" and "var" in Scala and similar languages
> shouldbe hit with a stick every time someone misreads or mistypes one
> for the other.
> Why the hell wasn't it possible to name them "var" and "const", so they
> look very different because they behave very different?

That is a good point.

Arne

[toc] | [prev] | [next] | [standalone]


#29219

FromJoshua Cranmer 🐧 <Pidgeot18@verizon.invalid>
Date2014-07-22 21:02 -0500
Message-ID<lqn53i$huq$1@dont-email.me>
In reply to#29201
On 7/22/2014 1:41 PM, Roedy Green wrote:
> I have composed an essay about what I consider were the blunders in
> the design of Java.  I hold out hope many of them will eventually
> be fixed. You might like to add to the list.
>
>
> see http://mindprod.com/jgloss/javablunders.html

*stare*

Biggest blunders IMHO:
1. signed byte, and signed short to a lesser degree. Sub-integer types 
should have always been unsigned even if unsigned types weren't a 
fixture of the language.

2. 16-bit char. Unicode is a steaming pile of insanity and extremely 
difficult to work with properly. 16-bit chars makes the problem even 
worse. (Granted, Java predates the Unicode oops-we-screwed-up that made 
the mess, but it's a blunder that would need to be fixed if it could).

3. Non-reified generics.

4. Default-fallthrough switch statements. There are very little times 
you want to do:
switch (a) {
case 0:
   foo;
case 1:
   bar;
   break;
}-- you mostly want either:
switch (a) {
case 0: case 1: foo; break;
}
or
switch (a) {
case 0: foo; break;
case 1: bar; break;
}

5. &, |, ^ should have higher precedence than ==, != et al. Just because 
C did it doesn't mean it's a good idea.

6. List.class should be Class<List<?>>, not Class<List>. There's a 
difference between those two types, and it's not fun when you discover it.


Now of the complaints you listed, I'll make these points:
A. I think languages work best if you need to specify a type name 
exactly once, e.g., Foo x = new Foo(); is one too many times to say 
'Foo'. auto x = 2; is also one time too few, IMHO.

B. Precedence is useful, although the compiler can (and should!) warn 
you if you start getting to the confusing parts of precedence [1].

C. On the balance, I think matching curly braces is superior to 
begin/end-ish constructs. If you're spending too much time trying to 
figure out where you have an extra or a missing curly brace, then, quite 
frankly, your IDE is defective. My IDE points out matching curly braces 
and can even fold them based on appropriate matching, and it has been 
able to do so since before Java was invented. Possibly since before I 
was born, even.

[1] One quote I remember hearing from a talk is a complaint that too 
many PL designers have never quite understood the value of a warning as 
opposed to an error.
-- 
Beware of bugs in the above code; I have only proved it correct, not 
tried it. -- Donald E. Knuth

[toc] | [prev] | [next] | [standalone]


#29221

FromLeif Roar Moldskred <leifm@huldreskog.lan>
Date2014-07-23 02:01 -0500
Message-ID<G_adneVI7eoswFLOnZ2dnUVZ8oqdnZ2d@giganews.com>
In reply to#29219
Joshua Cranmer ? <Pidgeot18@verizon.invalid> wrote:
> [SNIP]

> 6. List.class should be Class<List<?>>, not Class<List>. There's a 
> difference between those two types, and it's not fun when you discover it.

I'd add the following:

 * Octal notation (what _were_ they thinking?! Or smoking, for that matter?)
 * Using = for assignment 
 * Bracket-less conditionals and loops
 * In fact -- copying the syntax of C in general.
 * Having an operator for reference equality but not value equality (.equals() )
 * Defaulting to 'package' access level instead of 'private'
 * No out parameters
 * No named parameter syntax
 * System.exit() rather than just making the main method return an int
 * No Elvis-operator or similar (it would make logging logic a lot more 
   pleasant to write.)
 * java.io.File
 * java.util.Date 
 * I/O resources where .close() can throw IOException.
 * No "immutable array" type or reference type
 * HTML as the markup language for JavaDoc
 * Basing the OO inheritance mechanism on the type system (not an error limited
   to Java, of course.)

-- 
Leif Roar Moldskred

[toc] | [prev] | [next] | [standalone]


#29252

FromRoedy Green <see_website@mindprod.com.invalid>
Date2014-07-23 18:58 -0700
Message-ID<irp0t9lhq8215pcqofiv5r6c95s445oag5@4ax.com>
In reply to#29221
On 23 Jul 2014 20:38:11 GMT, ram@zedat.fu-berlin.de (Stefan Ram)
wrote, quoted or indirectly quoted someone who said :

>  Java and C are he two most popular programming languages.

If extant code is what matters, even COBOL would look good. 

You also want a measure of what people are using for new projects and
what people are writing new code in (which might be used to extend old
projects).

There seems to be a greatly renewed interest in new languages like
Python,  Groovy, Scala and Ruby.  IntelliJ support all kinds of
languages I have never even seen.  The JVM and class library has made
it possible to create a new language, standing on Java's shoulders.

-- 
Roedy Green Canadian Mind Products http://mindprod.com
Science is what we understand well enough to explain to a computer.
Art is everything else we do. 
~ Donald Ervin Knuth (born: 1938-01-10 age: 76)

[toc] | [prev] | [next] | [standalone]


#29294

Fromthinbluernime <thinbluernime3@gmail.com>
Date2014-07-25 03:55 +0000
Message-ID<lqskek$2bo$2@speranza.aioe.org>
In reply to#29221
On Wed, 23 Jul 2014 02:01:05 -0500, Leif Roar Moldskred wrote:

>  * No Elvis-operator or similar (it would make logging logic a lot more
>    pleasant to write.)

"Elvis-operator"? (And please don't anybody suggest that googling "Elvis" 
could *possibly* be useful here.)

>  * java.io.File
>  * java.util.Date

What are your specific complaints with those? Or do you think these 
classes should have been in java.lang?

>  * HTML as the markup language for JavaDoc

HTML is the standard way to represent hypertext these days. Are you 
suggesting JavaDoc shouldn't have been hypertext, or that it should have 
been something weird and unusual that few other tools would interoperate 
with and that would require a whole new ground-up browser be written for 
it instead of using the ones everyone already has installed?

[toc] | [prev] | [next] | [standalone]


#29299

FromLeif Roar Moldskred <leifm@huldreskog.lan>
Date2014-07-25 00:32 -0500
Message-ID<fd-dneUt7JpidkzOnZ2dnUVZ8lCdnZ2d@giganews.com>
In reply to#29294
thinbluernime <thinbluernime3@gmail.com> wrote:
> On Wed, 23 Jul 2014 02:01:05 -0500, Leif Roar Moldskred wrote:
> 
>>  * No Elvis-operator or similar (it would make logging logic a lot more
>>    pleasant to write.)
> 
> "Elvis-operator"? (And please don't anybody suggest that googling "Elvis" 
> could *possibly* be useful here.)

Well, you could try googling "?:", but I suspect it would be more fruitful
to google for "elvis operator".

>>  * java.io.File
>>  * java.util.Date
> 
> What are your specific complaints with those? Or do you think these 
> classes should have been in java.lang?

No, I think they should have been made well rather than poorly. 

For File the problem is that there is too much crammed into one single 
type: file-system navigation, logical file-names, physical files, 
file-related utility functions and more. Also, it's about the only
place in the Java standard library where error conditions are marked
with return values rather than exceptions.

>>  * HTML as the markup language for JavaDoc
> 
> HTML is the standard way to represent hypertext these days. Are you 
> suggesting JavaDoc shouldn't have been hypertext, or that it should have 
> been something weird and unusual that few other tools would interoperate 
> with and that would require a whole new ground-up browser be written for 
> it instead of using the ones everyone already has installed?

The _output_ of the JavaDoc tool should of course be HTML. The _input_
is just text with markup, and it was an unfortunate choice to choose 
HTML-style tags as the markup language for that text. 

A more concise, wiki-style markup language would have been better for 
two reasons:

First of all because the JavaDoc input also serves as in-situ source-code 
documentation, and a comment that's properly marked up for JavaDoc becomes 
annoying to read as plain text. It is particularly fiddly to refer to XML 
or HTML tags and to numeric comparsions in the documentation because the 
characters < and > need escaping.

Secondly, the JavaDoc input isn't plain HTML _anyway_ what with with
leading asterixes, block tags and inline tags, so there's no real benefit
to using HTML tags in the first place.

-- 
Leif Roar Moldskred

[toc] | [prev] | [next] | [standalone]


#29332

Fromthinbluernime <thinbluernime3@gmail.com>
Date2014-07-26 07:28 +0000
Message-ID<lqvlb1$c87$1@speranza.aioe.org>
In reply to#29299
On Fri, 25 Jul 2014 00:32:47 -0500, Leif Roar Moldskred wrote:

> thinbluernime <thinbluernime3@gmail.com> wrote:
>> On Wed, 23 Jul 2014 02:01:05 -0500, Leif Roar Moldskred wrote:
>> 
>>>  * No Elvis-operator or similar (it would make logging logic a lot
>>>  more
>>>    pleasant to write.)
>> 
>> "Elvis-operator"? (And please don't anybody suggest that googling
>> "Elvis" could *possibly* be useful here.)
> 
> Well, you could try googling "?:", but I suspect it would be more
> fruitful to google for "elvis operator".

It clearly wasn't for you, if that resulted in you thinking the OP meant 
the ?: operator, when he clearly didn't (as whatever he meant is 
something Java lacks, but Jave *has* the ?: operator).

> The _output_ of the JavaDoc tool should of course be HTML. The _input_
> is just text with markup, and it was an unfortunate choice to choose
> HTML-style tags as the markup language for that text.

Ah, so rather than also force the reinvention of the browser, you'd 
"merely" want everyone to learn an extra (and no doubt idiosyncratic) 
markup language instead of using the one everyone already knows. Gotcha.

[toc] | [prev] | [next] | [standalone]


#29344

From"Gavino" <invalid@invalid.invalid>
Date2014-07-26 19:43 +0200
Message-ID<c3i7mgFrr3rU1@mid.individual.net>
In reply to#29332
"thinbluernime" <thinbluernime3@gmail.com> wrote in message
news:lqvlb1$c87$1@speranza.aioe.org...
> On Fri, 25 Jul 2014 00:32:47 -0500, Leif Roar Moldskred wrote:
>
>> thinbluernime <thinbluernime3@gmail.com> wrote:
>>> On Wed, 23 Jul 2014 02:01:05 -0500, Leif Roar Moldskred wrote:
>>>
>>>>  * No Elvis-operator or similar (it would make logging logic a lot
>>>>  more
>>>>    pleasant to write.)
>>>
>>> "Elvis-operator"? (And please don't anybody suggest that googling
>>> "Elvis" could *possibly* be useful here.)
>>
>> Well, you could try googling "?:", but I suspect it would be more
>> fruitful to google for "elvis operator".
>
> It clearly wasn't for you, if that resulted in you thinking the OP meant
> the ?: operator, when he clearly didn't (as whatever he meant is
> something Java lacks, but Jave *has* the ?: operator).

Java has the ?: operator, but only as a ternary operator.
The (so-called) Elvis operator is a BINARY one, used as a 'null-coalescing' operator:
x ?: y
meaning
x !=null ? x : y



[toc] | [prev] | [next] | [standalone]


#29310

FromRoedy Green <see_website@mindprod.com.invalid>
Date2014-07-25 06:36 -0700
Message-ID<6an4t958o7bn9o7p7e453g196feciovcba@4ax.com>
In reply to#29294
On Fri, 25 Jul 2014 03:55:00 +0000 (UTC), thinbluernime
<thinbluernime3@gmail.com> wrote, quoted or indirectly quoted someone
who said :

>"Elvis-operator"? (And please don't anybody suggest that googling "Elvis" 
>could *possibly* be useful here.)

see http://mindprod.com/elvisoperator.html
-- 
Roedy Green Canadian Mind Products http://mindprod.com
Science is what we understand well enough to explain to a computer.
Art is everything else we do. 
~ Donald Ervin Knuth (born: 1938-01-10 age: 76)

[toc] | [prev] | [next] | [standalone]


#29313

From"Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org>
Date2014-07-25 15:47 +0100
Message-ID<ZtednXewzZnK8E_OnZ2dnUVZ7omdnZ2d@bt.com>
In reply to#29310
Roedy Green wrote:

> see http://mindprod.com/elvisoperator.html

Broken link as of the time of this posting.


OTOH (for thinbluernime): putting

    elvis operator

into any of DuckDuckGo, Google, or Bing produced an explanation as the first 
item in the list (even before "find Elvis at Amazon").

Also (for thinbluernime and anyone else) the name "elvis operator" is new to me 
too, and I DON'T LIKE IT ONE BIT...

    -- chris 

[toc] | [prev] | [next] | [standalone]


#29318

FromDavid Postill <david.postill@gmail.com>
Date2014-07-25 18:29 +0200
Message-ID<vd15t9pbbu1m9vfsaivmqpep5qkdoclp2j@4ax.com>
In reply to#29313
In article <ZtednXewzZnK8E_OnZ2dnUVZ7omdnZ2d@bt.com>, on Fri, 25 Jul 2014
15:47:04 +0100, Chris Uppal wrote:

| Roedy Green wrote:
| 
| > see http://mindprod.com/elvisoperator.html
| 
| Broken link as of the time of this posting.

http://mindprod.com/jgloss/elvisoperator.html
-- 
David Postill
Dance your Life - Biodanza in Alkmaar, Holland - <http://www.danceyourlife.eu>

[toc] | [prev] | [next] | [standalone]


#29339

FromRoedy Green <see_website@mindprod.com.invalid>
Date2014-07-26 09:27 -0700
Message-ID<inl7t99dous8lkgqllt9r46lnakmc0a4db@4ax.com>
In reply to#29313
uOn Fri, 25 Jul 2014 15:47:04 +0100, "Chris Uppal"
<chris.uppal@metagnostic.REMOVE-THIS.org> wrote, quoted or indirectly
quoted someone who said :

>> see http://mindprod.com/elvisoperator.html
>
>Broken link as of the time of this posting.
oops

http://mindprod.com/jgloss/elvisoperator.html
-- 
Roedy Green Canadian Mind Products http://mindprod.com
The art of strongly-typed language design is largely arranging 
that errors are automatically detected as soon as possible
in the compose, compile, run cycle.

[toc] | [prev] | [next] | [standalone]


#29311

FromRoedy Green <see_website@mindprod.com.invalid>
Date2014-07-25 06:37 -0700
Message-ID<2bn4t9pbvgdr90o5rnc7bseigldkc9f6a1@4ax.com>
In reply to#29294
On Fri, 25 Jul 2014 03:55:00 +0000 (UTC), thinbluernime
<thinbluernime3@gmail.com> wrote, quoted or indirectly quoted someone
who said :

>>  * java.io.File
>>  * java.util.Date
>
>What are your specific complaints with those? Or do you think these 
>classes should have been in java.lang?

Sun admitted that Date was the Lemon of Java. See
http://mindprod.com/jgloss/date.html

for some of the warts.

They tried again with Calendar,
and I seem to recall there is yet another attempt after that.
-- 
Roedy Green Canadian Mind Products http://mindprod.com
Science is what we understand well enough to explain to a computer.
Art is everything else we do. 
~ Donald Ervin Knuth (born: 1938-01-10 age: 76)

[toc] | [prev] | [next] | [standalone]


Page 4 of 8 — ← Prev page 1 2 3 [4] 5 6 7 8  Next page →

Back to top | Article view | comp.lang.java.programmer


csiph-web