I have a couple of questions about Hello World in Clojure:
(println "Hello, world!")
- Since ‘println’ is used, does this mean some Java libraries are included in the default namespace by default, just as in Grails?
- Why are the braces needed around the statement? Judging by other examples (below), braces are commonplace:
(let [i (atom 0)]
(defn generate-unique-id
"Returns a distinct numeric ID for each call."
[]
(swap! i inc)))
- Any evidence so far that Clojure is likely to catch on?
printlnis a built-in function in Clojure, and just happens to have the same name as in Java (check out the source). Some Java libraries are imported by default (java.ioandjava.langI think).The parentheses are syntax for calling a function and come from Lisp. For example, this function call in Java:
would be written as follows in Clojure (and Lisp):
Clojure’s community is vibrant and growing. Check out the Google Group