Subject: Languages as Safety Nets

From: Shlomi Fish <[email-masked]>
Date: Thu, 26 Sep 2002 20:54:50 +0300 (IDT)

I went out to the "Great Language Shootout" site and looked at the
Fibonnaci example. Surprisingly O'Caml out-performed C by far. Then I
looked better and guess what? It was this:

f(0) = 0
f(1) = 1
f(n >= 2) = f(n-1) + f(n-2)

Which as is known is a brain-dead, tree-recursive, exponential time way to
calculate the Fibonnaci series. But in O'Caml it works because it is
functional and has good caching. Does not work in Haskell, because of its
Lazy Evaluation, and does not work in C or in Perl, because these languages
do as they are told.

This naturally made me think of Joel Spolsky's "Back to Basics" article where
he says that:

strcpy(dest,src1)
strcat(dest,src2)
strcat(dest,src3)

is brain-dead because the pointer keeps starting from the start of dest.
In Perl or Java on the other hand, where strings are of arbitrary length
and contain their number of elements, it will work fine. I once modified a
portion of Freecell Solver from the exact same side-effect (without Joel had
anything to do with it, I just realized it was a bad idea)

Now, the question is what next? How can the languages of the future save
programmers from themselves? Or should they?

Regards,

    Shlomi Fish

There is no IGLU Cabal! It was implemented in a language which had an Oracle
for an NP-Complete Problem and thus became deprecated.

----------------------------------------------------------------------
Shlomi Fish        [email-masked]
Home Page:         http://t2.technion.ac.il/~shlomif/
Home E-mail:       [email-masked]

"Let's suppose you have a table with 2^n cups..."
"Wait a second - is n a natural number?"