What makes a great wine?

Saw a post on the Freakonomics blog about wines, and people’s abilities to tell the difference between good and bad wines. I love Levitt for his willingness to piss people off in the pursuit of truth (read the part about the scholar who stormed out of the room!) Anyways, there was a large study done, and the conclusion is that people generally can’t taste the difference between “great” wines, and ordinary wines (link goes to original paper).

Don’t get me wrong, I’ve had some reasonably pricey bottles of wine. And I’ve enjoyed some of them. I appreciate that there’s people who really take care of their vines; who pick the best grapes; who use classic equipment and methods. But, I’ve also had bottles that cost under $20 and tasted quite nice.

Generally (and with no expertise to back this up) I think the knowledge of how to produce a decent wine has spread very far, and snobbery is mostly a hangover from the past few hundred years when lots of wines were actually quite bad.

Of course, I know the true secret behind great wine. It’s that any average wine becomes great when you drink it with great people. Salud!

This gives me hope.

This post is for those of you who follow international politics on any level.

The US has had a policy of not speaking to Iran for many years. There’s even a debate in the current presidential election around “should we talk to our enemies?”.  Well, apparently someone in the current US administration thinks so.

There’s a lot of people who pooh-pooh talking, and I understand and agree with them. If you need to put up a building, standing around and talking about it won’t put the building up. If you have to make food for dinner, talking about it won’t make a nice beef stew. Talking is basically useless.

Unless you’re doing something that involves people. In that case, talking is hugely important.

A monkey wrench in monkey patching.

If you’re involved in the process of writing code on any real level, you should be a reader of Coding Horror. It’s written by a guy named Jeff Atwood, and he’s definitely got something going on between his ears.

There’s a good post from a few days ago talking about “monkey patching” which brings up some good points. A lot of code gets modified in this way, and while it makes for some really clean code at times, I can understand a maintainer of a large system to freak out when they can’t find a piece of code that they know is running. It’s one of the reasons I don’t like Flash. It’s a great language, it’s even good for teaching people OO concepts. But code can be hidden anywhere, and given that a lot of Flash pieces are made by people who are designers first and coders second, they tend to get code stuffed away in obscure places. This makes modifying it killer.

Another example of a great article is the one right after the monkey patching — it’s about normalizing databases and performance issues. This is an article with direct real world implications. If you work with databases, this post is straightforward and simple truth.

Definitely get this blog in your RSS reader. I’ve got it.

The next Twitter.

I don’t know Twitter’s mission statement, but to me it seems like it should involve enabling stream-of-consciousness communication. When I look at heavy Twitter users (especially those with iPhones), it is close to stream-of-consciousness — it seems like they’re sending every other thought to Twitter. But it’s not stream-of-consciousness for most people, there’s too much overhead in posting to Twitter.

It seems to me that if Twitter had some spare cash, it would be wise to look into developing some more advanced technology. The iPhone is very close to wearable computing, but I’m sure there’s some clever ideas in the wearable computing area that could be adopted and branded by Twitter. There’s a great opportunity for them to pull a trick like Apple did with the iPhone, and bring this technology to mass-market in a nice slick package. It’s a natural extension of their current business, and it’s a technology that’s coming — a nice time to catch the wave.

Easy exercise

I’m trying a neat workout program, called one hundred pushups. Right now I’m on week 3 of the program. It’s pretty neat so far — only needs about 5 minutes, 3 days a week. If you’ve been thinking about getting in better shape, definitely take a look at this. Literally, if all you’ve ever done is *think* about exercise, this plan is for you. There’s a version for people who can only do 5 pushups, so you’ll definitely be covered.

I’ve also been running between 1 and 2.5 miles every weekday morning. The whole day just cruises by after, and I feel like I’m getting lots more done, just because of a morning workout. I hate waking up early, but I just force myself to get over it, because of how awesome the rest of the day will be. Plus, I can listen to some tunes, or a podcast. Although, I’ve noticed if I start with the podcast, I end up thinking too much and ruining the run.

Learn to Map

As a follow-up to my previous post about how to create comma separated strings from arrays, here’s another array tip.

Let’s take the previous example of the Tags array. Except this time, Tags contains the IDs, which correspond to the textual string.

Tags[0] = 23
Tags[1] = 42
Tags[2] = 314

Rather than write a for-loop to look up each value, let’s pretend we’ve already got a function getTagTextByID(), which accepts the tag ID, and returns the tag text.

Tags = Tags.map(getTagTextByID)

Now tags has the text for the tags.

Map is a fairly common function for operating on arrays. As with the previous tip, Map is available in many languages. PHP offers array_map(), and JavaScript offers Array.map(). Check your favorite language for this function, it makes code cleaner.

As an added bonus, Map has a starring role in MapReduce, Google’s favorite technique. Shouldn’t you get to know Map too?

Comma, Separated, Values,

I recently realized how much of the art of programming is just lots of little tricks that you pick up along the way. I’m resolving to share these little tricks, in the hopes that others will do the same, either on their blogs or in the comments here.

Here’s one involving an array and building a string of comma separated values.

Let us pretend you have an array called Tags. It contains the tag names as strings.

Tags[0] = "awesome"
Tags[1] = "groovy"
Tags[2] = "existential"

You want to display these as CSV

awesome, groovy, existential

How do you do it? You might think “well, I want to print a tag, then a comma, then the next tag, and so on until I’m done”

for(i = 0; i < Tags.length; i++) {
    print Tags[i] + ', '
}

You probably see what’s wrong already. The above code prints

awesome, groovy, existential,

OK. Maybe you could get clever:

first = true;for(i = 0; i < Tags.length; i++) {
    if(!first) { print ', ' }
    print Tags[i]
}

or

for(i = 0; i < Tags.length; i++) {
    if(i == Tags.length - 1) { print ', ' }
    print Tags[i]
}

But ouch. Don’t do that.

Many languages provide a built in function for converting arrays into CSV strings. PHP calls it implode(), Javascript calls it Array.join(). Simply put, it returns a string consisting of the values of the array, with a delimiter in between the values.

Tag_string = Tags.join(', ')

Done.

Apple negotiates, not dictates

The confirmation that the iPhone will only be activated in AT&T stores is a sign that a definite concession that was made to get the price cut made. I enjoyed activating my phone from the comfort of my home — it was nice. So, it does reduce the user experience which they’re always going on about.

But, that’s a one-time deal, and it’s not an outrageous expectation of the customers. No one buys a phone because they like the activation process, and it’s not a bolt out of the blue to activate in-store.

Plus, for the long-term, it gets more of the iPhones out to market, while still ensuring a profit in the short-term, and thus continuing to establish Apple as a leading player. Portable computing is obviously where we’re headed, and Apple wants to use its current goodwill to put them in front of the upcoming wave. Overall, it’s a good move for them.

I think the lesson to take away from this is that while short-term luxuries are nice, don’t let that which is not needed prevent you from making a good long-term move.