Mining the Web with Clojure
measuringmeasures.com
measuringmeasures.com
https://github.com/swannodette/enlive-tutorial this is probably one of the best places to start learning.
I've been writing modest little web bots/crawlers in shell script for quite a few years now. I think it was a comment on HN just yesterday that prompted an impulse purchase of Michael Schrenk's Webbots, Spiders, and Screen Scrapers (ebooks at nostarch.com currently 1/2 the dead-tree version price). Even though I knew the platform going in (PHP w/ the CURL lib), at every page I can't help but gasp at what an awkward platform this is for the task. I'm only 1/3 of the way through, so I'm still hoping to learn some advanced techniques that I haven't thought of yet. At the least I hope to walk away from the book with some new ways to look at the problem space.
Anyway, as someone who's wanted to learn and dig into Lisp, this library sounds really cool. I'm not a fan of anything which depends on Java, so maybe the libray can be ported to something more scriptable like ECL, NewLISP, or SLisp. I will, however, install Clojure and give it a spin.
Why?
1. No one likes calling Java in an imperative or OO manner from Clojure ("easy" as it may be -- it really just isn't Lisp that way).
2. A lot of people who are now interested in Clojure once coded using Ruby. We Rubyists wrap everything.
However, a couple things to add based on the fact that Java libs usually stink pretty bad, and there are usually 10 for a given task.
1) One step is to find the 1 in 10 libs that is remotely close to being sane. This often takes a bit of time, trying to figure out which project is strongest from an engineering perspective, mavenized their jars, has some tests, and has an api that is close to being usable, etc.
2) We've had a number of java libs crap out on us after some time. There are 10 libs for everything, and none are complete - that is the general rule. So there is this pattern now of wrapping a java lib, evolving the wrapper layer, and then replacing the underlying lib once you find to many limitations. We've done this with libs like Rome and even Lucene and we're about to do it again for our linear algebra (but will try using Mahout first).
The CLR port appears to be fairly active (with regards to the amount of work going into it), and most of the libraries that are just shells over Java libraries can't be used.
What do the motivating factors behind Clojure have to do with anything?
Motivating factors dictate current practices. If every piece of Clojure PR says things like "harness all the power of Java from a language that uses Lisp semantics/syntax", of course library authors will be comfortable doing so.Part of the reason Clojure is great is because we don't have to re-implement all the functionality that Java libraries have given us in order to have a viable language. That benefit goes away if we start saying "stay away from Java".
I know one Clojure book that doesn't say that. ;-)
Because the Java invocation syntax in Clojure is clean
and simple, it is idiomatic to use Java directly,
rather than to hide Java behind Lispy wrappers.
I believe Pragmatic Clojure says something to that effect, too, but I'll have to look it up in my dead-tree version later.http://www.datawrangling.com/how-flightcaster-squeezes-predi...
"Building layer upon layer of abstraction is a big key. On the jvm, you have to do this, it is the path around the verbosity of Java and the vast abyss of poorly done APIs. You just keep searching until you finally find the folks who have built a sane, high level API on top of the thing you want to use - then you wrap it in a high level language like Clojure. The technical term for this is 'wrap the crap.'"