My Stuff
Email
Twitter
Front Page
Presentations
Projects
Music
Favorite Quotes
Dynamic Language User's Group

Love
Michelle Buxton

Respect
Vincent Foley-Bourgon
Sam Griffith
LeRoy Mattingly
Colin Putney
Matt Secoske
Sam Tesla
Andres Valloud

Admiration
Leo Brodie
Avi Bryant
Alan Cooper
Steve Dekorte
Stephane Ducasse
Doug Engelbart
Eric Evans
Brian Foote
Martin Fowler
Paul Graham
Dan Ingalls
Alan Kay
John McCarthy
Steve McConnell
Peter Norvig
Niall Ross
Randall Smith
Gerald Jay Sussman
David Ungar
Rebecca Wirfs-Brock
...And So Many More...

My Amps
Squeak
JavaScript
Scheme
Java
Corman Lisp
Ruby
Dolphin Smalltalk
Cincom Smalltalk
Self

Archives
05/01/2003 - 06/01/2003
06/01/2003 - 07/01/2003
07/01/2003 - 08/01/2003
08/01/2003 - 09/01/2003
09/01/2003 - 10/01/2003
10/01/2003 - 11/01/2003
11/01/2003 - 12/01/2003
12/01/2003 - 01/01/2004
01/01/2004 - 02/01/2004
02/01/2004 - 03/01/2004
03/01/2004 - 04/01/2004
04/01/2004 - 05/01/2004
05/01/2004 - 06/01/2004
06/01/2004 - 07/01/2004
07/01/2004 - 08/01/2004
08/01/2004 - 09/01/2004
09/01/2004 - 10/01/2004
10/01/2004 - 11/01/2004
11/01/2004 - 12/01/2004
12/01/2004 - 01/01/2005
01/01/2005 - 02/01/2005
02/01/2005 - 03/01/2005
03/01/2005 - 04/01/2005
04/01/2005 - 05/01/2005
05/01/2005 - 06/01/2005
06/01/2005 - 07/01/2005
07/01/2005 - 08/01/2005
08/01/2005 - 09/01/2005
09/01/2005 - 10/01/2005
10/01/2005 - 11/01/2005
11/01/2005 - 12/01/2005
12/01/2005 - 01/01/2006
01/01/2006 - 02/01/2006
02/01/2006 - 03/01/2006
03/01/2006 - 04/01/2006
04/01/2006 - 05/01/2006
05/01/2006 - 06/01/2006
06/01/2006 - 07/01/2006
07/01/2006 - 08/01/2006
08/01/2006 - 09/01/2006
09/01/2006 - 10/01/2006
10/01/2006 - 11/01/2006
11/01/2006 - 12/01/2006
12/01/2006 - 01/01/2007
01/01/2007 - 02/01/2007
02/01/2007 - 03/01/2007
03/01/2007 - 04/01/2007
04/01/2007 - 05/01/2007
05/01/2007 - 06/01/2007
06/01/2007 - 07/01/2007
07/01/2007 - 08/01/2007
08/01/2007 - 09/01/2007
09/01/2007 - 10/01/2007
10/01/2007 - 11/01/2007
11/01/2007 - 12/01/2007
12/01/2007 - 01/01/2008
01/01/2008 - 02/01/2008
02/01/2008 - 03/01/2008
03/01/2008 - 04/01/2008
04/01/2008 - 05/01/2008
05/01/2008 - 06/01/2008
06/01/2008 - 07/01/2008

Feed

Add this feed to a running copy of BottomFeeder

Sunday, June 04, 2006

A Dare

 
I have a simple dare. In fact, it's a triple dog dare to all developers. Are your ready? Here it is:

Stop using the same examples to show how great your favorite technology is.

Programming in general has "Hello, World" and every beginning programming book uses it. Even worse is the heavy use of "foo bar" in all its forms. Used to be cute, but not any more.

But, the worse by far is the fibonacci sequence used by every beginning functional programming article to prove the elegance of recursion or functional pattern matching. Come on. There are examples that prove it much better (pick anything in the real world). And that leads me to the final one...

ATMs are used as the example in almost every book in OO design. It's played to death and no longer interesting. Certainly, there's better examples than that out there now, right? And no, don't continue with the bowling example. It's already a cliche in all of the agile books.

Computer science is an exciting field filled with untapped potential and great ideas. But, cliched examples, while good for comparisons, fall flat in their simplicity. Fibonacci doesn't show the elegance obtained from functional programming. Much like showing that you can create a function to add one to prove the elegance of closures. I think a meatier example grounded in the real world will excite the reader much more. This is my dare. Dare to write an original example that makes me realize how clever you are and not @#$%^& ANOTHER FIBONACCI EXAMPLE?!

Comments
  • Interestingly, mathematics suffers from the same disease. Typically, books will describe all this beautiful theory and finish it off with the next to simplest possible example or application. No good.

    By Blogger Andres, at 1:44 PM   

  • Also, it would be much more interesting to show how some of the properties of the Fibonacci sequence could be used to calculate very large F numbers quite efficiently. For example, it is well known that

    F(a+b) = F(a+1) F(b) + F(a) F(b-1)

    This may say nothing at first, until you want to calculate F(n) and break n in halves. Assuming n = 2k, then

    F(n) = F(k+k) = F(k+1) F(k) + F(k) F(k-1)

    or

    F(n) = F(k) (F(k+1) + F(k-1))

    So if you break n in "good" values of k, you can cache those triplets around say powers of two, and then you're cooking with gas.

    A long time ago, I had implemented fibonacci as the naive sum of terms, and F16525 took so long I had to stop it. With this new algorithm, it took only 10 seconds the first time, and 1.5 seconds the next time. Simple examples also hide this kind of stuff away.

    Think, Luke... use the force but do not be brute!

    By Blogger Andres, at 3:49 PM   

  • And if memory serves right, this is how I found that

    F(p^n) ? p (100)

    Some friends extended the full precision calculator into a mod calculator, applied the mu and lamdba algorithm as shown in Knuth's books, and found that there were MANY OTHER SUCH CONGRUENCES...

    By Blogger Andres, at 3:55 PM   

  • There's an online book "http://users.impulse.net.au/dragoncity/smalltalk_for_mere_mortals.pdf" that has a decent example of recusion. The example on recursion is to print a check amount as text. i.e: $10.00 prints as Ten Dollars and zero cents.

    I haven't looked closely at the code, but there ya go. A non-Fibonacci example.

    By Blogger Brody, at 8:16 PM   

  • http://users.impulse.net.au/dragoncity/smalltalk_for_mere_mortals.pdf


    Contains a reasonable example of recursion in the chapter titled PROGRAMMING WITH RECURSION.

    By Blogger Brody, at 3:00 PM   



Web hosting by ICDSoft

Metalheads Against Racism
This page is powered by Blogger. Isn't yours?


My Weekly Top 20 Artists