

Functional constructs shared by Groovy, Scala, and Clojure and their benefits - moondowner
http://www.ibm.com/developerworks/java/library/j-jn10/index.html

======
vorg
So Scala...

    
    
        employees
          .filter(_.length() > 1)
          .map(_.capitalize)
          .reduce(_ + "," + _)
    

...Groovy...

    
    
        listOfNames
          .findAll {it.length() > 1}
          .collect {it.capitalize()}
          .join(',')
    

...and Clojure...

    
    
        (->> list-of-emps
          (filter #(< 1 (count %)))
          (map clojure.string/capitalize)
          (interpose ",")
          (reduce str))
    

They all look similar, but Clojure's syntax is harder to read for the
uninitiated at first sight, one of the downsides of enabling syntactic macros
and the homoiconocity it requires.

I do think there's room for a Scala/Groovy-looking syntax to sit atop Clojure,
though, not to replace Clojure but to complement it. As it stands, the
comparison code is easily misread and should be infix. I'm working on a tool
to read this...

    
    
        listOfEmps
          ->> filter(count(_) > 1)
          ->> map(clojure.string.capitalize)
          ->> interpose(",")
          ->> reduce(str)
    

...and convert it to the Clojure sample above. There's been no real technical
blockers (besides parsing performance of course). The bottleneck has been
designing the syntax to cover all possible holes.

