· · learn more

◌  Ugly Clojure

28 February 2009

So far I’m not mad at Clojure per se. But the mismatch with various naked Java libraries gets pretty raw. This is the ugliest code I’ve written in 2009.

(defn stream->str [stream] ; so angry (let [r (new InputStreamReader stream) w (new StringWriter) bufflen 1024 oh, god buffer (make-array (. Character TYPE) bufflen)] oh, god! (loop [] (let what?! [readed (. r (read buffer 0 bufflen))] (when (> readed -1) (. w (write buffer 0 readed)) (recur)))) (. w toString)))

Obviously this should actually be in the form of adding toString() to PlainTextInputStream. And then having a nice long cry.