“¢ Some programs, like compilers or theorem provers, are themselves functions.Â They take input and produce output.Â Purely functional languages like Haskell are good for these kinds of programs.Â But other programs, like GUIs or automation systems, are not functions.Â For example, a program that runs continously for months or years is not a function in the mathematical sense.Â Clojure is mostly functional, but not purely functional.
“¢ Most Clojure programmers go through an arc.Â First they think “eww, Java” and try to hide all the Java.Â Then they think “ooh, Java” and realize that Clojure is a powerful way to write Java code.Â Rich frowns upon “wrapper” functions in Clojure that do nothing but wrap a Java method.Â Calling the Java method directly is faster and easier to look up in JavaDoc.
“¢ Rich recommended a paper, Out of the Tar Pit, for a discussion of functional and relational techniques to manage state.
“¢ Clojure’s data structures are persistent.Â This isn’t persistent in the stored-in-a-database sense.Â It refers to immutability.Â For example, adding an element to a vector creates a new vector that shares structure with the old one.Â Because all data structures are immutable, this is both safe and efficient.Â Clojure’s hash maps, for example, have time complexity of log-base-32, which is so small it’s practically constant.
“¢ The first thing Rich did when experimenting with the semantic web was to pull data out of the Jena API and get it into Clojure data structures.Â That allows him to leverage the full power of Clojure’s data manipulation functions.Â This opens up a world of possibilities that he wouldn’t have if he stuck with Jena objects.Â Basically, having your data trapped inside objects is bad, because you’re limited to whatever methods those objects provide.Â With generic data structures, you can re-use and compose all the functions that Clojure already provides.
Screencasts and code from the talk should appear soon — watch clojure.org or the Clojure Google group for an announcement.