Posts tagged with 'ShortProse'
Nov 24, 2012
Comments in code: the more we write, the less we want to highlight

That's my immediate reaction watching these programmers argue about what color their comments should be when reading code. It seems those who write sparse comments want them to pop out of the screen, and those who comment more heavily like to provide a background hum of human commentary that's useful to read in certain contexts and otherwise easy to filter out.

Now that I think about it, this matches my experience. I've experienced good codebases commented both sparsely and heavily. The longer I spend with a sparsely-commented codebase, the more I cling to the comments it does have. They act as landmarks, concise reminders of invariants. However, as I grow familiar with a heavily-commented codebase I tend to skip past the comments. Code is non-linear and can be read in lots of ways, with lots of different questions in mind. Inevitably, narrative comments only answer some of those questions and are a drag the rest of the time.

I'm reminded of one of Lincoln's famous quotes, a fore-shadowing of the CAP theorem. Comments can be either detailed or salient, never both.

Comments are versatile. Perhaps we need two kinds of comments that can be colored differently. Are there still other uses for them?

comments

* *
Mar 14, 2012
The opposite of exponential backoff

Every few days I'm on IM with some coworker from a different building. The conversation goes something like this:

Them: Lunch?
(6 minutes)
Me: Sounds good! Meet downstairs?
(1 minute)
Me: Now?
(2 minutes)
Them: Yes!
(1 minute)
Them: You there?
(3 minutes)
Me: Oops, sorry. Heading down now.

Now I never know whether to wait for a response, or to run down because I'm already late. But today I finally figured out the answer:

Me: New rule. Head down when both of us say 'ready' within 1 minute of each
other.

That's it. No more ambiguity. It's kind of a silly example, but the general idea feels deep, complementary somehow to exponential backoff. Exponential backoff is the ideal game-theoretic strategy for competitive situations where two people need to contend for a common resource, like trying to call someone back after a dropped call and getting a busy signal. Both try to diverge away from a network-defined window of conflict by waiting longer and longer. Here both parties are trying to converge into an agreed window of agreement. Defining the size of the window by diktat should be handy anytime two parties (people, computers, ..) need to cooperate synchronously atop an asynchronous channel.

I'm sure there's a paper on this idea, perhaps something like that one by Lamport pdf on Buridan's ass. If you have a pointer I'd love to hear about it.

comments

* *
Jul 14, 2011
Evolution of a rails programmer

Idiomatic rails action for registering a user if he doesn't exist:

After a year of programming in lisp, I find it most natural to write:

Is this overly concise/obfuscated? I like it because it concisely expresses the error case as an early exit; most of the space is devoted to the successful save, which is straight-line code without distracting branches. It's clearer that we either pick an existing user or create a new one. Form follows function.

comments

* *
May 12, 2011
My latest project

Two of us have been building hackerstream, a real-time UI for Hacker News that a dozen addicts have been using since March. This won't matter to you if you don't frequent HN, or even if you swing by just once a day. But try it out if you go to HN every couple of hours like I do. You'll see comments on all the stories on the entire HN frontpage as they stream in. You can slice and dice the stream by story or by author. You can even set it up to highlight, say, all comments by security guy Thomas Ptacek and all comments about today's silicon valley brouhaha. If you use Twitter the UI will seem familiar.

Is such a firehose useful? Is it too much of a good thing? I find I see more of HN for the same time investment, and I waste less time scanning stories I've already read. What's more, when I started using it I found my comments getting more votes and more responses. It turns out the biggest factor affecting responses is not how good my comment is but just how early it shows up on a story. By biasing my reading to be more timely I was giving my few comments improved odds of a response.

It's not for everyone, but hackerstream is geared to help you have higher-quality conversation on Hacker News. Try it out and tell me what you think.

comments

* *
Mar 4, 2011
Backup theory for startups

