Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Holy boop: goto for Java

Reply
Thread Tools

Holy boop: goto for Java

 
 
markspace
Guest
Posts: n/a
 
      06-04-2012
Just looking for an extended answer to an earlier question (strings in a
case-switch statement), I found this on Joe Darcy's blog:

"Summary

"Provide the benefits of the time-testing goto control structure to Java
programs. The Java language has a history of adding new control
structures over time, the assert statement in 1.4, the enhanced for-loop
in 1.5,and try-with-resources in 7. Having support for goto is
long-overdue and simple to implement since the JVM already has goto
instructions."

<https://blogs.oracle.com/darcy/entry/upcoming_jep>

Holy booping bat boop Batman!

 
Reply With Quote
 
 
 
 
Daniel Pitts
Guest
Posts: n/a
 
      06-04-2012
On 6/3/12 7:36 PM, markspace wrote:
> Just looking for an extended answer to an earlier question (strings in a
> case-switch statement), I found this on Joe Darcy's blog:
>
> "Summary
>
> "Provide the benefits of the time-testing goto control structure to Java
> programs. The Java language has a history of adding new control
> structures over time, the assert statement in 1.4, the enhanced for-loop
> in 1.5,and try-with-resources in 7. Having support for goto is
> long-overdue and simple to implement since the JVM already has goto
> instructions."
>
> <https://blogs.oracle.com/darcy/entry/upcoming_jep>
>
> Holy booping bat boop Batman!
>

Check the date of that article before getting to excited/disappointed
 
Reply With Quote
 
 
 
 
markspace
Guest
Posts: n/a
 
      06-04-2012
On 6/3/2012 8:03 PM, Daniel Pitts wrote:
> Check the date of that article before getting to excited/disappointed



Ah. Somebody got me good, I think.

 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      06-04-2012
markspace wrote:
> Daniel Pitts wrote:
>> Check the date of that article before getting to excited/disappointed

>
> Ah. Somebody got me good, I think.


In a highly limited, controlled and presumably blessed-for-object-oriented
way, Java does have a version of "goto", in its 'break' and 'continue'
statements. You can't just jump anywhere, but you can jump to labels, with
restrictions.

I have never seen a use of Java's labeled 'break' or 'continue' outside of
tutorials and examples, though.

The full, unbridled "goto" doesn't exist in Java except for the keyword
'goto', whose head is mounted on a pike at the language's gates as a warning.

--
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedi.../c/cf/Friz.jpg
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      06-04-2012
On Sun, 03 Jun 2012 19:36:53 -0700, markspace <-@.> wrote, quoted or
indirectly quoted someone who said :

>"Provide the benefits of the time-testing goto control structure to Java
>programs.


People take a rule of thumb and turn it into a commandment from a
vicious god.

I remember back in the early 90s in C demonstrating how a common
pattern could be implemented with a goto. The boss insisted on a
goto-less implementation that was many times more verbose. NORMALLY
GoTos make for more tangled code. This time it did not.

Parser generators are simpler if they can generate gotos. Nobody is
supposed to even look at the code.

As a general rule, you don't want them. A team leader would want
members to get permission to use one.
--
Roedy Green Canadian Mind Products
http://mindprod.com
Controlling complexity is the essence of computer programming.
~ Brian W. Kernighan 1942-01-01
..
 
Reply With Quote
 
Robert Klemme
Guest
Posts: n/a
 
      06-04-2012
On 04.06.2012 06:17, Lew wrote:
> The full, unbridled "goto" doesn't exist in Java except for the keyword
> 'goto', whose head is mounted on a pike at the language's gates as a
> warning.


I'll print that and put it on our office door. Thanks for that, Lew!

Chuckle...

robert

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
 
Reply With Quote
 
Arved Sandstrom
Guest
Posts: n/a
 
      06-04-2012
On 12-06-04 01:17 AM, Lew wrote:
> markspace wrote:
>> Daniel Pitts wrote:
>>> Check the date of that article before getting to excited/disappointed
>>>

>>
>> Ah. Somebody got me good, I think.

