& it won't. attract. the worm.

A Month With an Electric Car: The Numbers

| Comments

Exactly one month ago, our family of four leased a Fiat 500e. It looks a lot like this:

It’s a good time, this little car. It is nimble. It doth go. The backseat has the endorsement of both kids. There is much say about how it feels, after many years, to suddenly not have a transmission. Maybe in another post.

Here instead, the cold hard numbers on month #1.

WebRTC: I Give You This Advice: Stay on the Path

| Comments

WebRTC is an emerging web standard that promises cheap, cheerful peer-to-peer media streaming. And by cheap I mean free. It also sidesteps expensive videoconferencing hardware and their remote controls, SIP call negotiation, creaking corporatist dinosaurs like (MSFT-owned) Skype, and the Google-in-your-face-all-the-time aspect of Hangouts (not to mention the amateur-hour Hangouts UI).

Instead, two (or three, or four…) browsers, separated by any thicket of firewalls and NATS, can simply connect and start exchange video and audio streams, data, and even (in Chromium) screen sharing, without the bytes passing through any intermediate server or service. talky.io and secretlymeet.me show some of what’s possible here.

But at the current state of the WebRTC browser APIs, it’s the kind of thing where to get something to work you have to stay on the path. The most common advice on Stack Overflow is to start with a working sample, and mutate from that. That might help. But also, as a guide for the weary, here is a path.

There Is (Still) No Such Thing as Software Engineering

| Comments

It’s kind of fun to share with non-programmer friends the opinion that there is “no such thing as software engineering” — fun because it is contrarian, it takes people by surprise, fun because I happen to believe it, and a fun excuse to try to envision what software engineering would actually entail. Software is so hard. Will it always be this hard?

Within the software industry, “there is no such thing as software engineering” is actually a fairly well-known argument. On the occasion of the healthcare.gov mess, I was giving a friend my version of it, which goes along these lines…

Instaparse: Parsing With Clojure Is the New Black

| Comments

This is the sequel to an earlier post where I tried to use the Clojure library Parsley to get my arms around some textual data. I was looking for a fast, cheap-and-cheerful approach that would take me from a big fat unwieldy string to a nice, regular tree-shaped data structure in 20 minutes or less.

I didn’t quite get there with Parsley, though I still think it’s a wonderful and approachable library, and it’s one that, for me, set a new standard for what kind of written artifact a programmer should have to produce in order to get a working parser. That is: it can and should be just a grammar. It should not look like this. (Maybe nothing ever should.)

As Mark Engelberg notes, “the world would be a better place if building parsers were as easy as working with regular expressions.” And he’s right; it would.

But unlike me, he actually did something about it; he wrote Instaparse. Instaparse is my new bicycle. It solved all the problems I had with Parsley (and some other problems I didn’t even know I had).

Sublime Text 2 as a Light C++ IDE

| Comments

Update: Good news and bad news: SublimeClang is semi-abandoned; but Sublime Text 3 is a thing. We’ll see what happens next.

There are lots of things that IDEs do, but really only 2 main things I miss when I’m coding C++ in a text editor:

  1. auto-completion of symbol names
  2. jump to symbol definitions or implementation

I’ve found that with recent versions of the SublimeClang plugin, I can finally do both in Sublime Text 2.

Parsing Is Fun Again With Parsley

| Comments

Recently I needed to pull data from some text files for a client project. No XML or YAML to be found here; the files are written in a variety of (familially related but distinct) custom formats. Time to go a-parsin.

I considered tools like ANTLR and Boost Spirit, but I didn’t feel like mastering an entire toolchain or getting deeply acquainted with a strange brew of never-before-seen errors from my C++ compiler. But I did actually want to have a parser, rather than a hand-hacked pseudo-parser, for reasons of maintainability.

And I was, of course, at least in part, looking for an excuse to use Clojure. With the Parsley library from Christophe Grand, I found my excuse. However, I haven’t yet managed to work through all my issues with Parsley yet, so I haven’t been able to deploy with it.

Ceci Ne Pas Une Football

| Comments

Me writing for avidly.org today: Ceci ne pas une Football.

Football is fundamentally a drama of knowledge. It’s a repetitive, fort-da kind of affair, where what’s on the end of the string, the string we keep pulling back and casting forth, is a known and measured human achievement. We come up with such a fish at the end of every play.

The play is the thing where every player and every referee takes their appointed places, reaching a point of stillness like a troupe of ballet dancers, and then, on an obscure signal, unleash a kind of stylized, hellish chaos. Then, somehow it gets brought to a screeching halt; that’s when we all agree to see what the result was. Out of that madness we preciptate a measurement; a result that can be parsed. It can be charted on the platonic geometry of the grid.

Remember this game is literally played on a ruler! The ruler is one hundred yards in length.

A Lightning Talk About ‘Auto’ in C++11

| Comments

This is the content (more or less) of a brief talk I gave at the LA C++ Meetup on April 3 2012, which was held at Oblong Industries in downtown LA. 20 or 30 folks turned out for a good chat about auto (lightly), the C++11 memory model and atomics (deeply), and various sundry topics like IDEs, good C++ books, and Linus Torvalds’ recent tiff with the GCC implementers. (We side with Linus here. Those bitfield semantics are just wrong.)

This talk draws on various intertube references such as Herb Sutter’s excellent writings, the Wikipedia entry on C++11, and the diligent work of Scott Meyers.

How to Call Clojure Functions From Java

| Comments

I’m fairly new to Clojure and possibly even less familiar with the state of 21st-century Java, so when I wanted to generate a Clojure jar file that someone else could call from ordinary Java code, in an ordinary way, I didn’t have much to start with. I hit up Google and Stack Overflow fairly hard with permutations of the bag of words {call invoke Clojure from Java interop WTF}. But I didn’t find more than one or two relevant, recent examples, of a Clojure 1.3 (or later) vintage. The official document on Clojure compilation is fine as far as it goes, and a good reference, but was not quite enough to actually set my feet on the path.

My goal was to generate a jar file that could be executed standalone (e.g. double-clicked), OR used as a library, and no user would need to know there was Clojure code inside.

Here, then, I’m presenting a complete walkthrough that will get things up and running with minimal tool dependencies — no Eclipse, ant, maven, CCW, et cetera. We’re going to create just a simple “Hello, Clojure” application in Clojure, a “Hello, Java” application, and then mix the two.

A Neophyte Builds a Wheel

| Comments

What is a wheel? Set of all points equidistant from one point. I set out to make a thing like that, for a bicycle I’m putting together. It took a long time.

The wheel certainly seems like a given enough object. It fits our sense of what’s simple.

But when you build a bicycle wheel yourself, you come to realize that instead of revealing roundness, you are doing the awkward work of propping up, by degrees, a system of constant, dynamic tension. This ordinary and stable object, this benign symbol — what looks like a wide base on which to establish other, more articulate things — is, in fact, itself a balance on toe shoes, with all the theatricality and all the effort that that implies. It’s perched out in the middle of a swamp of contingency.

So instead of a symbol, the wheel must be considered as a system. Systems have practices; here is the practice.

Using Ruby to Detect When Cables Are Plugged in or Unplugged

| Comments

I needed to get notified whenever a network or USB cable was physically plugged in or unplugged from my machine. On Linux, there are a number of ways to skin this cat, but D-Bus seemed like a reasonable (and reasonably modern) way to go. It’s supposedly a ‘message bus’ for the system, and various standard components (notably the HAL and the NetworkManager) are willing to talk to it.

There are D-Bus APIs for Python and Ruby, among others. I wanted to use Ruby. The ruby-dbus gem is an odd bird, but after trying one or two other dbus-affiliated Ruby libraries, I decided it was the least bad.

Use the ruby-dbus gem, which is invoked here as ‘dbus’; anything else would be…uncivilized. We’ll start out with some throat-clearing and an instance of the DBus object.

Log of an Actual Octopress Setup (OS X Lion)

| Comments

How I got this little thing on its feet, more or less. Setup of a heroku account not included.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
brew install rbenv
brew install ruby-build
brew install ccache
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
# a little scary!  todo: find out what I just did here
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/
rbenv install 1.9.2-p290

git clone git://github.com/imathis/octopress.git octopress
cd octopress
# Edited the .gitignore: removed 'public' folder
rbenv local 1.9.2 1.9.2p290
ruby --version
# ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.3.0]

gem install bundler
rbenv rehash    # rehash to be able to run the bundle command
bundle install

gem install heroku  # or gem update heroku
heroku create
git config branch.master.remote heroku

rake generate
git add .
git commit -m 'site updated'
git push heroku master