Subject: Re: "Choose the Right Language" in "Tutorial" by Norvig and Pitman
From: Erik Naggum <erik@naggum.net>
Date: Thu, 18 Apr 2002 09:44:42 GMT
Newsgroups: comp.lang.lisp
Message-ID: <3228111881824368@naggum.net>

* "Marc Battyani" <Marc.Battyani@fractalconcept.com>
| Here is a nice extract from it.
| 
| Recursion
| An XEXPR interpreter is not guaranteed to be safely tail recursive, even
| though recursion is allowed. As such, it is generally better to use an
| iterative form rather than a tail recursive form.
| The following defines the linear recursive form of factorial. This is simple
| to code, and easy to understand, but for large numbers, it may cause a stack
| overflow.
| <define name="factorial" args="x">
|  <if>
|    <lt><x/>2</lt>
|    <x/>
|    <multiply>
|      <x/>
|      <factorial><subtract><x/>1</subtract></factorial>
|    </multiply>
|  </if>
| </define>
| 
| Brilliant no ?

  Let me recast this into my syntax, which also considers whitespace no
  evil:

<define <name factorial> <args x>
  <if <lt x 2>
    <x>
    <multiply <x> <factorial <subtract <x> 1>>>>>

  Now, let me remove the tremendously stupid reference to X via an element
  and call simple arithmetic functions by reasonable names:

<define <name factorial> <args x>
  <if <lt x 2>
    x
    <* x <factorial <- x 1>>>>>

  Not so bad, I think.  But the massive stupidity of XML's redundant
  end-tags should be ever more evident.  Sigh.  Like, I receive this
  HTML-ified newsletter every Friday, and each message is from 24K to 32K
  large.  I rewrote it into my syntax, preserving all the HTML crap, but
  removing all the redundant whitespace.  The results were from 6K to 9K
  large.  Then I sanitized the table crap and made it into macro forms and
  removed the redundant font elements, and the results were from 3K to 5K.
  It is quite fascinating that people are willing to work with data formats
  that are 8 times more verbose than they trivially need to be, requiring 8
  times more network bandwidth or time to send out newsletters by mail.  Of
  course, these are the same people who think XML is better than shipping
  Word documents around.  I just wait to see a Word-in-XML document that
  takes a minute to ship over megabit-lines and which says "Hello, world!".

///
-- 
  In a fight against something, the fight has value, victory has none.
  In a fight for something, the fight is a loss, victory merely relief.

  Post with compassion: http://home.chello.no/~xyzzy/kitten.jpg