>
> In a highly limited, controlled and presumably
> blessed-for-object-oriented way, Java does have a version of "goto", in
> its 'break' and 'continue' statements. You can't just jump anywhere, but
> you can jump to labels, with restrictions.
>
> I have never seen a use of Java's labeled 'break' or 'continue' outside
> of tutorials and examples, though.
>
> The full, unbridled "goto" doesn't exist in Java except for the keyword
> 'goto', whose head is mounted on a pike at the language's gates as a
> warning.
>

I use labeled break/continue occasionally. I see a lot of advice on
programming forums like StackOverflow that says never use them. Typical
dogmatic advice is that you should extract inner-loop code into methods
and use boolean return codes to make a top-level break/continue decision.

What amazes me is that these individuals support this religious stance
by arguing that it improves readability, when producing little auxiliary
methods usually does anything but.

The combination of conditions that would indicate a labeled
break/continue is clear:

1. A loop;
2. A condition in that loop that could lead to a break or continue for it;
3. That condition is itself a loop. Furthermore, the logic in the loop
is probably coupled to the logic in the rest of the main loop.

To the degree that the logic in that inner loop makes (no) sense as a
standalone method - size, understandability on its own etc - is the
decision process I follow as to whether a labeled break/continue is
advisable.

In any case, Lew, I don't see that this has much to do with "blessed for
OO". We're talking imperative coding here, which is what Java
programmers spend the majority of their time doing.

AHS
--
Never interrupt your enemy when he is making a mistake.
--Napoleon
 
Reply With Quote
 
Robert Klemme
Guest
Posts: n/a
 
      06-04-2012
On Monday, June 4, 2012 9:28:13 AM UTC+2, Arved Sandstrom wrote:
> What amazes me is that these individuals support this religious stance
> by arguing that it improves readability, when producing little auxiliary
> methods usually does anything but.


I am not religious about break / continue (although I use it extremely seldom, I am more likely to use "return" inside a loop). But I disagree about your general statement about little auxiliary methods usually not improvingreadability. It all depends on the specific case, of course, but giving ashort part of an algorithm a name (with the option to have a place to put JavaDoc) often helps readability in my experience.

Kind regards

robert
 
Reply With Quote
 
Joshua Cranmer
Guest
Posts: n/a
 
      06-04-2012
On 6/4/2012 12:17 AM, Lew wrote:
> I have never seen a use of Java's labeled 'break' or 'continue' outside
> of tutorials and examples, though.


If you translate some of the examples in Knuth's retort "The use of GOTO
in structured programming" to Java, you'd find yourself using labeled
break/continue. I've used it a fair amount in nested loops.

--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
 
Reply With Quote
 
Joshua Cranmer
Guest
Posts: n/a
 
      06-04-2012
On 6/3/2012 11:03 PM, Daniel Pitts wrote:
> On 6/3/12 7:36 PM, markspace wrote:
>> Just looking for an extended answer to an earlier question (strings in a
>> case-switch statement), I found this on Joe Darcy's blog:
>>
>> "Summary
>>
>> "Provide the benefits of the time-testing goto control structure to Java
>> programs. The Java language has a history of adding new control
>> structures over time, the assert statement in 1.4, the enhanced for-loop
>> in 1.5,and try-with-resources in 7. Having support for goto is
>> long-overdue and simple to implement since the JVM already has goto
>> instructions."
>>
>> <https://blogs.oracle.com/darcy/entry/upcoming_jep>
>>
>> Holy booping bat boop Batman!
>>

> Check the date of that article before getting to excited/disappointed


When I first saw that article, I got as far as posting it in an IRC
channel [without context] before I realized it was an joke. Fortunately,
I realized the joke before any discussion started up around it .

--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
70-297 HOLY CRAP rwilsonsr@foundation.uconn.edu MCSE 4 02-01-2005 03:53 PM
Holy crap Ken Briscoe MCSE 14 01-30-2004 07:20 PM
Re: java and goto instuction! amazing! E.C. Bäck Java 0 08-25-2003 02:31 AM
Re: java and goto instuction! amazing! Roedy Green Java 1 08-24-2003 07:32 PM
Re: java and goto instuction! amazing! Tor Iver Wilhelmsen Java 1 08-23-2003 11:08 AM



Advertisments