Posts

Showing posts from 2011

Esmerelda's Imagination

An actress acquaintance of mine—let's call her Esmerelda—once said, "I can't imagine being anything except an actress." To which the retort was given, "You can't be much of an actress then, can you?"
I was reminded of this exchange when someone said to me about Go, "I can't imagine programming in a language that doesn't have generics." My retort, unspoken this time, was, "You can't be much of a programmer, then, can you?"
This is not an essay about generics (which are a fine thing and may arrive in Go one day, or may not) but about imagination, or at least what passes for imagination among computer programmers: complaint. A friend observed that the definitive modern pastime is to complain on line. For the complainers, it's fun, for the recipients of the complaint it can be dispiriting. As a recipient, I am pushing back—by complaining, of course.
Not so long ago, a programmer was someone who programs, but that seems to …

User experience

[We open in a well-lit corporate conference room. A meeting has been running for a while. Lots has been accomplished but time is running out.]
[The door opens and a tall, tow-headed twenty-something guy in glasses walks in, carrying a Mac Air and a folder.]
Manager: Oh, here he is. This is Richard. I asked him to join us today. Glad he could make it. He's got some great user experience ideas.
Richard: Call me Dick.
Manager: Dick's done a lot of seminal UX work for us.
Engineer: Hey, aren't you the guy who's arguing we shouldn't have search in e-books?
Dick: Absolutely. It's a lousy idea.
Engineer: What?
Dick: Books are the best UI ever created. They've been perfected over more than 500 years of development. We shouldn't mess with success.
Product manager: Well, this is a new age. We should be allowed to ...
Dick: Books have never had search. If we add search, we'll just confuse the user.
Product manager: Oh, you're right. We don't want to do that.
Engineer: But e…

Regular expressions in lexing and parsing

Comments extracted from a code review. I've been asked to disseminate them more widely.

I should say something about regular expressions in lexing andparsing. Regular expressions are hard to write, hard to write well,and can be expensive relative to other technologies. (Even when theyare implemented correctly in N*M time, they have significantoverheads, especially if they must capture the output.)Lexers, on the other hand, are fairly easy to write correctly (if notas compactly), and very easy to test. Consider finding alphanumericidentifiers. It's not too hard to write the regexp (something like"[a-ZA-Z_][a-ZA-Z_0-9]*"), but really not much harder to write as asimple loop. The performance of the loop, though, will be much higherand will involve much less code under the covers. A regular expressionlibrary is a big thing. Using one to parse identifiers is like using aMack truck to go to the store for milk. And when we want to adjust our lexer to admit other character t…