On Oct 28, 2011, at 10:40 AM, Fernando Cassia wrote:
> The "everything is a string" approach is pure genius.
Why is that more "pure genius" than "code is data" ?
==========================
To ravi:
Why is recursion not intuitive ? Why isn't polish notation not mainstream ?
Honestly, don't you think that even 6 years old can get that:
(add-everything-that-follows 1 2 3 4 5 6 7 8 9)
is equivalent and easier to handle and smarter and better looking than:
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9
As for recursion (quote from Paul Graham's "ANSI Comon Lisp", p.17):
"A better metaphor for a function would be to think of it as a process one goes through. Recursion is natural in a process. We often see recursive processes in everyday life. For example, suppose a historian was interested in population changes in European history. The process of examining a document might be as follows:
1. Get a copy of the document. 2. Look for information relating to population changes. 3. If the document mentions any other documents that might be useful, examine them.
This process is easy enough to understand, yet it is recursive because the third step could entail one or more applications of the same process."
That's easy enough to grasp. And with a few exercises (like the first part of SICP, and that is really trivial, unlike the rest...) you're ready to work with recursion for the rest of your programming career.
Last but not least, you write :
> void fibonacci(int n)
> {
> int a = 0, b = 1;
> int sum;
> int i;
>
> for ( i = 0; i < n; i++ )
> {
> printf("%d\n”, a);
> sum = a + b;
> a = b;
> b = sum;
> }
> }
>
> My claim is that the second is familiar (from training in middle school Algebra),
But in middle school Algebra you never learn things like i++ or rather i = i + 1. _That_ is impossible in Algebra and that is extremely counter intuitive.
See Armstrong in his "Programming Erlang" (I'm lucky that part in online):
http://media.pragprog.com/titles/jaerlang/GettingStarted.pdf
(search for "Algebra").
In middle school you never have to declare types either. And C does not do fractions. In Lisp (I use gauche, a Scheme implementation) you can have:
gosh> (+ 1/2 2/3) 7/6
How more intuitive can that get ?
JC