On Wed, Mar 7, 2012 at 3:16 PM, Alex Baranosky <
alexander.barano...@gmail.com> wrote:

> I think that the real question that is: if you know Python and Clojure
> equally well, then which is easier to read?
>
> Alex
>
>
>
I know both equally well (actually, I've logged more hours in my life
coding in Lisp syntax than other syntaxes), and I still consider Python to
be significantly easier to read.

A few specific things that hinder Clojure's readability in my opinion:

* prefix notation for arithmetic operators defies centuries of mathematical
notation conventions and consequently any mathematical formula will be less
readable.

* introducing variables creates new indenting level, making code "creep to
the right"

* as code creeps to the right, you need to have a lot more newlines (for
example, between each input to a function) to get it to fit on the page.
This lengthens the code block making less fit on a page, and also makes the
code look a lot different than the exact same code would look if it were
appearing in a place that were less indented.

* The convention of using hyphens to separate words is hard to read (since
- looks like the minus operator) and also takes up more width than camel
case, contributing to the problem that you quickly find lines getting too
wide and needing to be broken up.

* loop/recur is significantly less readable than either the corresponding
looping constructs in Python or the named let that Scheme offers,
*especially* when you have some sort of nested looping going on, which is
extraordinarily difficult to read in Clojure.

* cond branches are sometimes written with the test and the answer on the
same line, or when the test gets too long you have to write it with the
test and answer on subsequent lines; this inconsistent formatting can make
it hard to know in long blocks whether you are looking at the test or the
answer

* Interweavings of cond and let (a common pattern) end up ridiculously
indented and hard to read [Grand's flatter cond macro helps with this; I'd
love to see this brought into Clojure core]

* Decades worth of classic algorithms involving imperative manipulation of
arrays look significantly uglier in Clojure, because Clojure intentionally
makes imperative manipulation more difficult.  I have, for fun, converted
many Knuth algorithms to Clojure, and they invariably are far less
scrutable than the original.

* Expression-oriented syntax (along with the indenting cost of using let)
encourages people to pack far too much into one line rather than giving
names to intermediate results.

* DSLs are supposed to bring customized readable notation to many tasks,
but by the time you include namespace prefixes and colons for all the
keywords, DSLs don't really look that good.  I mean, compare Frinj to
Frink.  Frinj's integration into Clojure is cool, but is there anyone who
considers it even half as readable as Frink?  I certainly don't.

* I feel really clever when I condense some complex loop into some sort of
map/filter/reduce using anonymous functions.  And it looks brilliant when I
read my own code that does this.  But when I read someone else's compact
higher-order stuff, it's usually a nightmare to try to interpret what it is
doing.  Python's loops may be verbose, but I always know exactly what I'm
looking at when I read someone else's code.

* And the number 1 problem with all Lisps is that when you look at Lisp
code, it's a sea of sameness.  Function applications, Macros, Control
constructs, bindings, data lookups, etc. all look exactly the same.  You
look at Python code, and you instantly see the control flow of the code,
the assignments, the tests, the results, the loops, the data, the data
lookups, the breaks.  It's organized, but visually distinct.

I write code in Clojure because I find the semantics appealing, and I feel
I can get more done in less time than a language like Python.  "Code as
data" might be nice for writing macros, but the reality is that it forces
programmers to code in an abstract syntax tree which is more computer
friendly than human friendly.  If I were given the option to *read* a
sample program illustrating some concept in any language of my choice, I
would choose Python over Clojure in a heartbeat.

All one man's opinion, of course, but I wanted to bring it up because I am
someone who has logged many years working in Clojure and related Lisp
languages and I still have the opinion that Python is the most readable
language I have encountered.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to