Sunday, August 22, 2010

"That Deaf, Dumb, and Blind Kid...."

I work in a small-scale downtown area now. I commute to and from work on a bus. I see a lot of people every day, scurrying from place to place. Everyone seems to have earbuds jammed into their ears, with ubiquitous white cords dangling down to connect them to "their music", the soundtrack to their lives that makes them the individual they are - along with the millions of others making identical choices. So many of them are simultaneously scrolling through e-mail messages on their iPhone or Blackberry or Android, furiously tapping out a text message, or browsing something on the web.

They're completely cut off from their surroundings, any random contact with people around them, snug in a digital cocoon.

The ear buds and extreme focus make me think of that 60s rock opera "Tommy":

He ain't got no distractions
Can't hear those buzzers and bells
Don't see lights a flashin'
Plays by sense of smell
Always gets a replay
Never tilts at all
That deaf, dumb and blind kid
Sure plays a mean pinball

It drives me crazy to see someone on a bicycle with ear buds in. Hearing what's going on around me is a key component of keeping myself safe when I ride.

It's always someone else that's interesting in this cocoon: the person you could be talking to. Anyone within reach is fair game to be ignored or interrupted in favor of the next incoming packet of stimulation.

All this technology is re-wiring us and re-writing the rules of etiquette for social interaction. Sometimes it's good, but not always.


We're experiencing a rare morning of sustained rain here. It's been a dry summer, so the sound of droplets drumming on the shingles was most welcome.

I've spent most of the morning at a computer with the television off. The only sounds I can hear are the computer's fan, birds chirping in celebration of the moisture coming down, and the occasion splash of a car going by. The dog is being his usual handsome, lazy self lounging on the sofa. I'm puttering around: paying bills, writing some code in Python, and killing time with this blog.

I'm conscious of the end of another summer. My beloved eldest daughter is in Brooklyn awaiting the start of classes and grad school. My adored youngest daughter will be leaving us again in six days to renew her pursuit of an undergraduate degree in molecular cell biology. My wife will mourn the end of the period of renewal and head back to work in the schools on Wednesday. We'll be empty nesters for the first time this fall.

I rode my bike into work last Tuesday. It was dark enough when I left the house that cars had to put their lights on. I had a strobe light on the rear pannier to give those drivers their best chance to avoid hitting me. I may have another morning ride or two left in me, but the season for riding to work is rapidly coming to a close.

This is a solemn time of year for me. It's a reminder of the period fifteen years ago this year when a younger brother passed away. That was a hot, dry summer; just like this one.

I'm spending time learning a new language, Python, by working my way through "Core Python Programming". I'm enjoying it very much, now that I have a great IDE: PyCharm from JetBrains. "Develop with pleasure", indeed: it's fun to have a nice tool to help lighten the load. Python is fun after years of writing Java. It just feels light and fast. I like the combination of functional and object-oriented styles in one language. I want to remember the math I know and check out SciPy and NumPy; I want to find out if Django is just like Grails and Ruby on Rails.

I just want to keep learning and continue to do something - programming - that I like to do but rarely get a chance at in my current position at work.

Thursday, August 5, 2010

First IKEA Visit

I made my first pilgrimage to IKEA this past Sunday. My oldest daughter will be moving out this month, so we took a trip to find a bed: a decent, full size mattress that will last her for a while.

I had a similar feeling when I walked into Whole Foods for a first time: a little overwhelmed, awe-struck by the sheer scale of the display in a temple devoted to consumption.

Those IKEA folks must have taken a page from Disney: they shepherd you along a well-marked trail throughout the store so you have to see everything they have to offer. The number of path choices are limited and winding.

We looked at several beds that were nice before settling on one that suited her well. We asked about pickup and delivery options. IKEA won't bring it to her new apartment, but there's a store nearby that would make the pickup easier. (I wasn't thinking today; we should have brought a car that's bigger than a Honda Civic so we could have taken our purchase away.) We'll probably just go back to this store before she leaves to minimize running around on moving day.

It's an emotional thing to see one of my children leaving home. I remember it being a very hard thing for me to do, both when I took the half-step out of the house to go to college and the full, headlong leap into my first job and apartment upon graduation. The job didn't pay much. I didn't have a lot of possessions: a bed, a stupid desk bought at a second-hand store that I was convinced was worth refinishing, two guitars, a small all-in-one stereo, my clothes, and a few kitchen items so I could feed myself.

