HACKER Q&A
📣 lopatin

LISPers, do you use homoiconicity (code-as-data)?


So IMO the biggest reason to use LISP over other languages that also provide first class functions and closures is homoiconicity. On the other hand, when I was using LISPs as my primary language, I found that I wasn't using this feature as much as I imagined I would. And when I did, it was arguably superfluous.

So my question is two fold:

1. Do you have any examples (aside from PL/compiler related work) that LISPs code-as-data features are used to solve problems that otherwise would have been much harder?

2. Given that you've likely substituted 50,000 lines of Java code with 300 lines of LISP, it goes without saying that you are a lone wolf programmer. But do you, yourself, ever have trouble understanding what you've written after some time? Also, how do your refactors go? Do you do them at all?


  👤 daly Accepted Answer ✓
Quite a lot, actually.

Polynomials can be easily manipulated, such as taking a derivative, and the result is still valid executable code.

Macros use homoiconicity all the time, doing code walking and code expansion.

Functions can construct and return functions easily.


👤 kehrin
I'm new to LISP but the way Hiccup (https://github.com/weavejester/hiccup) in Clojure allows to embeds HTML in Clojure code feels really powerful.