Lisp Lacks Visual Cues
c2.com
c2.com
Actually, you get the same effect in any language. You can tell a lot about, say, a Java program by printing it out, sticking the printout on a wall, and walking back 10 feet. But Lisp's regularity makes this effect richer, more powerful, and workable-with at much smaller scale.
Unfamiliarity reactions are not properties of the unfamiliar thing. When you walk into a space that is brighter or darker than what your eyes are used to, you can't see as well. This does not mean the space "lacks visual cues".
You don't have to use them, but I find inserting the odd keyword arg makes things much easier to read.
Also, wart is like arc in that it's utterly unconcerned about backwards compatibility. It's not meant for building large edifices. That doesn't mean you can't build webapps in it. It does mean that you better write lots of unit tests.
After some time, I found syntax-colored Common Lisp (in SLIME) to be very readable, and I started to find confusing other languages.
It (Lisp's "lack of visual cues") is also an interesting topic, and I think it would be especially interesting if you looked at this while comparing it to Haskell.
I was active at Ward's Wiki from 1999 to 2002. I just spent some seriously nostalgic moments clicking around.
I am not experienced reading Lisp code, but I find the many levels of indentation and the abundance of parentheses overwhelming. I don’t know if this is the case with Common Lisp code.
In Chicken Scheme however, parentheses are interchangable with other brackets – so you can add visual cues through your style if you don’t care much about portability.
(defface paren-face '((((class color) (background dark)) (:foreground "grey20")) (((class color) (background light)) (:foreground "grey70"))) "Face used to dim parentheses.")
(add-hook 'scheme-mode-hook (lambda () (font-lock-add-keywords nil '(("(\\|)" . 'paren-face)))))
I also came across a blog post[1] which includes a slightly more complete solution.
(def map
(-> |list f|
(? (== list []) []
// (: (f (. list)) (map (.. list) f)))))Lisp is the language, where you have to write the AST yourself instead of having a language-defined parser.
Parentheses: ()
Braces: {}
Square brackets (or just Brackets): []
Angle brackets: <>
Python:
def spam(self, eggs):
for egg in eggs:
if egg.color == "white":
egg.crack
Which goes to: xxx xxxx(xxxx, xxxx):
xxx xxx xx xxxx:
xx xxx.xxxxx == "xxxxx":
xxx.xxxxx
CL: (defun spam (eggs)
(dolist (egg eggs)
(when (equal (color-of egg) 'white)
(crack egg))))
(Ignore the fact that this example was clearly written with object-oriented Python in mind :P .)Which goes to:
(xxxxx xxxx (xxxx)
(xxxxxx (xxx xxxx)
(xxxx (xxxxx (xxxxx-xx xxx) 'xxxxx)
(xxxxx xxx))))
I don't think there's a huge difference.You should indent when statements like:
(when (equal foo bar)
(do-something)
So that it doesn't look like: (when (equal (some-long thing)
(that is being compared))
(do-something)First of all, with the python the first things on the lines are:
def for if egg
My eyes are naturally drawn along that list. While I could do the same thing for CL, I find the opening brackets slow me down.
The colons at the end of each of those lines tell me that each of the def, for, and if are one-statement lines. With the CL, I have to backet-count along the line to figure out if everything is on one line.
I can see instantly that ' if egg.color == white: ' is a complete statement, as it is a common pattern. With (when (equal (color-of egg) 'white), I need to bracket count to see where I have got to by the end of the line.
If it were clojure it would look better than the python version since you'd use [] instead of () in a couple of places.