It wasn't a young man's bachelor pad, by any stretch. I don't recall either of my parents setting foot in it during the two years I lived there. No one who came to visit once came back a second time. I can't tell if it was because the company was poor or the lack of a couch to sit on.

But it was my place. If I came home from work and wanted to swim or play basketball before cooking dinner, so be it. One of the reasons I've become such an avid swimmer was that I had an indoor pool available to me every day. It was a bathtub - just 20 yards long - but it gave me the chance to practice my poor freestyle in relative privacy without worrying about being run over by better swimmers or cannonballed by flying children.

I didn't have a television set, so there were few distractions. I'd listen to the public radio station for company: Robert J. Lurtsema on WFCR was the star of the dial. His "Morning Pro Musica" program would start every day at 6 AM with themes like Respighi's Ancient Airs and Dances Suite (thanks to Google and 10engines for this nugget). There was one piece, whose title escapes me, that I learned how to play on the guitar. It was always a pleasure to hear it and think to myself "I know how to play that."

I rekindled my love of classical guitar after a four-year undergraduate hiatus by going to the music store down the street and signing up for lessons. My teacher was a young Hartt School graduate named Jim Petrie. He was a terrific teacher. I wish I could say I was a better student. I practiced faithfully, usually in the morning before I went to work. I found the early hours lent themselves to this sort of thing.

When I married my wife she was the one who brought "stuff": a huge, comfortable couch from her parents that was long enough to stretch out and take naps on; lamps; end tables. One point of friction at first was the television. If I liked listening to the radio for company, she liked to have the television on. I chafed under the new regime at first - until the NBA playoffs rolled around. I was happy to be able to watch a young Larry Bird face down the Houston Rockets.

You never forget your first apartment. I hope my daughter makes good memories in hers.

Sunday, August 1, 2010

Python and PyCharm

I bought a book entitled "Core Python Programming" by Wesley J. Chun at the urging of John D. Cook. It's a wonderful book, but I stopped reading about three-quarters of the way through. I wanted very much to learn Python, but I didn't have a motivating problem. I was also lacking a good IDE. As a Java developer, I'm used to having IntelliJ by Jetbrains on hand at all times. I think it's the best IDE there is. I buy a personal license every year, because I don't want to work without it.

I've been trying to do more coding on my own time lately, because my architecture day job doesn't afford me any opportunity to write code. (We draw UML diagrams, write documentation, and act as a go-between for the business and the developers.)

I've been aware of Peter Norvig's brilliant spelling corrector in Python for a while. He makes magic happen in just 21 lines of Python 2.5 code. It inspired a cottage industry of efforts to match his functionality and succinctness in other languages, including Java and Groovy.

This weekend I thought I'd revisit his spelling checker and see if I could reproduce it in Java. I wasn't concerned with minimizing lines of code. My goal was to maximize my understanding.

The shell of the code is simplicity itself, but when I got to the heart of the matter I didn't understand the Python idiom well enough to see my way through in Java, so I got my "Core Python Programming" off the shelf and started trying to piece things together. Running the code in a debugger would help. What tools could I use?

That's when Jetbrains came to my rescue again: I downloaded the latest version of PyCharm, their new Python IDE that's now in beta. It offers the same wonderful feel that I've enjoyed in IntelliJ for years.

It was easy to create a new project and add Norvig's code and seed file. I didn't know how to run a module in the console - that's how green I am - but it didn't take long to figure out how to import. Then there was the problem of command line arguments. I knew how to enter them in Java - how to duplicate the trick in Python? Thank god for Google; the answer was soon at hand.

The script took a very long time to run when I tried it the first time. What was taking so long? The debugger clued me in: the first command line argument was the full path to the script being executed, which drove the poor spelling corrector crazy. How to avoid processing the first argument? With Python, the answer is easy. You change this:

if __name__ == "__main__":
for arg in sys.argv:
print arg, correct(arg)

to this:

if __name__ == "__main__":
for arg in sys.argv[1:]:
print arg, correct(arg)

It felt great to work through some simple difficulties that are challenging to a newbie like me. I'd love to develop a comfort level with Python sufficient to start taking advantage of its terrific scientific programming libraries like NumPy and SciPy.

I'm going to continue working to port the spelling corrector over to Java. It's a terrific application of Bayesian statistics.

But I hope that having a world-class IDE at my disposal will re-inspire my Python efforts.