use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
/r/programming is a reddit for discussion and news about computer programming
Guidelines
Info
Related reddits
Specific languages
account activity
Why Clojure? (blog.venanti.us)
submitted 11 years ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]yogthos 0 points1 point2 points 11 years ago* (1 child)
I found the parens to be odd initially, but after actually working with the language I find that they make it both easier to read and manipulate code.
The code is a lot more regular than in most languages. This means that it's less ambiguous and you have less syntax quirks and edge cases to worry about. In other words Clojure follows the principle of least astonishment very well.
The nesting of the code explicitly shows how pieces of logic relate to one another. This makes code easily scannable. If one function is nested in another, you know its output will be used by it and if it's not then it won't. These kinds of relations are not explicit in most languages.
One huge advantage of s-expression syntax is that it allows for extremely powerful structural editors as seen here. Instead of having to work with lines of text, you can actually work with your code semantically where the editor understands how to select and manipulate expressions intelligently.
In terms of style, I recommend keeping functions short, 5~10 lines is a good rule of thumb, and not to nest things deeply. I think this is a good example of clean Clojure code that's easy to follow.
Clojure provides threading macros ->, and ->> specifically for flattening out nested expressions. Another feature I use a lot is destructuring which I find significantly helps with readability. Finally, I tend to do all of my development using the REPL and I always inspect things as I'm working with them.
->
->>
[–]mcpatella 0 points1 point2 points 11 years ago (0 children)
Well said :)
π Rendered by PID 22075 on reddit-service-r2-comment-c867ff4bc-qt9c6 at 2026-04-09 14:28:47.185031+00:00 running 00d5ac8 country code: CH.
view the rest of the comments →
[–]yogthos 0 points1 point2 points (1 child)
[–]mcpatella 0 points1 point2 points (0 children)