24 May 2008

EAFP vs LBYL

I've been learning Python in the last few weeks. Many of my friends have switched to using it, making me think that it's the scientific programming language of the future (if not now).

I've been working my way through the official Python tutorial. I was amused to find the following in the tutorial glossary:
EAFP
Easier to ask for forgiveness than permission. This common Python coding style assumes the existence of valid keys or attributes and catches exceptions if the assumption proves false. This clean and fast style is characterized by the presence of many try and except statements. The technique contrasts with the LBYL style that is common in many other languages such as C.
And what is LBYL, you may ask?
LBYL
Look before you leap. This coding style explicitly tests for pre-conditions before making calls or lookups. This style contrasts with the EAFP approach and is characterized by the presence of many if statements.

23 May 2008

Link of the day: Attenuation and the suck threshold

I really like the graph in this post entitled "Attenuation and the suck threshold." The post is about designing software for end users, but the graph applies to most pursuits in life. We want to design life paths where we can quickly get past the "suck threshold," so we can capitalize on the "passion threshold."

Link of the day: Gin and the cognitive surplus

I got this link from a high school friend. It's a video of a talk by Clay Shirky about cognitive surplus.

Shirky gives two examples of cognitive surplus. Right before the Industrial Revolution, people were in shock because the transformation from rural to urban life was so sudden. So they passed the time by drinking large quantities of gin. The second example is post-World War II American society. People only had to work five days a week so they had to do something with their time. They spent it watching sitcoms like "I Love Lucy." So cognitive surplus is the freed time we have from technological advances. Note this is different than just being rich and hiring people to clean and cook for you. This is free time on a society level.

Shirky claims that we are now at the beginning of an age where people have realized there are more options than just watching TV. That was the era of consumption and that is the model that current media companies have. Now we can also produce and share via the Web 2.0 model. We can share links via del.icio.us, share photos via Flickr, blog, etc.

I think there's a great deal of truth to Shirky's idea of "cognitive surplus." It's true that people have been playing sports together, gathering for farm competitions to show off animals and vegetables, etc for years. But the advent of the web makes these things much easier. If you like theater but don't live near a major city, you aren't completely hamstrung anymore. You don't have to move to New York. You can watch illegal clips of theater on Youtube and participate in forums like musicals.net.

I've been moving my life into Web 2.0 in the past few years. Two of my Flickr photos were selected for the Schmap guides. I make my del.icio.us, Flickr, and LibraryThing accounts public. I blog. I actively contribute to forums like musicals.net and ModSquadHockey. There are a lot of really smart people out there and they are much easier to find on the web. I've learned a lot about how to watch a play and how to select the right hockey equipment from these forums.

22 May 2008

Link of the day: Get people to do your research for you by playing video games

We've seen SETI@Home and other distributed computing projects that borrow computing power. We've also seen scientists have users identify CAPTCHA images for their research. Now, the next level, some people have developed a video game that somehow simultaneously entertains the user while solving protein folding problems. The Science Daily article has more details.

Song of the day: "You Gotta Have A Gimmick" by Jules Styne and Stephen Sondheim

I love the jazzy, brassy tune, but don't count on me singing this one out loud.

From Gypsy
Mazeppa
You can pull all the stops out
Till they call the cops out
Grind your behind till you're bend.
But you gotta get a gimmick
If you wanna get a hand.
You can sacrifice your sacharo
Working in the back row.
Bump in a dump till you're dead.
Kid you gotta have a gimmick
If you wanna get ahead.
You can uh...You can uh...
You can uh...uh...uh...
That's how Burlesque was born.
So I uh...and I uh...
And I uh...uh...uh...
But I do it with a horn...
Once I was a Schleppa,
Now I'm Miss Mazzeppa,
With my revolution in dance.
You gotta have a gimmick
If you wanna have a chance!

Electra
She can uh... She can uh...
She can uh...uh...uh...
They'll never make her rich.
Me, I uh... and I uh...
And I uh...uh...uh...
But I do it with a switch.
I'm electrifying
And I ain't even trying.
I never had to sweat to get paid
'Cause if you got a gimmick
Gypsy girl, you got it made.

Tessie Tura
All them uh and then uh...
And that uh...uh...uh...
Ain't gonna spell success.
Me, I uh... and I uh...
And I uh...uh...uh...
But I do it with finesse.
Lady Tessie Tura is so much more demure
Than all them other ladies because-
You gotta get a gimmick
If you wanna get applause.

ALL
Do something special
Anything special
And you'll get better because
Come on and just do mimic
When you gotta gimmick
Take a look how different we are!

Electra
If you wanna make it,
Twinkle while you shake it.

Tura
If you wanna grind it,
Wait till you refined it.

Mazeppa
If you wanna stump it,
Bump it with a trumpet!

