Capstone project: stepping back for a moment

April 30, 2009

We have a capstone project, a reworking in Clojure of some of the mashup features of Yahoo Pipes. At our last meeting, Luke VanderHart presented a framework for building and connecting components. I’m going to recap the framework as well as a few philosophical decisions we hammered out. But I’m also going to invite you to take a look at the code with me, with an eye towards 1) understanding each bit and 2) replaying the development of the framework by starting with simple building blocks. Luke and I both agree that the current framework, although awesome, has leapfrogged the kind of discussion and collaboration we want to foster in the study group. So I’m going to try an experiment with coding in public. On this blog, and soon on github, we’re going to build the framework again, together, feature by feature, always embracing the principle of the simplest thing that could possibly work. We’ll build up the might of Luke’s framework, but in a way that we get there together. And we’ll probably make it better from all being involved.
Read the rest of this entry »

Unofficial Clojure 1.0 release candidate

April 28, 2009

Clojure 1.0 is on the way, and as a result a lot of activity is occurring in the Subversion repository.  Revision 1357 of the Clojure source was proclaimed the likely release candidate, although a few minor changes have been checked in since.  Likewise, clojure-contrib revision 723 is the likely release candidate corresponding to 1.0. It should be interesting to watch what unfolds in the source until the actual release.

It’s not too late to contribute, and no contribution is too small.


Meeting recap, Pipes/Tubes/Clinks, and next meeting info

April 6, 2009

At our latest meeting, we discussed macros and adopted a capstone project, an open-source Clojure implementation of some of the functions of Yahoo Pipes.


Regarding macros, we touched on the chain of events when a Clojure program is evaluated: evaluation runs from top to bottom, and each S-expression is macro-expanded (if possible) and then evaluated. If an expression expands into something that itself contains a macro, the the new macro expression will be expanded before it is evaluated. This allows a macro to use a previously defined function in the determination of its expansion.

“Macros” in Lisp are very different from “macros” in other languages, as they allow the programmer to use all the power of Lisp to determine the macro’s expansion. Macros are not first-class members of the Clojure language, however. You cannot use them as you use functions–you can not use them with map or apply, for example–because macroexpansion happens before an expression can be used in this way.

Seeing stars

We also talked about “star” functions and macros. The macroexpansion of an expression that uses ‘and‘ includes something called let*:

(macroexpand '(and 1 2 3))
->(let* [and__2863 1]
(if and__2863 (clojure.core/and 2 3) and__2863))

We concluded that you really aren’t supposed to see let*. You only do in this case because macroexpand completely expands the expression it is given, and it turns out that let is a macro whose definition includes the mysterious let*. In fact, a lot of Clojure’s core macros use “star” constructs that appear to be special forms. Some digging at the REPL confirmed that they are not symbols. Likely the “star” forms are transformed by the Clojure parser directly into Java. If you have some special knowledge about this, please post a comment or join our discussion group. We’d like to know more.

Capstone project

Luke presented the case for a project that implemented some of the Yahoo Pipes application. By general acclamation we adopted this project as our capstone. We’ve decided to spend the next two weeks hacking on the basic problems of the project ourselves, keeping in touch through the group mailing list. David set up a github repo for us, with a wiki for collaboration. There you can find the summary of our initial work on defining the project, thanks to Keith. Serge dug up Yahoo’s Pipes documentation.

We’re calling this Tubes right now (as in “teh tubes”), but a final decision on the name (I’m not saying I don’t like Tubes) is one of many tasks we’re deferring. Right now we just want to get things moving. Personally, I expect Paul to have it all done by this afternoon.

Multimethods on Sunday, April 19th, 1pm

Our next meeting will be at least partly devoted to the final topic in Stu’s book: multimethods. Read chapter 8 of Programming Clojure and bring any questions or comments you’d like to discuss. Please notice two things about the next meeting date: 1) it is in two weeks, not three; and 2) it is on a Sunday. The location is still HacDC’s meeting space at St. Stephens, and the time is still 1pm. We hope to see you there.

Project Proposal: Clojure Pipes

March 30, 2009

This Saturday, April 4, at our face-to-face meeting at HacDC, member Luke VanderHart will informally present a case for a Yahoo Pipes-like content aggregator as a possible capstone project. Interested?

Read up on Pipes.

Read Luke’s initial comments.

Of course, we’ll also discuss macros, including the material in Chapter 7 of Programming Clojure.

We hope to see you there: 1PM at HacDC.

March 14 meeting recap, next meeting April 4

March 16, 2009

We had another successful meeting at HacDC’s workshop on Saturday. We covered functional programming, walking through the concepts in the chapter from Programming Clojure and then putting them to work in translating a decision tree modeling program from Python to Clojure: watch for a separate announcement on how we will continue to work on that. We had an especially good time unraveling this bit of code…

(def head-fibo (lazy-cat [0 1] (map + head-fibo 
                                      (rest head-fibo))))

…and understanding what’s less than optimal about it: that it keeps a reference to the head of a lazy sequence, and thus (nth head-fibo x) fails for large values of x.

Next, we’ll tackle macros on April 4th, at 1PM, at HacDC’s workshop. The reading is Chapter 7 of Programming Clojure. We’ll be looking at simple implementations of defmacro and reviewing different uses for macros. We may also tackle a bit of Paul’s proposed templating language, putting what we’ve learned to use. Hope to see you there!

