Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
ClojureScript gets a REPL that drives the browser (github.com/ibdknox)
92 points by ibdknox on July 28, 2011 | hide | past | favorite | 9 comments


I had been wondering about what advantage ClojureScript gave, since the biggest appeal of lisp to me is generally the ability to send functions straight to the REPL and see updates without restarting the program. Last night, I went on IRC to ask about this, and lbdknox responded that he was working on it as I asked. As he explained a little more, I realized that it wasn't an intractable problem - in fact, I was capable of solving it.

I think the lesson here is that you shouldn't just wait for answers to your problems - you should create them.


Stolen from Alan Kay: "Don't worry about what anybody else is going to do. The best way to predict the future is to invent it." --Alan Kay

Stolen from "Joy of Clojure": CLOJURE APHORISM Clojure programmers don’t write their apps in Clojure. They write the language that they use to write their apps in Clojure. --M. Fogus && C. Houser


I've been wondering why they didn't create an actual compiler in javascript? I understand it's more trouble.


I imagine that they would have, but for the following:

I'm sure that clojure compiles clojure, at this point, at least for the majority.

So, once you've written something that compiles clojure to js, then you just need to compile that compiler to js.

Why haven't they done this? My guess is that "something" in the clojure compiler relies on the jvm, or links to some java code to do its work.

Another possible reason that clojurescript doesn't yet compile all valid clojure.

In any case, I'm sure that this is an eventual goal. Hickey has stated that he always wanted clojure to target multiple platforms, but decided to start on java first.


Any good examples of some JS that's cool to run?


Not "cool" per se, but here's something that works :)

    (require '[goog.dom :as dom])
    (def body (aget (dom/getElementsByTagNameAndClass "body") 0))
    (defn elem-factory [tag text] 
        (let [elem (dom/createElement tag)] 
            (dom/setTextContent elem text) 
            elem))
    (dom/appendChild body (elem-factory "p" "my new tag"))


Will ClojureScript take care of cross-browser issues?


ClojureScript just compiles to JavaScript it does not care for cross-browser issues --> it does not add a browser independed standard library but ClojureScript works closly together with the Google Closure library (witch is used for a lot google products) and this library includes browser independend librarys.


ok. thanks




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: