Muli Ben-Yehuda's journal

July 15, 2003

Code that Sucks #3 – variables? we don’t need no stinking variables!

Filed under: Uncategorized — Muli Ben-Yehuda @ 6:32 AM

Compare, contrast, weep:

((bar*)foo->bar)->gar->member = ((adapter*)(ptr + 4))->sequence_number++; 

(Real code, struct and member names changed to protect the guilty)


struct bar* bar = foo->bar; 
struct gar* gar = bar->gar;

struct adapter* adapter = (ptr + 4);

gar->member = adapter->sequence_number++; 

I just spent a couple of minutes making sure that the second version is functionally equivalent to the first, and I’m still not sure. Think about it – a couple of minutes for ONE line of code. Code should be written for people first, compilers second. Say no to gratuitous obfuscation, say yes to intermediate variables!


  1. Also
    Say no to avoiding replying to people’s e-mails!
    This is also an important platitude 🙂

    Comment by moshez — July 15, 2003 @ 2:54 AM | Reply

    • Re: Also
      moshez, you are not going to like this…
      Not only did I not answer your email (yet!), I won’t be able to attend your talk.
      *gasp* *horror*
      There’s one reason, one thing, in the entire world that is compelling enough to make me miss your talk, and precisely that thing happened. I’m going to OLS, and have to leave on Sunday night.
      I’m really sorry. Yours is one of the talks I wanted to hear the most since the club was started, four years ago. At least I’ll catch you on August Pneguins…

      Comment by mulix — July 15, 2003 @ 3:08 AM | Reply

      • Re: Also
        Bummer 😦
        But at least put me in touch with the correct people at haifux before you leave 🙂
        Regarding AP: I’m going to switch the topic of my talk. I recently got into PyPy, which is a reimplementation of Python in Python. Even though it is 20k times slower than Python, there’s nothing to worry about — we have plans to make it slower.
        [And after this kind of tag line, who could miss that talk?]
        Also, you can read my talk on
        But you’ll miss me talking through it 😦

        Comment by moshez — July 15, 2003 @ 3:14 AM

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at

%d bloggers like this: