Over at the Emacs subreddit, AbstProcDo proposes an interesting idea: some Elisp constructs are very intuitive and natural compared to other languages. He uses the example of dolist
to process a list versus the Python way.
(dolist (item '(1 2 3 4))
(print item))
versus
for item in ['a', 'b', 'c', 'd']: print(item)
It’s a valid point but I think there are better examples to make it. How about
(dotimes (i 10)
(print i))
versus the same in C
for ( i = 0; i < 10; i++) printf( "%i ", i)
The Elisp macro suggests that we want to perform its body for the values \(0 \cdots 9\). The C for
loop construct is all about initializing, incrementing, and terminating the loop. Of course, the same can be said of the Lisp do
construct.
There’s nothing wrong with either of these approaches, of course. I’ve written a lot more C than I have any type of Lisp and the semantics of the for
loop are embedded in my brain. Still, AbstProcDo has a point. The Elisp does seem more natural.
It would be easy to make too much of the comparison and enlist it for use in some sort of language war but that’s not my intention. I merely think it’s a provocative idea and worth thinking about. There are, I’m sure, counter examples, and I’m sure we’ll be learning all about them from the comments.