1188: "Bonding"

This forum is for the individual discussion thread that goes with each new comic.

Moderators: Moderators General, Prelates, Magistrates

ctsketch
Posts: 26
Joined: Thu Aug 04, 2011 12:40 pm UTC
Contact:

Re: 1188: "Bonding"

Postby ctsketch » Wed Mar 20, 2013 12:41 pm UTC

I don't even program java and I got the joke. haha. you people need to lighten up


parent...child...bonding....playing catch,.,....so much pun

User avatar
BAReFOOt
Posts: 179
Joined: Mon Jul 19, 2010 7:48 am UTC

Re: 1188: "Bonding"

Postby BAReFOOt » Wed Mar 20, 2013 12:56 pm UTC

Gargravarr wrote:Play with me Daddy, forever and ever and ever and... until StackOverflowError.


Not if it’s tail recursive, and the compiler/interpreter optimizes the stack frames away.

Then it can go until the end of all time…

User avatar
cellocgw
Posts: 2053
Joined: Sat Jun 21, 2008 7:40 pm UTC

Re: 1188: "Bonding"

Postby cellocgw » Wed Mar 20, 2013 12:56 pm UTC

Well, I suppose it's a couple steps better than the ancient shell joke:

% \(
-bash: (: command not found
https://app.box.com/witthoftresume
Former OTTer
Vote cellocgw for President 2020. #ScienceintheWhiteHouse http://cellocgw.wordpress.com
"The Planck length is 3.81779e-33 picas." -- keithl
" Earth weighs almost exactly π milliJupiters" -- what-if #146, note 7

dp2
Posts: 346
Joined: Wed Aug 18, 2010 3:06 pm UTC

Re: 1188: "Bonding"

Postby dp2 » Wed Mar 20, 2013 1:23 pm UTC

For all the obscure topics xkcd covers, why is it programming, one of the most basic geek activities, that evokes such virulent whining about not getting the joke?

LID919
Posts: 26
Joined: Sun Feb 17, 2013 10:21 pm UTC

Re: 1188: "Bonding"

Postby LID919 » Wed Mar 20, 2013 1:25 pm UTC

[deleted]
Last edited by LID919 on Tue Oct 16, 2018 8:43 pm UTC, edited 2 times in total.

User avatar
Klear
Posts: 1965
Joined: Sun Jun 13, 2010 8:43 am UTC
Location: Prague

Re: 1188: "Bonding"

Postby Klear » Wed Mar 20, 2013 1:28 pm UTC

dp2 wrote:For all the obscure topics xkcd covers, why is it programming, one of the most basic geek activities, that evokes such virulent whining about not getting the joke?


Because the joke isn't that good today and people are supposing they are missing some context that would make it funnier?
Or... maybe they're right and they are all missing some context which makes it funnier.

rmsgrey
Posts: 3630
Joined: Wed Nov 16, 2011 6:35 pm UTC

Re: 1188: "Bonding"

Postby rmsgrey » Wed Mar 20, 2013 1:29 pm UTC

dp2 wrote:For all the obscure topics xkcd covers, why is it programming, one of the most basic geek activities, that evokes such virulent whining about not getting the joke?


Because it's the only one in a foreign language?

eddward
Posts: 1
Joined: Wed Mar 20, 2013 1:26 pm UTC

Re: 1188: "Bonding"

Postby eddward » Wed Mar 20, 2013 1:30 pm UTC

Is it time for a new task on Rosetta Code?

dp2
Posts: 346
Joined: Wed Aug 18, 2010 3:06 pm UTC

Re: 1188: "Bonding"

Postby dp2 » Wed Mar 20, 2013 1:38 pm UTC

Klear wrote:
dp2 wrote:For all the obscure topics xkcd covers, why is it programming, one of the most basic geek activities, that evokes such virulent whining about not getting the joke?


Because the joke isn't that good today and people are supposing they are missing some context that would make it funnier?
Or... maybe they're right and they are all missing some context which makes it funnier.

rmsgrey wrote:Because it's the only one in a foreign language?

If he makes a joke about quantum physics or some math theorem, you don't see dozens of posts from non-math people saying "Huh? Whu? This is dumb."

As a programmer and parent, I think it's a sweet comic.

User avatar
Isaac5
Posts: 5
Joined: Mon Feb 01, 2010 1:24 pm UTC

Re: 1188: "Bonding"

Postby Isaac5 » Wed Mar 20, 2013 2:21 pm UTC

Great, another one that I completely don't get.

*Hangs head in shame again*

Gargravarr
Posts: 74
Joined: Mon Dec 21, 2009 8:34 am UTC

Re: 1188: "Bonding"

Postby Gargravarr » Wed Mar 20, 2013 2:23 pm UTC

BAReFOOt wrote:
Gargravarr wrote:Play with me Daddy, forever and ever and ever and... until StackOverflowError.


Not if it’s tail recursive, and the compiler/interpreter optimizes the stack frames away.

Then it can go until the end of all time…

I'm almost semi-sure that JRE doesn't support tail recursion optimization (could be wrong?)
Last edited by Gargravarr on Wed Mar 20, 2013 2:23 pm UTC, edited 1 time in total.

LordKraken
Posts: 2
Joined: Wed Mar 20, 2013 4:34 am UTC

Re: 1188: "Bonding"

Postby LordKraken » Wed Mar 20, 2013 2:23 pm UTC

drachefly wrote:
LordKraken wrote:Man, I loved this. I'm up coding and took a break to read xkcd. Wonderful.

I wrote the program up for the hell of it. Aside from the obvious boilerplate ( like wrap in class{ } ), the only change I needed was that 'throw Ball' has to be 'throw new Ball()'. This is sort of funny in and of itself, since rather the throw the ball back and forth, each time the parent or kid catch the ball he or she tosses it away and pulls a new one out of their pocket to throw.


Nope. You can throw the same ball over and over again. Ball is just Throwable, not an Exception, so it's not like you need to make a new one to reinitialize the stack trace or anything.

Did you even try it with the 'throw Ball' as written?

As for the sequence of events, well, there's no way to get a try/catch to be executed in methods attached to two different objects, so at some point something is going to have to give way and be done by the 'wrong' person. Even if you do everything in Ball and rephrase everything in passive voice.


You are, in fact, correct. Ah well.

Wooloomooloo
Posts: 128
Joined: Wed Mar 16, 2011 8:05 am UTC

Re: 1188: "Bonding"

Postby Wooloomooloo » Wed Mar 20, 2013 2:32 pm UTC

dp2 wrote:For all the obscure topics xkcd covers, why is it programming, one of the most basic geek activities, that evokes such virulent whining about not getting the joke?

Because, I suppose, humor is an extremely subjective thing - I suppose there is stuff a lot of people tend to find funny and other stuff that decidedly few do (dead babies etc.) but to be honest for me this didn't even elicit mild amusement and I think more than a few felt the same way about it (and yes, for the record, I do have a basic grasp of the technicalities involved in the joke). I have a theory that programmer jokes tend to put way too much emphasis on the "technical cleverness" of the construct, in detriment of the actual wide-reaching humor - and that (failing to grasp what actually has wide social appeal) is indeed quintessentially geeky (/nerdy/dorky/letsnotgothereplease).

joeyadams
Posts: 6
Joined: Wed Nov 11, 2009 1:01 am UTC

Re: 1188: "Bonding"

Postby joeyadams » Wed Mar 20, 2013 2:35 pm UTC

Here's a Haskell implementation, throwing a Ball as an asynchronous exception between two threads:

Code: Select all

{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Concurrent
import Control.Exception as E
import Control.Monad
import Data.Typeable

data Ball = Ball deriving (Show, Typeable)
instance Exception Ball

wait :: IO ()
wait = threadDelay 500000

main :: IO ()
main = do
    parent <- myThreadId
    child <- forkIO $ forever $ mask_ $
        wait `E.catch` \(b :: Ball) -> wait >> throwTo parent b
    throwTo child Ball
    forever $ mask_ $ wait `E.catch` \(b :: Ball) -> wait >> throwTo child b


Fun exercise: extend this to "juggling" by throwing a couple more balls, and adjusting the delays so the parent and child don't kill each other.

User avatar
peewee_RotA
Posts: 504
Joined: Mon Dec 12, 2011 1:19 pm UTC

Re: 1188: "Bonding"

Postby peewee_RotA » Wed Mar 20, 2013 2:39 pm UTC

rmsgrey wrote:
dp2 wrote:For all the obscure topics xkcd covers, why is it programming, one of the most basic geek activities, that evokes such virulent whining about not getting the joke?


Because it's the only one in a foreign language?


I think it's basic geek nature when they see bad code to comment and keep it inline.
"Vowels have trouble getting married in Canada. They can’t pronounce their O’s."

http://timelesstherpg.wordpress.com/about/

Kit.
Posts: 1117
Joined: Thu Jun 16, 2011 5:14 pm UTC

Re: 1188: "Bonding"

Postby Kit. » Wed Mar 20, 2013 2:56 pm UTC

peewee_RotA wrote:
rmsgrey wrote:
dp2 wrote:For all the obscure topics xkcd covers, why is it programming, one of the most basic geek activities, that evokes such virulent whining about not getting the joke?

Because it's the only one in a foreign language?

I think it's basic geek nature when they see bad code to comment and keep it inline.

Hmm... not getting it again... did you want to say: "To comment it out and keep it in line"?

Story
Posts: 78
Joined: Wed Aug 26, 2009 9:03 pm UTC

Re: 1188: "Bonding"

Postby Story » Wed Mar 20, 2013 3:03 pm UTC

Gargravarr wrote:
BAReFOOt wrote:
Gargravarr wrote:Play with me Daddy, forever and ever and ever and... until StackOverflowError.


Not if it’s tail recursive, and the compiler/interpreter optimizes the stack frames away.

Then it can go until the end of all time…

I'm almost semi-sure that JRE doesn't support tail recursion optimization (could be wrong?)


It doesn't. It's infeasible to do TCO in the JVM for technical reasons.

Ended
Posts: 1459
Joined: Fri Apr 20, 2007 3:27 pm UTC
Location: The Tower of Flints. (Also known as: England.)

Re: 1188: "Bonding"

Postby Ended » Wed Mar 20, 2013 3:08 pm UTC

Kit. wrote:I'm not getting the part about Eclipse. Does it crash while trying to parse this code or what?

It's a pun on the phrase "build character": to make oneself (or someone else) a better person, or to compile a coding project called "character".
Generally I try to make myself do things I instinctively avoid, in case they are awesome.
-dubsola

User avatar
peewee_RotA
Posts: 504
Joined: Mon Dec 12, 2011 1:19 pm UTC

Re: 1188: "Bonding"

Postby peewee_RotA » Wed Mar 20, 2013 3:35 pm UTC

Kit. wrote:
peewee_RotA wrote:
rmsgrey wrote:
dp2 wrote:For all the obscure topics xkcd covers, why is it programming, one of the most basic geek activities, that evokes such virulent whining about not getting the joke?

Because it's the only one in a foreign language?

I think it's basic geek nature when they see bad code to comment and keep it inline.

Hmm... not getting it again... did you want to say: "To comment it out and keep it in line"?

I think I see the source of your confusion. It's a double entendre. Comment as in to respond in the post which could be interpreted as commenting a line of code. Then inline as in an inline comment (//) which could be interpreted as keeping someone from acting in an unacceptable way.

Don't let the explanation end this conversation. IDE rather keep it going.
"Vowels have trouble getting married in Canada. They can’t pronounce their O’s."

http://timelesstherpg.wordpress.com/about/

sonoftunk
Posts: 11
Joined: Thu Feb 25, 2010 3:50 am UTC

Re: 1188: "Bonding"

Postby sonoftunk » Wed Mar 20, 2013 4:20 pm UTC

peewee_RotA wrote:
Kit. wrote:
peewee_RotA wrote:
rmsgrey wrote:
dp2 wrote:For all the obscure topics xkcd covers, why is it programming, one of the most basic geek activities, that evokes such virulent whining about not getting the joke?

Because it's the only one in a foreign language?

I think it's basic geek nature when they see bad code to comment and keep it inline.

Hmm... not getting it again... did you want to say: "To comment it out and keep it in line"?

I think I see the source of your confusion. It's a double entendre. Comment as in to respond in the post which could be interpreted as commenting a line of code. Then inline as in an inline comment (//) which could be interpreted as keeping someone from acting in an unacceptable way.

Don't let the explanation end this conversation. IDE rather keep it going.


I would love to Integrate myself into this conversation, but the only recent Developments I know about are about the Environment.

poslundc
Posts: 7
Joined: Fri Jun 08, 2012 4:05 pm UTC

Re: 1188: "Bonding"

Postby poslundc » Wed Mar 20, 2013 4:24 pm UTC

The program would get a bad grade but I still let out an "aww" when I read through the end and comprehended the purpose. Maybe it helped that I hadn't read the title yet.

Dan.

mattholimeau
Posts: 16
Joined: Wed Nov 03, 2010 8:37 pm UTC

Re: 1188: "Bonding"

Postby mattholimeau » Wed Mar 20, 2013 4:32 pm UTC

To those of you who are complaining that the code is wrong because the same person throws then catches the ball, I think you missed the funniest part of the joke.

The parent aims at the child, throws the ball at the child, the ball hits the child in the head, bounces back, the parent catches the ball, repeat. This is bonding. (And in fact, a hilarious and apt metaphor for parenting, imho.)

To those complaining that it doesn't compile because its in all caps - pay more attention to the font. The letters that are actually capitalized are slightly taller than the others. This in fact uses correct Java casing.

flamewise
Posts: 35
Joined: Tue Oct 05, 2010 2:40 pm UTC

Re: 1188: "Bonding"

Postby flamewise » Wed Mar 20, 2013 4:57 pm UTC

Ended wrote:
Kit. wrote:I'm not getting the part about Eclipse. Does it crash while trying to parse this code or what?

It's a pun on the phrase "build character": to make oneself (or someone else) a better person, or to compile a coding project called "character".


I read as secondary meaning that trying to catch balls thrown to each other during a solar eclipse is hard when it's dark.

It's a pity that you can't really use the font drawn in the comic for title tags, to obfuscate the capitalization.

dp2
Posts: 346
Joined: Wed Aug 18, 2010 3:06 pm UTC

Re: 1188: "Bonding"

Postby dp2 » Wed Mar 20, 2013 5:25 pm UTC

peewee_RotA wrote:
Kit. wrote:
peewee_RotA wrote:
rmsgrey wrote:
dp2 wrote:For all the obscure topics xkcd covers, why is it programming, one of the most basic geek activities, that evokes such virulent whining about not getting the joke?

Because it's the only one in a foreign language?

I think it's basic geek nature when they see bad code to comment and keep it inline.

Hmm... not getting it again... did you want to say: "To comment it out and keep it in line"?

I think I see the source of your confusion. It's a double entendre. Comment as in to respond in the post which could be interpreted as commenting a line of code. Then inline as in an inline comment (//) which could be interpreted as keeping someone from acting in an unacceptable way.

Don't let the explanation end this conversation. IDE rather keep it going.

Exceptional post.

DaveInsurgent
Posts: 207
Joined: Thu May 19, 2011 4:28 pm UTC
Location: Waterloo, Ontario

Re: 1188: "Bonding"

Postby DaveInsurgent » Wed Mar 20, 2013 5:45 pm UTC

This is not real Java code. Where is the BallFactory? Seriously though, that would add to the pun.

Also seriously - not every comic has to be "funny". I found this one whimsical.

User avatar
peewee_RotA
Posts: 504
Joined: Mon Dec 12, 2011 1:19 pm UTC

Re: 1188: "Bonding"

Postby peewee_RotA » Wed Mar 20, 2013 5:52 pm UTC

dp2 wrote:
peewee_RotA wrote:
Kit. wrote:
peewee_RotA wrote:
rmsgrey wrote:
dp2 wrote:For all the obscure topics xkcd covers, why is it programming, one of the most basic geek activities, that evokes such virulent whining about not getting the joke?

Because it's the only one in a foreign language?

I think it's basic geek nature when they see bad code to comment and keep it inline.

Hmm... not getting it again... did you want to say: "To comment it out and keep it in line"?

I think I see the source of your confusion. It's a double entendre. Comment as in to respond in the post which could be interpreted as commenting a line of code. Then inline as in an inline comment (//) which could be interpreted as keeping someone from acting in an unacceptable way.

Don't let the explanation end this conversation. IDE rather keep it going.

Exceptional post.


I wanted to fill this thread with endless jokes about thumb tacks but that just creates tack overflow
"Vowels have trouble getting married in Canada. They can’t pronounce their O’s."

http://timelesstherpg.wordpress.com/about/

User avatar
Moonfish
Posts: 34
Joined: Sat May 24, 2008 10:40 am UTC
Location: San Diego, California

Re: 1188: "Bonding"

Postby Moonfish » Wed Mar 20, 2013 6:57 pm UTC

Just Let Yourself Goto Your Children

Try catch statements fracture the structure of code body’s basic blocks. This whole notion of optimizing a relationship by throwing things around is an idealistic an unobtainable myth. Why can’t the parent and child work together in a stack based loop? Heaven forbid one just go to the other.

Try catch statements:
  • Promote an “I’ll handle that later” approach to implementation (permissible in design not code).
  • Reduce maintainability by disrupting code order and compartmentalization.
  • Render optimization techniques like static single assignment ineffective.
Try catches are lazy, one should write the handler in place of the throw statement instead of passing the buck up the chain.
Image

dp2
Posts: 346
Joined: Wed Aug 18, 2010 3:06 pm UTC

Re: 1188: "Bonding"

Postby dp2 » Wed Mar 20, 2013 7:52 pm UTC

Moonfish wrote:
Just Let Yourself Goto Your Children

Try catch statements fracture the structure of code body’s basic blocks. This whole notion of optimizing a relationship by throwing things around is an idealistic an unobtainable myth. Why can’t the parent and child work together in a stack based loop? Heaven forbid one just go to the other.

Try catch statements:
  • Promote an “I’ll handle that later” approach to implementation (permissible in design not code).
  • Reduce maintainability by disrupting code order and compartmentalization.
  • Render optimization techniques like static single assignment ineffective.
Try catches are lazy, one should write the handler in place of the throw statement instead of passing the buck up the chain.

Fair points, but certainly not catch-all. It's usually bad form to hide errors in a library, say. You often want to let the client know what happened, not try and fix it for them. You don't know how they want the error handled.

User avatar
Whizbang
The Best Reporter
Posts: 2238
Joined: Fri Apr 06, 2012 7:50 pm UTC
Location: New Hampshire, USA

Re: 1188: "Bonding"

Postby Whizbang » Wed Mar 20, 2013 8:36 pm UTC

Maybe the up-tick in complaints on programming comics is due to the inability to Google anything about them.

Googling "What the hell gibberish is this shit?" doesn't help much. Even copying lines of code into a Google search bar won't yield anything meaningful.

Patrik3
Posts: 112
Joined: Tue Aug 14, 2012 1:45 pm UTC

Re: 1188: "Bonding"

Postby Patrik3 » Wed Mar 20, 2013 9:07 pm UTC

gormster wrote:I remember when this site used to have comics on it.


Agreed. I know this is a nerdy comic and that's why I love it, but there've been several 'programming'-based jokes in the last couple of weeks and, having regrettably not yet learned any programming, I'm not finding the comic very funny... And yeah, since when did the term "comic" cover panels that were comprised of text and no images? Graph-jokes are a bit of a cop-out but this just feels lame.

Psylent
Posts: 1
Joined: Wed Mar 20, 2013 9:16 pm UTC

Re: 1188: "Bonding"

Postby Psylent » Wed Mar 20, 2013 9:32 pm UTC

Loving the latest computer science jokes! I've missed them!

User avatar
Moose Anus
Posts: 430
Joined: Fri Oct 14, 2011 10:12 pm UTC

Re: 1188: "Bonding"

Postby Moose Anus » Wed Mar 20, 2013 9:39 pm UTC

Patrik3 wrote:
gormster wrote:I remember when this site used to have comics on it.


Agreed. I know this is a nerdy comic and that's why I love it, but there've been several 'programming'-based jokes in the last couple of weeks and, having regrettably not yet learned any programming, I'm not finding the comic very funny... And yeah, since when did the term "comic" cover panels that were comprised of text and no images? Graph-jokes are a bit of a cop-out but this just feels lame.
I assume Randall has been on a coding bender and is getting his ideas from that.
Lemonade? ...Aww, ok.

Kit.
Posts: 1117
Joined: Thu Jun 16, 2011 5:14 pm UTC

Re: 1188: "Bonding"

Postby Kit. » Wed Mar 20, 2013 9:42 pm UTC

peewee_RotA wrote:
Kit. wrote:
peewee_RotA wrote:
rmsgrey wrote:
dp2 wrote:For all the obscure topics xkcd covers, why is it programming, one of the most basic geek activities, that evokes such virulent whining about not getting the joke?

Because it's the only one in a foreign language?

I think it's basic geek nature when they see bad code to comment and keep it inline.

Hmm... not getting it again... did you want to say: "To comment it out and keep it in line"?

I think I see the source of your confusion. It's a double entendre. Comment as in to respond in the post which could be interpreted as commenting a line of code. Then inline as in an inline comment (//) which could be interpreted as keeping someone from acting in an unacceptable way.

Ah, line comments. Frankly, I wouldn't consider using them for commenting out bad code: there's just too much of it.

One of the reasons to love C++ is that #if 0 is perfect for the task.

User avatar
Moonfish
Posts: 34
Joined: Sat May 24, 2008 10:40 am UTC
Location: San Diego, California

Re: 1188: "Bonding"

Postby Moonfish » Wed Mar 20, 2013 11:26 pm UTC

There must be someone around here who’s up for a debate about the detrimental effects of Try-Catch blocks on single static assignment optimization or code flow. Some times I feel like the XKCD forum is filling up with people un-interested in lively discussions about either compiler theory or software design for example. I was kind of expecting someone to at least make a raptor reference about my assertion that Try-Catches are worse than Gotos. At the very least I was hoping that someone would point out that Java doesn't even implement Goto.

Try catch statements:
  • Promote an “I’ll handle that later” approach to implementation (permissible in design not code).
  • Reduce maintainability by disrupting code order and compartmentalization.
  • Render optimization techniques like static single assignment ineffective.


If you don't like jokes written in Java then maybe XKCD isn't for you.
Personally I find them very funny.

SamSam
Posts: 22
Joined: Fri Apr 03, 2009 4:00 pm UTC

Re: 1188: "Bonding"

Postby SamSam » Wed Mar 20, 2013 11:45 pm UTC

mattholimeau wrote:To those of you who are complaining that the code is wrong because the same person throws then catches the ball, I think you missed the funniest part of the joke.

The parent aims at the child, throws the ball at the child, the ball hits the child in the head, bounces back, the parent catches the ball, repeat. This is bonding. (And in fact, a hilarious and apt metaphor for parenting, imho.)


That might be funny, but isn't actually correct at all.

After parent first catches his own ball, he calls "target.aim(ball)". This calls aim on target, which is child. So child then tries to aim, throws, and catches his own ball. Repeat.

User avatar
StClair
Posts: 408
Joined: Fri Feb 29, 2008 8:07 am UTC

Re: 1188: "Bonding"

Postby StClair » Thu Mar 21, 2013 12:04 am UTC

My alternate for the strip title:

O=C=O

User avatar
Sean
Posts: 3
Joined: Sat Oct 25, 2008 11:50 am UTC
Location: London, UK

Re: 1188: "Bonding"

Postby Sean » Thu Mar 21, 2013 1:01 am UTC

dp2 wrote:As a programmer and parent, I think it's a sweet comic.


As a programmer and a dog owner, I agree.

User avatar
Eternal Density
Posts: 5579
Joined: Thu Oct 02, 2008 12:37 am UTC
Contact:

Re: 1188: "Bonding"

Postby Eternal Density » Thu Mar 21, 2013 3:20 am UTC

da Doctah wrote:
tibfulv wrote:
CasualSax wrote:I don't really get the humor of this one, and I know Java. Meh.


Amongst others, it's a pun. The try-throw-catch sequence is a way to handle errors in Java IIRC.
Finally!
You win the thread :D We might as well suspend it here.
Play the game of Time! castle.chirpingmustard.com Hotdog Vending Supplier But what is this?
In the Marvel vs. DC film-making war, we're all winners.

User avatar
super_aardvark
Posts: 54
Joined: Tue Jan 22, 2008 9:26 am UTC

Re: 1188: "Bonding"

Postby super_aardvark » Thu Mar 21, 2013 6:01 am UTC

tentative wrote:Would've been funnier if the metaphor wasn't broken by the content.
parent and child aren't aiming and throwing a Ball for each other to catch.
Rather, each is throwing and catching a Ball, then handing it to the other (until stack depth is exceeded).

A possible fix:

Code: Select all

class Ball extends Throwable {}
public class P {
   P target;
   P(P target) {
      this.target = target;
   }
   void aim() throws Ball {
      try {
         target.aim();
      }
      catch (StackOverflowError e) {
         throw new Ball();
      }
      catch (Ball b) {
         throw b;
      }
   }
   public static void main(String[] args) {
      P parent = new P(null);
      P child = new P(parent);
      parent.target = child;
      try {
         parent.aim();
      }
      catch (Ball b) {
         System.exit(0);
      }
   }
}


A fix more faithful to the metaphor would require messing with the stack,
but I don't know if that's possible in Java.
Now, if this was python...


This made me laugh when I imagined two people playing catch this way. The parent aims at the child. The child aims at the parent. The parent aims at the child again, etc etc etc etc etc.... Then when they've had enough of aiming, one of them pulls out a ball and they throw it back and forth in a flurry until all their aiming is used up.

Kit.
Posts: 1117
Joined: Thu Jun 16, 2011 5:14 pm UTC

Re: 1188: "Bonding"

Postby Kit. » Thu Mar 21, 2013 6:13 am UTC

Moonfish wrote:There must be someone around here who’s up for a debate about the detrimental effects of Try-Catch blocks on single static assignment optimization or code flow. Some times I feel like the XKCD forum is filling up with people un-interested in lively discussions about either compiler theory or software design for example. I was kind of expecting someone to at least make a raptor reference about my assertion that Try-Catches are worse than Gotos. At the very least I was hoping that someone would point out that Java doesn't even implement Goto.

Think of exceptions as of an automated way to handle variant type returns. Then they won't look so scary.

Besides, exceptions provide an alternative to the only good use of goto in the "structured programming".

Moonfish wrote:
Try catch statements:
  • Promote an “I’ll handle that later” approach to implementation (permissible in design not code).
  • Reduce maintainability by disrupting code order and compartmentalization.
  • Render optimization techniques like static single assignment ineffective.


I'm not convinced in any of this. In particular, in Randall's example all what you wrote applies not to the try-catch statement, but to target.aim(b). Does it mean that we shouldn't use references to functions (as well as their OO equivalents)?


Return to “Individual XKCD Comic Threads”

Who is online

Users browsing this forum: DwayneSa and 104 guests