> This has been a fascinating discussion, thanks to everyone involved.

So I've been lurking on this thread for some time, and thought I'd go
and offer my two cents on the topic. While writing clojure-py, I've
been in the unique situation of having to decide which language
features will be implemented in Clojure and which will be implemented
in Python. For example, deftype is not a compiler feature in
clojure-py it is actually big macro that ends up calling the python
internal functions to create types.

My viewpoint is that, in general, Clojure and python are equal in
their "readability" on a feature to feature basis. That is, define
feature A in both Clojure and Python and you'll find that it will take
you about the same amount of time to grasp what is being done in both
implementations. The difference is that it normally takes 1/2 the
number of lines of code to do something in Clojure than it does in
Python. In other words, Clojure is more terse, and hence more dense
than Python.

So I think the question of readability I think it really comes down to
the programmer making sure that he considers what future readers of
his code will think. For example, this is perfectly valid Python, and
something I see fairly often in other people's Python code:

print [(x, y, x * y) for x in (0,1,2,3) for y in (0,1,2,3) if x < y]

But personally I consider this sort of code unacceptable.

Instead I tend to write Python code thusly:

for x in (0,1,2,3):
    for y in (0,1,2,3):
        if x < y:
            print (x, y, x*y)

It looks cleaner and is much easier to understand.

In Clojure we have the power to reach the middle-ground:

(print (for [x [0 1 2 3]
               y [0 1 2 3]
              :when (< x y)]
             [x y (*x y)]))


Here we get the get the "expression" style of the first Python
example, with the code structure of the second python example, and at
the same time end up with less indents/linewidth than either Python
example.

This is the reason why the majority of clojure-py is written in
clojure and not python.

Timothy

-- 
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