Meeting Recap, Next Meeting, and Group Projects

February 22, 2009

The Study Group met on February 21st at 1PM at HacDC’s workshop to continue our discussion of concurrency.

We worked through Stuart Halloway’s snake program, taking note of the way he organized his program by separating the functions that dealt only with immutable data from the ones that dealt with changes in state. We noted his use of “update-” at the beginning of his names for the state-aware functions, and we agreed this was a pretty good convention for functions that were going to update the state of some refs, agents, or atoms. We also paid a fair amount of attention to his consistent use of destructuring as well as the syntax for the alter function. Finally, we looked at Halloway’s atom-snake, which actually stores the state of the entire snake game in an atom and updates it with swap!, and in so doing creates a transaction-free version of the game. This precipitated a discussion of Software Transactional Memory, which allows copies of complex objects, such as the state of a snake game, to be made without duplicating data from original to copy.

Our next meeting is March 14th, at 1PM, at HacDC’s workshop in St. Stephen’s Church in Washington DC. Homework: chapters 5 and 7 (on Functional Programming and Macros) from Stuart Halloway’s Programming Clojure. We hope to see you there.

We’re also starting to consider our capstone project. Watch the Google group for discussions about the project.

Next Meeting: February 21st, 1PM

February 17, 2009

We’ll be continuing our exploration of concurrency this Saturday at HacDC’s workshop at St. Stephen’s Church, in Northwest DC.

Be sure to check out chapter 6 of Stuart Halloway’s Programming Clojure. It’s the concurrency chapter, and it has some good new stuff in it, including a discussion of atoms and a Clojure snake game that Halloway walks you through fn by fn.

Come with ideas for hacking. I think it might be fun to alter the snake game so you can play against 1+ AI snakes, trying to get those apples. Collisions could eliminate players: think Tron and those light cycles.

Thanks to Serge and HacDC for providing a warm wi-fi-enabled meatspace where we can gather.

Clojure roundup

January 10, 2009

In the last few weeks, there’s been a fair amount of Clojure news and activity here in our study group. Here are some links to things we’ve been watching.

  • A new language release. On December 17th, Rich “cut a new release” of the language. This should bring the offical release up to date enough for most people, although you’re still advised to check out the latest from Subversion, especially a few months go by without another official release
  • Streams vs. sequences. A lively discussion about the right implementation(s) of laziness and the role of caching in Clojure’s sequences. There is a move afoot to add true streams to Clojure, although the ramifications of such an addition are uncertain.
  • Compojure. Yes, Clojure has its own web framework now, and it looks pretty smart. Its syntax is inspired by Ruby’s Sinatra, it interfaces with Jetty, and it lets you write HTML in a vector-tree fashion that looks odd but probably saves the experienced user lots of keystrokes. Eric Levigne has written some posts about using Compojure to run a website.
  • Paul’s article on bean and Java interop. A nice tip on making it easier (and more Clojure-ish) to work with Java libraries.
  • Luke’s Markov chain generator and Michael’s post about it. Luke wrote a cool program that generates an output text from the pieces of an input text and uses pattern analysis and probability to mimic the style of the input text. Your humble blogger responded with a post examining the workings of the program and suggesting ways to build on it. This could become a group project.

That isn’t everything that happened in Clojure lately, not by a long shot, so feel free to comment to ad your own observations. Also, consider joining our study group list (link in the column to the right) to contribute. You don’t have to be in DC or come to meetings–we’d love to hear from you.

Next meeting rescheduled to Saturday January 31st

January 10, 2009

We will still meet at St. Stephens, in northwest DC, just a week later than we’d initially planned: on the 31st at 1PM, a day before Paul Barry’s beloved Baltimore Ravens take the field in Superbowl 0x2B.

Concurrency is still on the agenda. Watch for an update to the Programming Clojure PDF soon: Stuart Halloway has pledged to try to get us a more complete Concurrency chapter with a discussion of atoms. Thanks, Stuart!

If the door is locked on the 31st, we’ll post a note with my cell phone number for you to call for entry. I hope to see you there.

Emacs, Slime, and Clojure update

January 5, 2009

Some of you have noticed that when combined, the latest versions of the set of tools for editing Clojure in Emacs aren’t playing well together. Life on the bleeding edge means occasional paper cuts. I don’t yet understand exactly how Emacs, SLIME, and swank are working together, but I have been able to follow some advice online to fix the troubles I was having.

When starting SLIME in Emacs, everything seemed to work–Emacs and SLIME appeared to be communicating over local ports–but then an error message popped up:

error in process filter: Symbol's function definition is void: slime-redirect-inferior-output

I use Bill Clementson’s emacs setup, which he described on his blog. It turns out Clementson was already aware of the problem, which he describes in a thread on the Clojure mailing list. In a nutshell, swank-clojure has been updated and is a bit out of whack with the other edting tools. A patch has been applied, and if you checkout the latest tools, you’ll now get the patched version. You must then make a minor change to your .emacs file (Preferences.el for me and my Aquamacs setup):


(eval-after-load "slime"


(eval-after-load "slime"
(slime-setup '(slime-repl))

And then restart emacs. Works like a charm now. Thank you, Clojure community!