I'm currently learning Lisp, and I think that I got the basics (I'm using the excellent book Land of Lisp, and so far I've read and worked through about a quarter).
I try to create my own Lisp programs, based on what I already learned. Somehow, it works. But it's only somehow. So far I have been developing mainly in languages with C syntax, such as C# and JavaScript (and please note that I'm perfectly aware that JavaScript is not a C-based language).
Nevertheless, I'm used to "think" in C syntax, and when I write code in C# or JavaScript, I can write it down in a quite straightforward way. In contrast, when writing Lisp code I have enormous difficulties wrapping my mind around all those parentheses.
If I have a simple statement such as
(setf x (+ 2 3))
I always find myself in trying to read it from left to right, find out that it does not work, then search for the innermost pair of parentheses, and then work it out inside-out. For this simple expression, this works quite fast.
But if I have more complex code (although it is not yet complex at all), say a function that uses let
, it's harder (at least for me) to find the innermost pair of parentheses:
(defun foo ()
(let ((x 23)
(y 42))
(+ x y)))
Here it's already a little bit harder to see what happens after what, and what is nested to what. Now add some cond
stuff, perhaps combined with a few lambda
s, and I'm perfectly lost and find myself counting parentheses for minutes (literally).
The same is true when writing it, I get lost in the number of parentheses, and I don't think that I even saw "complex" Lisp code yet.
Does this get better over time? I.e., do you get used to it? Or, are there tricks on how to approach reading and writing Lisp code to make things more easy for yourself? How do more experienced Lisp programmers do this? Any hints?