User login

Lispy Idioms

Common Lisp has a very long lineage. The large standard library in the :COMMON-LISP package is sort of an akashic record of that long history. It records programming wisdom and knowledge passed down through the generations of Lisp programmers. There is often a very clean, clear, and general facility for performing a task built in to the language.

Other languages were written for different purposes and have different (usually shorter) histories. So they probably won't have the same idioms that Lisp enjoys. When you're translating Java code (or any other language) to Common Lisp, it's all too easy to miss some opportunities for writing clear, lispy code. Simon Alexander has a great post detailing a lispier translation of code that Mike Ajemian translated last week.

This is something I struggle with, too. The learning curve of Lisp is steeper because of the breadth and depth of its library. But the richness that Lisp provides in the end is beautiful to behold. I have learned that before I write a function that seems very useful, I stop and consult the HyperSpec to see if it already exists. Very often it does, and with nice optional parameters that anticipate my needs. Truly, the Lisp gods must be praised.

Comments

Searching Hyperspec

How do you actually find a specific function in the hyperspec?

Good question

There are several ways I have learned to find function names in the huge HyperSpec.

I use (apropos 'word) often to see if I can't find the name of a function that looks like it's useful. I then look up that function using the alphabetical index. http://www.lisp.org/HyperSpec/FrontMatter/Symbol-Index.html The permuted symbol index is nice, too.

I also use lispdoc, which does a search of the HyperSpec as well as some free books. It's a great reference. I think someone has integrated it into a package available at the REPL. http://lispdoc.com/

Lastly, the HyperSpec is also organized by data type. If I want a function that operates on sequences, I can get an overview of all of those functions. http://www.lisp.org/HyperSpec/FrontMatter/Chapter-Index.html

Learning Curve

I'm rather surprised when I hear about the large learning curve. Often the learning curve for recursion is conflated with that for lisp. But once you learn the types of things you can do and how to put them together, learning comes pretty quickly. I also suspect that the learning curve is very much higher for self-study of lisp than it is in a classroom.

Learning a language can be done on one's own, learning the idiom effectively requires a local mentor.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.