Tuesday, June 11

Two programmer's jokes. Wrong jokes.

A mother said to her programmer son, "While you're out, buy some bread."
Her son never came home.
The mother created an infinite loop because no exit condition is given:
while (you are out){buy bread;}
So the programmer keeps buying bread, with no way to exit the loop.
Actually, as I said in the title, the joke is wrong. When the store is out of bread, or the programmer is out of money, or when the programmer keep bugging the store attendant for buying bread, the store attendant is not able to assist others (CPU intensive task), or at the time the store is closed, an exception is thrown. I should be more clear: the programmer is thrown out of the store. When he is out of money, the only way for him to do is to return home.

The next day, the mother said:  "Could you please go to the store for me and buy one carton of milk, and if they have eggs, get 6!" 
A short time later the programmer son comes back with 6 cartons of milk.
This programmer is not a good programmer. After he buys one carton of milk, he checks the condition of (they have eggs) and finds the condition is fulfilled, he should buy 6 cartons again. So he should go home with 7 cartons of milk!
buy one carton of milk
if (they have eggs){
    buy 6