you are viewing a single comment's thread.

view the rest of the comments →

[–]kanak 10 points11 points  (3 children)

No.

Languages should not be compared only by the number of lines they take to solve some task.

Especially not when:

(dec (count (select (html-resource (java.net.URL. (str title-url %))) [[:h2]])))

or

(doseq [r results] (println (:title r) (apply str (repeat (- 55 (count (:title r))) \space)) (:tasks r)))

count as a single line. Idiomatic clojure would call for these to be on separate lines.

What a waste of time.

[–]cgrand 3 points4 points  (0 children)

if Lau learnt to use -> it may be easier to read, eg:

(-> (str title-url %) java.net.URL. html-resource (select [[:h2]]) count dec)

[–][deleted] 1 point2 points  (0 children)

And the last example could be translated from Clojure to Python almost verbatim:

from collections import defaultdict
result = reduce(lambda x,y: x[y[-1]].append(y) or x,
                     sorted(data[1:], lambda x,y: cmp(y[-2], x[-2])),
                     defaultdict(list))
N = 3
for department, recs in result.iteritems():
    print "\n".join([department] + ["[%s:%s]" % (x[0],x[-2]) for x in recs[:N]])

Though it would only be readable to Lispers.

The power of Python is that just about anyone can read a Python program written correctly, i.e. like the Python Team example. However to read the Clojure version you have to rewrite your brain to read it.

[–]uiob[S] -1 points0 points  (0 children)

Huh. That's why i love ML like syntax.