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.

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.

Code walkthrough in Hickey presentation

December 6, 2008

**Update 12/11/2008: In the original post, I claimed the code from Hickey’s presentation needed to be updated to the latest version of Clojure. Wrong. The code wasn’t running for me because I didn’t have the de facto latest version, which is built from subversion. I’ve edited the post to reflect this. **

Hickey’s presentation to the Western Massachusettes Developers Group is primarily about Concurrency. The first half covers similar topics to his other presentations (including the For Lispers presentation). But about halfway through the talk, at 1:16:00, he begins a walkthrough of a program he wrote simulating an ant colony. I really recommend following this. It’s helped me a lot.

So go view the video:

Get the code for the simulation too, from the link on the Blip page. As of this posting, you’ll need to build clojure from subversion to make the code work. If you’re using the latest official release, from September 16, you’ll need to use a copy of the code I made:

The key difference is in the java interop syntax. The latest version of clojure uses a dot before a method call in many circumstances, whereas the official release does not. In other words:

(doto g
    (.setColor c) ;; current syntax, with dot


(doto g
    (setColor c) ;; official release syntax, no dot.

If you run current Clojure code using the official release, you’ll see a lot of errors like these:

java.lang.IllegalArgumentException: No matching method found: 
  .setPreferredSize for class clojure.lang.Proxy__2845

The walkthrough takes about an hour. Give it a try.

More resources for Clojure: Rich Hickey videos

November 30, 2008

I’m posting a link to videos of presentations on Clojure by its creator, Rich Hickey:

Most of these are Hickey’s slides over audio of Hickey and the audience, although at least one gives you a look at the man himself. Videos are 60-90 minutes, and some presentations span two videos (!) So far, all the ones I’ve seen are good quality.

Topics covered include Clojure for Lispers, Clojure for Java Programmers, Clojure data strutures, and concurrency in Clojure.