ALL
Get yourself a gimmick and you too,
Can be a star!

21 May 2008

Creating a knowledge vault

Cal Newport blogs about writing down what you learned so all that studying doesn't go to waste.

I've been having exactly the same thoughts lately. I moved my website to siteground.com because they claim to make it easy to install and use MediaWiki, the wiki software used by Wikipedia. I suppose I could have used something free like pbwiki, but pbwiki uses proprietary software. I want to have control of my data and be able to back it up and move it to other servers if necessary.

Link of the day: How to make accurate time estimates

I'm always underestimating how long things take. Steve Pavlina shares some nice ideas about improving time estimates in a recent post. The basic idea is to record how long it takes you to do things and after accumulating enough data, calculate your appropriate fudge factor.

Gypsy review

I just got back from seeing Gypsy on Broadway, fourth row center. :-D (If you're wondering how I got that seat, I bought it months in advance.)

The book was written by Arthur Laurents (who is also directing the current production at 90+ years of age), the music by Jules Styne, and the lyrics by Stephen Sondheim. The story is pretty simple. It's about a stage mother, Rose Lee, who will do anything to make her two daughters stars on the vaudeville circuit. She seduces a theater agent, Herbie, into helping her. Eventually, her meddling and inflated ego drive away her younger daughter June, the star of her act. Rose resolves to take the hit in stride and re-works the act to center around her other daughter, Louise. The act is so bad that they end up in a house of burlesque (basically stripping). Rose finally decides to call it quits on her stage dreams and marry Herbie as she promised, but at the last minute, there is an opportunity for Louise to take the star strip spot. Herbie realizes that he can never marry Rose and leaves. Louise becomes a star stripper and with her newfound confidence, becomes an independent woman. Rose is left feeling empty and wondering what "she did it for." Gypsy is often considered one of the best written musicals of all time; someone even calling it the King Lear of musical theater.

Now, my comments on the actual performance. Patti Lupone played Rose, Boyd Gaines played Herbie, and Laura Benanti played Louise. All three have been nominated for Tony Awards. I came to the musical expecting Patti LuPone to belt her way through (LuPone had a tendency of doing that in her earlier years), but she really did a great job acting, so much that I noticed her acting just as much as her singing. I think LuPone has been working very hard in the last ten years to become a better actress and it shows. She was very controlled and focused acting-wise all the way through, only really belting in the Act 2 finale, "Rose's Turn." I felt like LuPone's singing voice was a little off, but it could have been my imagination. LuPone played Rose as a very human creature. Some people (I'm thinking Bette Midler) have played Rose as this crazy superwoman and that choice just doesn't work because I can't imagine Herbie falling for that kind of Rose. I really liked Boyd Gaines and Laura Benanti as well. Gaine played Herbie as a really sweet guy who's seduced by Rose. He plays along until he explodes right before Louise becomes a stripper. It's hard to imagine a more likable and believable Herbie. You really feel like Herbie is madly in love with Rose. Gaines and LuPone have great chemistry in songs like "Mr. Goldstone, I Love You" and "Together Wherever We Go." Benanti does the transition between Louise the eager-to-please girl and Louise the confident stripper very well. I thought the actor who played Tulsa was good, but not outstanding. There was just some spark that was missing. The orchestra was fantastic, especially the brass, and they had a full 25-member complement. Yay for old-fashioned overtures! Interestingly enough, Arthur Laurents chose to put the orchestra on the stage behind the set. I liked that choice because it made the orchestra part of the story more and the actors were closer to the audience.

Even if you've seen other productions (I watched both movies before attending this show), there are some new, thoughtful touches. During the "You'll Never Get Away from Me" number, Rose starts dancing with Herbie and somehow Rose drags Herbie onto the ground and they end up rolling around on the floor. It was hilarious. They end the number with a tender kiss, while sitting on the floor -- aww, how sweet. In the "You Gotta Have a Gimmick" number, Electra is played as a lethargic woman who wearily turns the switch on her costume. The ironic joke is that the woman with the flashiest costume has the opposite personality. That is a directing choice I was not expecting and very refreshing.

Laurents's direction emphasizes how Rose and Louise's roles are gradually switched over the course of time. Louise becomes more and more confident with each strip and she starts talking down to her mother. Rose breaks down during "Rose's Turn" and in the conversation with Louise aftewards, she starts crying. Pretty shocking. Louise (Benanti is conveniently quite a bit taller than LuPone) comforts her mother like she's a child. Rose regains her composure and tells her dream about having her name in lights -- "Madame Rose and her daughter Gypsy." Louise walks off chuckling, obviously not taking her mother seriously. In the movies I've seen, you are given the impression that Rose and Louise reconcile -- walking off the stage arm in arm, but in this performance, I didn't get that sense at all. Instead as Louise walks off alone and Rose is seen with her back to the audience, grasping at her name in lights -- a very dark ending.

