i_like_monkeys
i_like_monkeys

Reputation: 247

A few questions about "hello world" in clojure

I have a couple of questions about Hello World in Clojure:

(println "Hello, world!")
  1. Since 'println' is used, does this mean some Java libraries are included in the default namespace by default, just as in Grails?
  2. 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)))
  1. Any evidence so far that Clojure is likely to catch on?

Upvotes: 3

Views: 802

Answers (1)

Mike Mazur
Mike Mazur

Reputation: 2519

  1. println is 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.io and java.lang I think).

  2. The parentheses are syntax for calling a function and come from Lisp. For example, this function call in Java:

    addTwoNumbers(4, 5);
    

    would be written as follows in Clojure (and Lisp):

    (addTwoNumbers 4 5)
    
  3. Clojure's community is vibrant and growing. Check out the Google Group

Upvotes: 8

Related Questions