I spent the weekend writing a scraper in Clojure using the HtmlUnit Java library. As much as possible I aimed for purely functional, side effect free code, but as with most Java libraries, using the HtmlUnit API forced me to write functions dealing with mutable, stateful Java objects.
I would have preferred to write everything in a purely functional style because I agree that it makes testing and reasoning about your code so much easier. But looking back, the ability to dip into Java (and use the great HtmlUnit library) was a big win in terms of accomplishing the task at hand.
Comments
I spent the weekend writing a scraper in Clojure using the HtmlUnit Java library. As much as possible I aimed for purely functional, side effect free code, but as with most Java libraries, using the HtmlUnit API forced me to write functions dealing with mutable, stateful Java objects.
I would have preferred to write everything in a purely functional style because I agree that it makes testing and reasoning about your code so much easier. But looking back, the ability to dip into Java (and use the great HtmlUnit library) was a big win in terms of accomplishing the task at hand.