Summarising a bunch of responses:
On Oct 28, 2011, at 8:10 AM, Tayssir John Gabbour wrote:
>
> Something weird happens when a programmer compares snippets in two
> languages, with even the tiniest subconscious desire to demonstrate
> that his language is better-endowed. This is 100% certain to happen:
> "Here's a lovingly-crafted version in my favorite language. And here's
> yours, coded by drunk monkeys.”
>
I have not claimed that any language is better endowed. If that is your point of issue, then I suspect we have no disagreement. It’s not about me, that’s why I keep mentioning what I think (perhaps incorrectly) as the political dimension. Me? I have earned a good living in the field for 20 years and if the wind shifts to FP/Clojure/RoR/whatever, I suppose I could retain some spot in that landscape and find my way to retirement.
Second, the examples offered were intended and were the opposite of what you imply: the C code was not lovingly crafted version (hence I didn’t write my own version of it) but one of the first search links - a link to a blog post. The Clojure example on the other hand was from someone who seemed to be a professional publishing under the banner of IBM. IOW, I tried to make sure that I was not biasing the examples in favour of my argument.
Moving on: the IBM link was one of the first few links when I searched for Clojure examples (i.e., I did not do a custom search for Fibonacci implementations). If you think live-compose music is a better example of the real world of programming, then we live in entirely different worlds. As for “who learns this way?” - many people do. These sort of functions - Fibonacci, or factorial if you prefer - are what are found in introductory texts and undergraduate and vocational training programming courses.
Compiling vs interpreting: the C code does not compile because it wasn’t intended to. It was intended to provide an example bit of code in one language to compare against another. Replace the function name with main(), add some initial value for ’n’, and with a couple of other changes not relevant to the issue under debate, you can get it to compile. You can step through it if you wish using a debugger. Or you can implement it in Perl or Python if you prefer an interpreter to step through it for you.
Responses to Joanna and JC that relate to the above:
Joanna and JC point out that “x = x + 1” is strange for a student of Algebra. That is quite true, though Pascal IIRC attempts to disambiguate it with the := operator. But this is a comparison, not an absolute claim, and the result of the comparison is expressed in Joanna’s response in which she finds the C code more readable (I am not quoting her verbatim). This, as I mentioned earlier, was the impression I gained from undergraduates learning programming.
JC wonders why “x + y” is more readable than (+ x y). I am not sure I have more to substantiate that than my earlier argument that “x + y” is more familiar.
JC also asks why I think recursion is not intuitive. Actually, I did not mean to imply in that post that it is not. I just mentioned that the C version was not recursive, more for the record, than to draw attention to that (as JC implies, the recursive version might well be simpler!). The C and Clojure versions were taken from the net, to avoid introducing my own personality into the examples (that as well as the fact that I don’t know how to write a line of code in Clojure, or Lisp any more for that matter).
— ravi