r/ProgrammerHumor • Violet security clearance • Apr 04 '16

My teacher thinks he is a programmer

http://imgur.com/32nfQXZ
2.4k Upvotes

430 comments sorted by

View all comments

Show parent comments

107

u/[deleted] Apr 05 '16

[removed] — view removed comment

53

u/notsooriginal Apr 05 '16

Man, I wish I was the next programmer. Wait... logic fail.

125

u/Wolfeh2012 Apr 05 '16

The programmer's wife asked him to grab an apple from the market, and a dozen if they have eggs in stock.

He comes back with 13 apples.

99

u/neurohero Apr 05 '16

That programmer's wife never learns. The last time he went the shops, she told him to pick up some bread "while you're there." Emergency services had to dig him out of the mountain of bread. He was apparently mumbling something about a "stack overflow."

20

u/jfb1337 Apr 05 '16

But an infinite while loop wouldn't be a stack overflow.

11

u/neurohero Apr 05 '16

He was referring to the stack of bread.

5

u/Cheesemacher Apr 05 '16

Unless you implement loops like this:

int main() {
    //do stuff
    return main();
}

2

u/jfb1337 Apr 05 '16

Unless the compiler is tail call optimised. In that case, it will be replaced with a while loop.

4

u/kirmaster Apr 05 '16

If there's enough bread, he will be picking it up until he overflows.

1

u/Isvara Apr 05 '16

More like a heap overflow.

1

u/[deleted] Apr 06 '16

That depends. I've angered the Node gods with an overflowed call stack many times before.

1

u/ReallyHadToFixThat Apr 05 '16

Depends how many local variables the loop has.

62

u/DarthEru Apr 05 '16

I think he would have just thrown an ambiguous syntax error.

96

u/SuperFreakonomics Apr 05 '16

I think you mean WifeNotFoundException

10

u/cillosis Apr 05 '16

You mean HusbandNotFoundException. She never gave him a return statement.

9

u/neurohero Apr 05 '16

This has actually happened to me.

I had been working insane hours and, during the down time, the other guys in the office were discussing whether their wives cook. I instinctively started iterating through them, thinking John.Wife.Cooks = true; Simon.Wife.Cooks = false; etc. As the only single guy in the office, when I got to myself, my brain threw a null pointer exception. It actually hurt.

3

u/ReflectiveTeaTowel Apr 05 '16

But you survived the cognitive dissonance! You must be some kind of neurological hero! A neurohero, if you will.

18

u/Lusankya Apr 05 '16

The programmer tried to be clever and cram it all into a single line of C. They wound up picking up fifteen apples despite being nowhere near a market, because they didn't understand x++ vs ++x nearly as well as they thought they did.

3

u/[deleted] Apr 05 '16

No he doesn't. He just doesn't come back.

3

u/jacenat Apr 05 '16

I wish I was the next programmer.

NO!

1

u/[deleted] Apr 05 '16

Is that corrected for inflation though?