Editor Tools

We need help from our editors to tame the LISPy syntax. This chapter walks through the tools we will need and why.

Clojure is a LISP. LISP, short for List Processing is a family of languages with a distinctive, parentheses based, prefix notation. The original LISP specification was drafted by John McCarthy in the year 1958.

One of the major barriers to entry into the world of Lisps is the syntax.

Here's what a function to convert a HashMap to a query string might look like in Clojure (don't worry if it doesn't make sense, it soon will):

At first glance, it's almost impossible to figure out the function boundaries. Unlike C-style languages, Lisp functions don't indent well. It's also hard to keep track of parenthesis. A single misplaced bracket will cause the program to fail.

Lisp code is a Tree#

Lisp code is written in Tree form, whereas C-style code is written in prose form. If you examine the code above, and assume round and square brackets to denote a collection, then the Tree structure becomes evident.

Tree-based code is also referred as S-Expression (or sexp for short). The function defined above can be visualised as the tree below:

Partial S-Exp for map->query-string function

To mitigate this problem, we are going to install two tools: Paredit and Rainbow Params

Paredit#

Paredit is a structural editing plugin. It was originally built for Emacs, but well maintained ports exist for most major editors.

Paredit enables multiple hot keys that: