Practical Elegance

"Elegance is not a dispensable luxury." - Edsgar Dijkstra

Recovering from Clojure/conj

Whew. I just got back from Clojure/conj and boy, is my brain tired.

I’l be doing a more detailed and code-oriented post with Milt Reder on the Yet Analytics blog this week, but I need to do a brain dump beofre I brainsplode.

So, getting the fanboy stuff out of the way: I got to shake Rich Hickey’s hand and thank him for all the work that went into Clojure and Datomic, i.e., the stuff that made programming fun again for me. So that was fun. This was at the conference party at the Crime Museum, which was a joy and a wonderful place for a party.

But, the actual conj…

Emacs: Down The Rabbit Hole

So I wrote Welcome to The Dark Side: Switching to Emacs in response to a tweet, but as any of my co-workers will attest, it doesn’t take much to get me started on my Emacs workflow.

I feel like a religious convert… I miss those simple, unadorned Vim services but I’m floored by the majesty of the stained glass and altar dressings and ritual of the Church of Emacs.

So before the jump, in the spirit of “I’ll show you mine if you show me yours,” my .emacs.d.

An Unexpected Journey

I lived in my happy little Vim hobbit hole, smoking my pipe and enjoying my brandy. It was not a dirty hole, or a sandy hole, but a hobbit hole, which means comfort.

One day, a wizard visted me.

And that’s when things began to get weird…

Reify This!

On the way home this afternoon I was asked to explain Clojure’s reify macro, and apparently I did quite well, as an “Aha!” moment resulted. So I shall endeavour to explain reify here in the hope that such a moment might be available to others.

Reify derives from the Latin res, or “thing.” So reify fundamentally means “make a thing out of….

Protocols and Datatypes

Clojure protocols are similar to Java interfaces: They define a set of methods/functions purely by their signatures without providing implementation details. Declaring that a class implements an interface (in Java) or that a record implements a protocol (in Clojure) is a contract that specifies that the given class or record, in order to be valid, will provide concrete implementations of those methods/functions.

But sometimes we don’t need a reusable entity with reusable implementations that we can instantiate willy-nilly; sometimes we just need a thing that implements those methods.

In Java, anonymous inner classes can fulfill this purpose. In Clojure, we have reify.

That Nameless Thing

OK, it’s not really going to be nameless… let’s say we have a putative protocol as follows:

(defprotocol Foo
    (bar [this])
    (baz [this st])
    (quux [this x y]))

So if we were creating a new record, we might do:

(defrecord FooRecord
    (bar [this] (println this))
    (baz [this st] (str this st))
    (quux [this x y] (str this (* x y))))

Which is perfect if we need to repeatedly instantiate a FooRecord that implements the Foo protocol. But sometimes we just need a Foo and be done with it. And so, Clojure gives us reify.

Welcome to The Dark Side: Switching to Emacs

I have to start this post by saying I’ve been a dogmatic Vim partisan since the 1990’s, when I started using vi on the Solaris and Irix boxen I had access to, and then on my own machines when I got started with Linux in 1994.

I flamed against Emacs on Usenet, called it all the epithets (Escape Meta Alt Ctrl Delete, Eight Megs And Constantly Swapping (8 megs was a lot then), Eventually Mangles All Computer Storage)… I couldn’t stand the chord keys and lack of modality.

Even once I got heavily into Lisp I still tried to stick with Vim, or tried LightTable, or Atom, or SublimeText. But then one day I hit a wall and Emacs (plus cider-mode and slime and a few other packages) was the obvious solution. Now I’m out there evangelizing Emacs (I’m writing this post in the Markdown major mode plus some helpful minor modes) and I figure I’d offer some advice for those looking to convert to the Church of Emacs.

St. Ignucius

Fear and Coding in Las Vegas

I’m sitting in the first session of the K-5 PD training workshop.

It’s my first time in Las Vegas. We went to In-N-Out Burger (required if I travel out west), and I hit a $2k jackpot on penny slots. Not bad. And now we’re getting an overview of the K-5 curriculum. It’s pretty exciting.

I learned to code when I was 5. Learning BASIC on a TI 99/4A. This is pretty much my first computer:

