

Java.next() - Clojure: The Return of the Lispers - bozhidar
http://batsov.com/Clojure/Java/2011/05/12/jvm-langs-clojure.html
The third chapter of Java.next() series. A glance at the Clojure programming language, a modern Lisp-1 dialect for the JVM and .Net.
======
efsavage
I'd love to be sold on a new language, but using it by showing me ridiculous
examples of a language I know reduces the credibility of the seller. It's an
otherwise good looking article but when I see this:

    
    
      public boolean hasUpperCase(String word) {
        if (word == null) {
            return false;
        }
        int len = word.length();
        for (int i = 0; i < len; i++) {
            if (Character.isUpperCase(word.charAt(i))) {
                return true;
            }
        }
        return false;
      }
    

Where it should be this:

    
    
      public boolean hasUpperCase(String word) {
         return word != null && word.matches(".*[A-Z]+.*");
      }
    

It casts doubt on the other examples. I'm not saying Java isn't a verbose
language that can get tedious, but let's use some decent examples.

~~~
swannodette
It's doesn't cast doubt on the examples at all, your code is less generic:

    
    
      (defn has-uppercase? [string]
        (some #(Character/isUpperCase %) string))
    

This code can deal with _any_ sequence of characters: String, Array,
PersistentList, PersistentVector, Cons, LazySequence, etc. Your example only
deals with String.

~~~
efsavage
Fair enough, but mine was not an alternate to his Clojure code, but to his
Java code (which only checks String). Perhaps he should have focused on the
functional efficiency like you did, rather than just bloated lines of code.

~~~
seabee
It's still not an alternate to the Java, since there are more upper-case
characters than the 26 your regex matches. But I'm sure there is an
appropriate Unicorn character class you could use instead.

------
dotcomsmarties
I've been coding Java/Python for 10+ years (C/C++ before that), and recently
started on Clojure a few months ago. I'm having trouble grokking Clojure since
I'm not a Lisp guy, but after stumbling around like a blind rat I find that
Clojure's syntax is quite extraordinary. I hope Clojure will become more
mainstream as more people use them, and creates more tutorials for a layman
like me.

------
d0m
I feel like when people are comparing languages, they are exaggerating.. For
instance:

    
    
      public boolean hasUpperCase(String word) {
          if (word == null) {
              return false;
          }
          int len = word.length();
          for (int i = 0; i < len; i++) {
              if (Character.isUpperCase(word.charAt(i))) {
                  return true;
              }
          }
          return false;
      }
    
      or
    
      public boolean hasUpperCase(String word) {
          if (null != word)
              return any(charactersOf(word), new Predicate() {
                      public boolean apply(Character c) {
                          return isUpperCase(c);
                      }
                  })
              else
                  return false;
      }

~~~
swannodette
Small inconveniences add up fast. For example
[https://github.com/clojure/core.logic/blob/master/src/main/c...](https://github.com/clojure/core.logic/blob/master/src/main/clojure/clojure/core/logic/minikanren.clj).
It's a 1000 lines of Clojure, I strongly doubt that this could be implemented
in anything less than 5000 lines of Java split across 10 files.

------
th0ma5
I've been playing a lot with Kawa (Scheme) for Java, it's rather nice.

~~~
rikthevik
What are the cool things we should know about Kawa?

~~~
cjenkins
One cool thing is that the Google Android App Inventor is built out of Kawa.
(<http://en.wikipedia.org/wiki/Google_App_Inventor>)

I believe Kawa is also currently a bit friendlier on Android as Clojure has
some overhead. (More at
<http://dev.clojure.org/display/design/Android+Support>)