One of the things I really like about Gypsy is that it has something for everyone. Kids will enjoy the silly vaudeville acts and Tulsa's dance number. Adults will appreciate the complexity of Rose's character and the fine supporting acting from Louise and Herbie. The score is wonderful, upbeat, and jazzy (something I didn't appreciate until now). There is a lot of humor in the musical (especially in the "You've Gotta Have a Gimmick" number starring three strippers), but also a lot of darkness especially in "Everything's Coming Up Roses" and "Rose's Turn".

Anyways, all the rave reviews from theater critics are true. The play is beautifully acted, beautifully sung, extremely entertaining, and extremely thoughtful.

10 May 2008

Line spacing issues in blog

I've noticed line spacing problems in some of my posts. In these cases, there was no whitespace between the last line of the post and the footer of my poster (e.g. "Posted by qmechanic...")

I posted my problem in the Blogger Help group and got a very helpful answer. To make a long story short, it has to do with the way Blogger templates work and the issue can be fixed by inserting a strategic paragraph opening tag.

I went through my entire blog and fixed all the posts with this problem. I also fixed a few other line spacing errors, unrelated to the Blogger template.

05 May 2008

Laying down your burdens and finding redemption

This past week's Battlestar Galactica episode "The Road Less Traveled" explores the theme of struggling with your past, laying down your burdens, and finding redemption.

Kara "Starbuck" Thrace is a hot shot pilot and the poster child for self-destruction. She draws good people to her like the Adamas (father and son), Anders, Helo, but she often abuses them and on the few occasions where she realizes what she's doing, she simply tells everyone "I frakked up" and goes back to her self-destructive behavior. In the end, it seems like her only redeeming quality is being the best pilot in the fleet. Starbuck is the female version of the prototypical abusive husband. Last aeason, we found out that her behavior had its roots in an overbearing, narcissistic, equally abusive mother.

Leoben, one of the Cylons, is the only "person" who understands her. In this episode, he appears in a badly damaged raider and is taken prisoner. Starbuck, the commanding officer of the ship Demetrius, brings him onboard. A crew member dies after the raider explodes in a seeming accident. Starbuck storms into Leoben's cell and punches him in a fury. Leoben tells her to finish it and kill him. She tries to continue beating up Leoben, but she can't bring herself to do it.
Leoben: It doesn't help, does it? Nothing feels quite like it did before, I know.

Starbuck: What are you doing to me?

Leoben: All of your life, you forced back the truth by lashing out at everyone. Anesthetizing yourself with ambrosia to empty your fears. But you've lost the taste for those petty things.

Starbuck: I'm the same person!

Leoben: No! The ... emptiness can only be filled by taking the next step on your journey.

Starbuck: What happened to me the two months I was missing?

Leoben: I don't know.

Starbuck: You recall? The pain, my mother, it had to mean something.

Leoben: You have to make peace with your past.

Starbuck: Why?

Leoben: Because that part of you is gone.
Starbuck isn't the only one with personal demons. Gaius Baltar, the anti-hero who played a major role in humanity's destruction, has become a preacher of the One-God religion in the past few episodes. Baltar reaches out to former flight deck chief Galen Tyrol who is having a very hard time coming to terms with his Cylon existence and his wife's death. Baltar tells Tyrol:
I know it's hard to...make sense of things sometimes. In my own life, I...in my own life I've joined the fleet as a scientist, as a skeptic, as a...supposedly a man of reason. Only to have fate turn that all on its head. But I understand now that there is a purpose to it. We change. We evolve. Maybe we even learn something along the way. (pauses) I have committed...unconscionable crimes. And I have been offered one last chance at redemption, because I chose to accept my fate and not fight it anymore.
Battlestar Galactica is very much about bad things happening to people (whether they did it to themselves or it happened to them) and how they deal with their problems. Starbuck seems to reach a turning point where she's left behind self-destructive behavior and looking for the next step: redemption. Baltar's already taken that step. And as Baltar and Leoben say, the key to finding redemption is to accept the past, accept that the past is part of who you are even if it's horrible and make peace with it. In the ministry, people often call this process "laying down your burdens" (this phrase incidentally is the title of an earlier Battlestar Galactica episode.)

02 May 2008

Quote of the day: Scientists vs Humanists

A good many times I have been present at gatherings of people who, by the standards of the traditional culture, are thought highly educated and who have with considerable gusto been expressing their incredulity at the illiteracy of scientists. once or twice I have been provoked and have asked the company how many of them could describe the Second Law of Thermodynamics. The response was cold: it was also negative. Yet I was asking something which is about the scientific equivalent of : Have you read a work of Shakespeare's?
- C.P. Snow from The Two Cultures (1959)