I was recently corresponding with a professor of mine about Wittgenstein, planning to set up a meeting to have a chat and catch up. Oh, and talk about Wittgenstein, as I found another place where philosophy is relevant to programming. In my last email to him, I happened to ask after one of his colleagues, who was my advisor, mentor, and one of the most influential people in my life.
Then I remembered Google, and the first result was an obituary.
I was devastated. Indescribably so. Biblicallly devastated; I literally rent my garments in grief. I really liked that shirt, too.
If it hasn’t been clear up to now, I love Clojure. I wish I could write Clojure all day, every day. But Clojure isn’t my first language, and possibly not even the language I grok most completely.
I jump between programming languages all the time, and end up having to do the most jumping at work because I probably have at least a passing familiarity with the most languages for anyone on our team. And that’s fine.
What I want to ponder on here is the challenges of “speaking” multiple programming languages, learning new ones, and moving between them.
I started programming BASIC when I was about five years old. By the time I hit high school, I was running Linux and writing Perl, C, and Bash scripts (throw some sed and awk in there for good measure, though one wouldn’t call them “languages” as such).
Full disclosure: I have written some PHP. But as the illusory Bertolt Brecht in Cradle Will Rock tells the playwright Marc Blitzstein, “Capitalism makes prostitutes of us all.”
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.
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:
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.
I’m sitting in the first session of the Code.org K-5 PD
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 Code.org 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:
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:
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:
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.
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.