Is the Common Lisp 'loop' macro evil?

I must admit to being "old school" when it comes to Lisp coding. I like s-expressions. The loop macro introduces a non s-expression syntax to the language that I find a little uncomfortable. I spent 20 minutes this morning looking for interesting loop example uses and generally playing with them. Definitely some cool stuff, but I think that I will continue to pass on using the loop macro, except when it is already in other people's code - no point in rewriting stuff that works.

Different programming languages have different coding styles that seem to work well and are language specific. As an example, yesterday I wrote some Ruby code with two nested collection collect blocks. I had been coding non-stop in Common Lisp for weeks, and before I checked my new Ruby code into svn, I took another look at it: looked strange at first even though it was a natural Ruby coding style. I looked at it again this morning, after my "thinking in Lisp" mode was temporarily suspended, and the nested collect blocks looked just fine. Amazing how choice of programming language affects the way we think to solve problems.

Comments

  1. I can strongly recommend to read the chapter about LOOP in Peter Seibel's Practical Common Lisp. It is an exceptionally clear explanation how to construct LOOP expressions. Several people who also don't like LOOP use iterate instead which covers more or less the same ground, but is more complete, uses s-expressions throughout and is on top of that extensible.

    ReplyDelete
  2. Thanks Pascal. I just read Peter Seibel's chapter and took a quick look at iterate. If I spent close to 100% of my time coding in Common Lisp, then the loop macro would look better to me (as would iterate). I like concise code which is what loop and iterate are all about. However there is a limit to how many program language features that I can keep "ready at hand" and long term I spend roughly equal amounts of time developing in Lisp, Ruby, and Java. BTW, I find Ruby and Java easier to stay on top of, feature and coding tricks wise, but I prefer Lisp.

    I have considered giving up consulting and just doing product development to earn a living. If I ever do this (difficult because I enjoy consulting), there is almost a 100% probability that I would standardize on Common Lisp.

    ReplyDelete
  3. Mark, can you give us some idea of where those jobs are (product development in Lisp), and what are the prospects for landing one? Maybe in a separate blog post?

    I'm getting back into Lisp, largely via Seibel's book, after a long layover in Java and (most recently) Ruby. Programming professionally in Lisp would be a refreshing change of pace.

    ReplyDelete
  4. Hello David,
    re: Lisp product development: that would be self funded, my taking a little risk hoping for a long tail of revenue. For Lisp programming jobs: I know that they are out there. My current customer just about insists that almost everything be done in Common Lisp. An idea: perhaps Lisp vendors like Franz and LispWorks might have leads on companies needing Lisp development talent.

    ReplyDelete
  5. For what it is worth, I don't care for loop at all. I was going to paste my tirade here, but it occurs to me that I should blog my opinion of the LOOP macro and save it for posterity.

    ReplyDelete
  6. Hello Joseph: Good reasons for avoiding loop. The best reason may be the unpredictability of what the macro expansion is unless you either use loop a lot or use it in simple ways.

    ReplyDelete

Post a Comment

Popular posts from this blog

Ruby Sinatra web apps with background work threads

Time and Attention Fragmentation in Our Digital Lives

My Dad's work with Robert Oppenheimer and Edward Teller