More Clojure talks July 5, 2013 1 Comment
In November of 2012, I spoke at the Clojure Conj on my experiences using ClojureScript in production. It was an amazing conference and I was beyond excited to speak. You can watch the talk on YouTube.
Clojure/West was hosted in Portland, OR this year! I gave a talk on the power of specification and capturing Specifications as a Value. I plan on writing a follow-up post with my latest work in this area – logical assertions with core.logic and capturing the concepts of xADL in EDN. The combination of these two lets you specify and validate your system from the requirements, through the architecture, and then into the code, while still enabling you to augment your running system (via a more robust version of `fn-with` that I demoed in my talk).
I’ve gotten a few emails to publish a screencast of the demo from my talk, since it wasn’t captured live – I’ll do my best to pull one together, but in the meantime you can see the code on GitHub that was used to drive the demo.
ClojureScript and Node.js – an experience report October 26, 2012 No Comments
ClojureScript on Node.js is a (potentially) compelling story for writing scripting apps with Clojure.
I am just now finishing up the first of a handful of example apps to help tease out the approach, tooling, and ClojureScript patches needed to make Clojure a viable option in this regard.
git-ttt is a git-backed, text-based, ticket tracker written in ClojureScript, making use of EDN as the storage format, supporting datalog-like query driven by core.logic, running on Node.js. I pushed an early glimpse of it to github and published an intro screencast to allow those that are curious to see it in action.
Two interesting pieces of the project are its use of protocols and the approach to avoiding constant callbacks.
“Program to an interface, never to an implementation.” and “Favor composition over inheritance.” – Gang of Four
Protocols enable developers to open their systems for extension, while also allowing others to compose targeted functionality ala carte. Shoreleave’s pubsub abstractions and git-ttt’s search abstraction are two concrete examples to see these benefits. In Shoreleave, one can extend the full functionality of the pubsub to any object in ClojureScript1 and extend the pubsub bus abstraction to any implementation. Participation in this system is open to all, from all directions.
In TTT, the search protocol specifies a function to compare two attributes, while falling back on equality in the default case. This allows plugins to extend search functionality and behavior.
Scripting applications usually have some global constants (for example a file path string), which you might need to set from an external system call. A more concrete example- TTT needs to know some of the user’s git settings, which are fetched with the git command via Node’s system exec call. The result (a map of git config keys to their values) is bound to a dynamic var and the rest of code is written against that dynamic var. To actually get that result though, we use an atom, a promise, and the threading macro.
First we write the system call to git in a standard callback style, except an atom will contain the eventual result.
|1 2 3 4 5 6 7 8 9 10 11||
Multiple requests are threaded, passing the atom along and building up the data.
|1 2 3 4 5 6 7 8 9||
A promise awaits the values in the atom. Blocking-deref just ticks away Node’s internal process until the promise is fulfilled.
|1 2 3 4 5 6 7 8 9 10 11||
This overall approach is similar in notion to how transients work. From a top-level, the value of the promises set the dynamic vars or are passed in before kicking off the main application loop.
|1 2 3 4 5 6 7||
Scripting Clojure apps on Node.js is a real possibility and a complete pleasure by using the platform (Google Closure), the host (Node.js), and the language cooperatively.
- By default Shoreleave extends the abstraction to functions and atoms, allowing construction of reactive dataflows [↩]
Earlier in the year I spoke at Clojure/West on “Clojure-powered Startups.” The talk was limited to 25 minutes and sadly was light on supporting data. The point I really wanted to drive home was a roadmap of successfully adopting Clojure for production work.
At the upcoming Conj, I’ll be speaking about Production ClojureScript – and this time I’m bringing the data
Production ClojureScript June 21, 2012 3 Comments
Last night I presented at ClojureNYC on my experience putting ClojureScript into production.
A few have asked for the slides.
The presentation discusses some features of Shoreleave, the suite of utilities Tutorspree built up for building ClojureScript apps. The slides also provide some suggestions on how to build out or structure your ClojureScript applications.
Coming soon are two example apps (one of which was demo’d during the talk) – a SOLR-connected CLJS client a TodoMVC example. Both will come bundled with a teaching/exploration tool (which was also demo’d last night).
Once the demo apps are done, I’ll be doing a quick screencast on getting the most out of Shoreleave.
Lastly, thanks to everyone who has help shaped Shoreleave and provided me with feedback. It’s all greatly appreciated.