   (.flush out))
 
 (defn read-response [^BufferedReader in]
-  (let [sb (java.lang.StringBuilder.)]
+  (let [sb (StringBuilder.)]
     (loop [sb sb c (.read in)]
       (cond
        (= c 1) (let [ret (str sb)]
                  (print ret)
-                 (recur (java.lang.StringBuilder.) (.read in)))
+                 (recur (StringBuilder.) (.read in)))
        (= c 0) (str sb)
        :else (do
                (.append sb (char c))

  (node-eval ctx (slurp url)))

(defn setup [repl-env]
  (let [env {:context :statement :locals {} :ns (@comp/namespaces comp/*cljs-ns*)}
        scope (:scope repl-env)]
    (repl/load-file repl-env "cljs/core.cljs")
    (swap! loaded-libs conj "cljs.core")
    (repl/evaluate-form repl-env
                        env
                        "<cljs repl>"
                        '(ns cljs.user))
    (repl/evaluate-form repl-env
                        env
                        "<cljs repl>"
                        '(set! *print-fn* (fn [x] (js/node_repl_print (pr-str x)))))))

(extend-protocol repl/IJavaScriptEnv
  clojure.lang.IPersistentMap

(defn repl-env
  [& {:keys [host port] :or {host "localhost" port 5001}}]
  (let [repl-env (socket host port)
        base     (io/resource "goog/base.js")
        deps     (io/resource "goog/deps.js")]
    (node-eval repl-env (slurp (io/reader base)))
    (node-eval repl-env (slurp (io/reader deps)))
    repl-env))