Have A Happy #Whyday with whynot

It’s August 19th, the day we remember why the lucky stiff’s poignant departure from the internet. ruby-jokes would hate to part with the Whyday tradition of hacking on something just for fun and releasing it into the wild.

So it’s with great ambivalence we announce whynot, a gem that does irresponsible things because… why not?

whynot is for when you really just don’t care. It started as a single monkey-patch to Kernel, called maybe. maybe takes a block, and may or may not yield the result. So for instance:

maybe do |x,y,z|
  x,y,z = 1,2,3
  x + y + z

About half the time, this will return 6. The other half, nil.

About three minutes after I pushed whynot to Github, Micah Gates added some kernel methods that allowed for a little more specificity: mostly, which will execute your code about 2/3 of the time, and occasionally, which has about a 1 in 5 chance of actually executing your code.

But wait, there’s more!

Just in time for the 0.0.4 release this afternoon, I decided sometimes, the truth doesn’t matter. Or, at least, you just don’t care. So I added meh. Sometimes true, sometimes false, whatever. When you really don’t care, just do this:

meh ? "I guess" : "Nah."

I really wanted to create a global value like true or false that was neither truthy nor falsey, but I’m not sure whether that’s possible, and I have a feeling it would require some C-extension hackery if it is.

Perhaps for a future release?

As always, pull requests are welcome, and use at your own risk.

On Comments And Moderation

I’ve always taken a hands-off approach to moderating comments, feeling that it was a form of censorship to restrict discussion even on my own blog. It’s worked pretty well; I feel like prior to yesterday, I’ve deleted less than three comments in the three years I’ve maintained this blog.

But yesterday’s post, I’m Telling :: Employer-Tattling and The Decline of Agency, brought in some of the nastiest of trolls, and I had to re-evaluate that policy. The post also got so many comments I was going crazy trying to weigh my anti-censorship views against comments that bordered on hate speech.

I’m Telling :: Employer-Tattling and The Decline of Agency

The other night Twitter was abuzz with controversy and drama, as per usual. One of those threads (which I’ll get to momentarily) invovled what I’ll refer to as “employer-tattling,” and Jon Soeder (laudably without drawing attention to the ongoing echo chamber), tweeted this:

He doesn’t mention which Twitter thread prompted this, but I have an educated guess.

Scream When You Learn

Apologies to Charles Bukowski


I fucking hate this school. All the teachers too. Well, there are a few exceptions, but few enough it doesn’t really matter.

There are a few saving graces. Molly, that redhead in fourth period I’m dying to fuck. There’s a party Friday, maybe that’ll happen. At least I’ll be drunk enough not to care about this shithole for a few hours.

Had a test today. Fucking Mr. Blum walked over to my desk and watched me solve quadratic equations. Grabbed the calculator out of my hand when he saw me using the program I wrote to solve them. Old fucking moron doesn’t even know what these piece of shit TI-83’s are capable of. Thought I was cheating.

Discussing Privilege: EduCon Reflections #1

While I’m planning a full “overview” reflection on EduCon 2.6, I was (pardon the pun) privileged to participate in a conversation entitled “The Privileged Voices in Education”, facilitated by Audrey Watters and Jose Vilson. Audrey has written about the session on her blog, and Jose has written about it on his blog, so you can refer to those for context. But I want to talk about my takeaways from that wonderful session and what came after while it’s fresh in my mind, and then work on a more general EduCon post.


This is a Hard Topic to address in a meaningful way that actually effects change. It’s a hard topic to broach in general. I applaud Audrey and Jose for creating this EduCon session, for their facilitation of the conversation, and I’m in awe of how civil, insightful, and enlightening the discourse was.

Let me start by confessing: as often happens, I was unable to make it through the discussion without saying something (at the very least) bothersome. I talked about my initial reaction to #edchat, a hashtag-based recurring event for educators on Twitter, as an offhand preface to the difficulty of certain discussions in diverse media. Tom Whitby, founder of #edchat, was in the room. This actually opened a (in my opinion) constructive dialogue ex post facto, but I’ll return to this later.