r/programming • • May 25 '17

Readable Clojure

http://tonsky.me/blog/readable-clojure/
42 Upvotes

35 comments sorted by

View all comments

Show parent comments

2

u/Retsam19 May 25 '17

As someone who has dabbled in a lot of LISPs but never used any of them extensively, what do you prefer about CLisp and Scheme over Clojure's syntax?

5

u/LoyalToTheGroupOf17 May 25 '17

It's simply a matter of there being more syntax in Clojure: Where Scheme and Common Lisp code consists only of lists, Clojure is lists, vectors and maps.

By the way, "CLisp" and "Common Lisp" are not synonymous. CLISP is a particular implementation of Common Lisp.

1

u/Retsam19 May 25 '17

Ah. Yeah, I liked having maps, but I did find the List/Vector thing confusing. It seemed like there were good reasons for having the dichotomy, but it led to a lot of boilerplate and confusion in my code.

1

u/LoyalToTheGroupOf17 May 25 '17

In Clojure's flavor of code-as-data, lists are preferred over vectors in cases where the first element should be treated differently from the rest. In other cases, vectors are preferred. For instance, in a function invocation, the first element of the sequence is handled differently from the rest (the first element is the function, the rest of the sequence is the arguments to the function, and therefore, function invocation is written as a list. In a sequence of let bindings, on the other hand, there is no distinction between the first element and the rest, hence a vector is used.

This makes some sense, and is good enough to help me easily remember when to use a list and when to use a vector when writing code, but it seems needlessly complex to me.

Regarding maps: I guess you talk about using map syntax for destructuring? I agree, that's really neat.