Showing posts with label humor. Show all posts
Showing posts with label humor. Show all posts

20 March 2013

how simple things can go awfully wrong

You know programming languages? At least one or two?

A two-liner, without any regular expression, should not be a too-great adventure...

Try the following in your favorite language:

i = 1
i += ++i + ++i

A simple assignment to an integer variable, some forms of add-operators.

They're evil - believe me. Things go wrong from here:

Let's analyse the expression in a functional way:

  • With i set to 1, the first ++i should yield 2.
  • Calculate the two of them one-after-the other, the second one yields 3.
  • Calculate the two of them in parallel, both yield 2.

So - the result should be something between 5 and 6.

Let's try Ruby first:

ruby-fails

Slightly off any sensible calculation. Consider it "failed".

Move on with Java:

java funny expression

Believe me, C# and JavaScript and some other JVM languages come to the same conclusion.

But we're not finished here. Fire up your command line and type:

awk 'BEGIN {i=1; i+= ++i + ++i; printf i}'

Puuh - yields 8. Eight. Seems a bit off for me, but awk might have reasons.

We'll check that with php in a second:

 

NewImage

 

Eight again. So many commercial websites are build with php - and they all calculate like that? re-consider your e-commerce behaviour...

Now, if you happen to have one of those wonderful GNU-C compilers installed - try out the objective-C variant of this expression: You will see eight again. Two more than with Java.

 

Finally, the mother of all programming languages, the common ground of all platforms, the C programming language:

#include <stdio.h>
int main(int argc, const char* argv[]) {
int i = 1;
i += ++i + ++i;
printf("i+= ++i + ++i liefert %i\n", i);
return 0;
}
==> 9

I have to declare it the winner of this informal competition. At least numerically the winner: Nine. 9. Three times three.

Three times what Ruby calculates. 30% more than Java and C#. Btw, compiled with the same GNU compiler that found 8 to be the answer for Objective-C. 

 If you check that with Perl, fine: Nine again:

#!/usr/bin/perl
$i=1;
$i += ++$i + ++$i;
print "i = ".$i."\n";
print "\n\n";
==> 9

I personally stopped laughing here: If we stumble upon two-liners, what about real programs, with memory, sync/async, concurrency and UI issues? With changing requirements?

 

Eventually, thinking (!) about your software might help, so instead of "test driven" or "behavior driven" or "nerd driven", what about "thought driven development" (as Rich Hickey pointed out in his famous speech "Hammmock Driven Development"

 

As a sidenote: Cobol outputs 6. I did not find any solution less than 3, nor one greater than 9.

PS: Thanx to Franz Antesberger for this nice riddle!

31 May 2010

Dropbox and Cactuses or Cacti?

I really like Dropbox and their fantastic sync service - a serious and valuable software, highly reliable, stable and efficient.

Once in a while I even read some of their forum discussions - you get quick responses and no-nonsense discussions.

But today they (aahm - some users) talked about Caci or Cactuses. Yes - the plants with spikes or stings. Made me laugh...


03 October 2009

old - but still great'n true: How NOT to wrap your product...

I've seen it in different flavors - but this video made me really laugh:



(if the embedded video does not work, try the URL here!)

07 September 2009

"Escheresque" 404...

I admire the folks from Dropbox for their unobtrusive, reliable, high-performance and well-supported service...

While researching some dict.cc updates for my MacBook, I found a link
to the Dropbox-404-Not-Found-Site :-)

Well done...



07 March 2009

One of the coolest things I've seen in a long time...

an absolutely stunning T-Mobile marketing event - happend January 2009 in a London underground station...

From one reviewer at youtube:

Whoever thought of this idea can rest on this one idea for many years to come. Brilliant at many levels. Music can change the world. We've just witnessed it at a railway station in London. And old and young. And black and white. Love this video. Kudos to T-Mobile.

(happend to be my mothers' birthday...)

If you like it, I found its making of video...

22 November 2007

Trunk Monkey: Awesome Videoclips

Here you find four short videoclips about TrunkMonekey - really funny. I liked Monkey3 best!

19 October 2007

To All Fathers: You Still Got A Chance...

VERY funny short film about a young father fighting back: