Simplicity isn't simple, a coda.

by Charles Miller on May 13, 2015

The weekend after I posted this article about the pitfalls hiding in a simple shell command-line, I had some free time and decided it might be fun to see what the same functionality would look like in Haskell.

My Haskell experience is limited to tutorials, book exercises, and reading other people’s code, so I wanted to go a little bit off the paved road for once.

So I grabbed System.FilePath.Find and hsexif off Hackage because they seemed to be what I needed, and set about making the type checker happy enough to run my program.

I didn't expect to just knock out a working program in an unfamiliar language in minutes, and I didn't. Nonetheless I was pretty impressed by how, once I had muddled through understanding the pieces I was working with, they joined together in a pleasingly logical way. (Although looking at the code a month later I can get what the various bits do—the types are informative enough for that—but it would take some unravelling for me to remember how.)

Then I ran my resulting program on a real directory full of photos and it instantly died, because the exif parser was built on lazy I/O, and my script was running out of available file-handles before it was getting around to closing them.

Leaky abstractions 1, Charles 0.

This is the kind of post that has a small but annoyingly non-zero chance of setting off somebody's "wrong on the Internet" buzzer. Please don't. It's an anecdote of how I encountered an unshaven yak on a lazy Sunday afternoon, as developers are wont to do, nothing more.

Update: December 6, 2015, the author of the hsexif package, Emmanuel Touzery, emailed me to say that after finding this post via Google, he updated the library (v0.6.0.7) to close files eagerly instead of lazily, so future Charles’s won’t encounter the same problem. Present Charles is left feeling mildly guilty he didn’t file the bug through more official channels.

Previously: Twitter is a crowded bar

Next: Why does it matter that Future is a monad?