You run a startup. Your company has been given data by users, data that it would be embarrassing to lose. You make backups. You're aware of the best-practices:

  • Make backups.
  • Make backups automatic. Or they won't happen.
  • Make backups yourself. Outsourcing them is for suckers.
  • Regularly restore from your backups. A backup doesn't exist if it's never read.

    Incomplete

    This paranoia is useful, but it's intended for personal data. For business data it's incomplete. Businesses have automation. Lots of automation. Dumb automation that can do stupid things, like corrupting data. Businesses also develop nooks and crannies where important data may go unread for periods of time. The combination of automation and dusty corners can cause insidious data loss: some obscure-yet-critical corner of your data gets deleted or corrupted, and you don't notice until the corruption has infected the backup copy.

    Stale is good

    You can guard against catastrophic data loss with just a regular backup at a remote location. Insidious loss is harder to guard against. Insidious data loss is the reason companies have more than one backup, the reason journalled file systems have multiple .snapshot directories, the reason slicehost and linode provide a daily and a weekly backup. Daily/weekly is perhaps the simplest backup cascade. It gives you a week to detect corrupted data in your server. As operations get complex you'll want longer cascades with more levels. The lower levels backup frequently to capture recent changes, and higher levels backup less frequently as a cushion to detect data corruption.

    More best-practices

  • Make cascading backups.
  • Make sure you can detect corruption to anything important before it reaches the highest level of your cascade. The 'height' of your cascade defines how far back in time you can undo damage.

    Failure modes

    Whatever your backup strategy, ask yourself what it can't handle. I can think of two scenarios cascades can't handle: extremely insidious corruption that doesn't get detected in time, and short-lived data. If many records in your database get deleted everyday, most of them may never make it into a weekly backup.

    What else?

    comments

    * *
  • Dec 17, 2010
    Don't apologize

    As a teenager it drove me crazy that my father would never apologize to me. Ever. Even when something was obviously his fault. I swore to myself that I would be more intellectually honesti, that I would admit when I was wrong. That emphasis on intellectual honesty gave me a scientific bent and took me to engineering college, and to grad school. For 12 years I unquestioningly assumed the virtue — and importance — of intellectual honesty. Coincidentally, I also spent most of those years working alone.

    Now that I've worked in teams for a while I'm starting to change my mind. In many social situations being apologetic sucks. It makes others around you feel awkward. If you're leading a team it makes you seem weak. If you're the rookie you sound like you're making excuses. If others aren't intimately familiar with the details it can magnify your screwups and make things seem worse than they are. And always it's a distraction, diluting your focus and that of your team. I'm learning to not apologize until it's clearly expected. Better to err on that side.

    All this may seem crazy obvious to you. Apologizing isn't really part of western culture. I can remember others telling me dozens of times, "don't apologize." Somehow it never sunk in. Perhaps it's not even an eastern thing, just a personal fetish.

    Looking back, I have a different perspective on my father. I realize he was an army officer who spent much of his day telling subordinates what to do. You can't be apologizing in that situation. You just don't think about whose fault it was, because the entire focus is on adjusting to a constantly-changing situation, and on what needs to be done next. I want that mindset.

    comments

    * *
    Aug 8, 2009
    Bringing yourself to think about death

    Q: Most people find it morbid for someone young and healthy to think about their death.

    me: I can never understand that. I am accomplishment-oriented rather than experience-oriented. I derive daily motivation much more from having a sense of accomplishment and impact on the world than from experiential pleasures, or even from having learned something. If you feel the same, it behooves you to think about the impact you will have on the world after you're gone, and how to best channel it. It's only experience that ends when you die.

    comments

    * *
    Jun 6, 2009
    Coping with friendfeed's time-ordered torrent

    I've been increasingly using friendfeed, and the number of my subscriptions has trended steadily down. The reason: ordering by time forces me to be strict in who I let in.

    Every new watering hole for conversation — facebook, google reader, twitter, friendfeed — orders my reading by time to provide immediacy. Ordering by time renders it susceptible to frequent posters. The minute I subscribe to one, the diversity of my reading goes down. Other voices become hard to find. My response to this: never subscribe to frequent posters.

    But this is a blunt heuristic. High-volume sources often have great posts. As the need for other views grows, I find coping mechanisms. Sometimes I give up and leave. Sometimes I build a replacement, and sometimes I find others have done so. Once I can get around pure time ordering, I heave a sigh of relief and subscribe to the people I want to without feeling constrained by volume.

    So, friendfeed, please help me navigate this stage of my reading. Find ways to keep my reading diverse, even if I subscribe to Robert Scoble.

    comments

    * *
    May 31, 2009
    Designing for serendipity

    Lu Liu: How can we use serendipity to get out of homophily traps? I have a serendipity friend list. But if I can define my serendipity friends, then I guess they are not really serendipity friends by my expectation. In reality, I seldom read articles from that list.

    Me: Yes, a serendipity list can't come from yourself. It must be an external recommendation. Automated since that's my bias :)

    Time is key. What is serendipitous today is not so tomorrow. That makes it harder to 'define'. In practice, I suspect we must evaluate it like we evaluate porn: not by defining it but by categorizing examples.

    Perhaps it can't be a list either, just one recommendation, with pride of place. I find I require time to appreciate something outside of my comfort zone.

    Since it must take prime real estate it must be high-confidence. If nothing is good enough today, show me nothing.

    Finally, it mustn't nag. Make it easy to dismiss, use the dismissal as a signal to learn from.

    comments

    * *
    Oct 8, 2008
    You’re going to have to rewrite code. All the time. You have to be ok with it. You have to be willing. This is the secret of the great programmers, and the great stumbling block of those new to refactoring and TDD.

    The bad news: Refactorings like extract object will require you to test drive a new class from scratch. All the time.
    The good news: It’s much easier to rewrite when you have tests. You just haven’t noticed yet.

    — me

    comments

    * *
    mission
    Making the big picture easy to see, in software and in society at large.
    about me
    Code (contributions)
    Prose (shorter; favorites)
    favorite insights
    Life
    Making
    Work
    Cognition
    Economics
    History
    Startups
    Social Software

    © mmxiv ak