Friday, February 19, 2010

RPG Called Coding

Apologies for my scattered thoughts...

It's been a crazy week. The long weekend (we got Presidents Day off on Monday) only intensified my school workload, and on Wednesday my grandmother (who lives here in Honolulu) wound up in the hospital after her second stroke. It was a minor stroke, and she seems to be doing well, but she'll be spending more time in the hospital and eventually in rehab--stuff she went through last summer after her first stroke, which I'm sure is frustrating to her. I was supposed to drive her to a dentist appointment on Wednesday afternoon, which may have actually been linked to the stroke (the appointment, not my impending driving)--she had stopped taking her blood thinner for three days in preparation for the dentist. I guess that's how things can be when you're 88. Hopefully she'll have a speedy recovery.

Anyway, I meant this post to be about coding, not my grandmother. So here we go: I have three classes this semester, and they each give constant homework of different types: for Geophysical Fluid Dynamics I have to do reading (really detailed textbook reading so that I could reproduce derivations in class or analyze the physical meaning of equations in different ways); for Equations for Geophysics (aka "advanced math") I have to do problem sets with good old paper and pencil; and for Data Analysis I have to do coding in Matlab. Which of these assignments do you think I enjoy doing the most?

That's right: coding. The other assignments are painful. But the coding is actually kind of fun, to the point that I procrastinate on the other classwork by touching up my already working code. It's a good thing that I find coding fun because I have sentence myself to a career of computer programs. Coding is kind of exciting, since you start with a blank screen, puzzle your way through the problem, and wind up with colorful plots, or interesting numbers, or... some sort of reward to admire, at least.

I was recently discussing this topic with a coworker, and he pointed out that programming in Matlab is a bit like playing a computer game:

"My wife will call to ask me, 'Hey, when are you coming home?' but I'll tell her that I just can't leave until I finish this bit of code. It's like 'Wait, I just have to beat this level!'"

And I realized that's exactly what it is. I like coding because it's a bit like playing a computer game. Now, computer games are designed to be fun and entertaining, while data crunching generally isn't. Still, both gaming and coding have their frustrating moments. You can spend hours trying to get one thing to work just right (it doesn't happen very often, but there are a few game battles I could name that I have spent multiple hours trying to beat), and it can drive you crazy. But the satisfaction once you overcome the challenge is a great reward. Triumph is fun, and addicting.

My homework assignment for Data Analysis this week had three problems that I had to solve for four different water property time series (at five hundred different depths). Solving each of those three problems was like beating levels 1, 2, and 3. But I had developed my code using the temperature time series as the test data set; the code didn't work for the oxygen or chlorophyll data sets because those had periods of missing data (sensors didn't work or something). So then I had to modify the code to work for the series with missing data--levels 4, 5, and 6! It was hugely frustrating, incredibly annoying (I complained to at least four different people about it, individually), and yet...when I finally got it working, and those lovely graphs popped up with the oxygen data, I felt elated. I won! Take that, ye evil error messages!

I handed in the assignment only to be given a new one for next week. But I'm ready. I recruited two team members into my adventuring party (classmates I consulted with)--it's a multiplayer game, though I can't decide if I'm the tank or DPS. And in completing the last one, I gained experience, learned new skills, and even added some new bits of code to my inventory. Hopefully the game sequel will live up to the original.

2 comments:

Sebastian Anthony said...

Nerd.

Coding's definitely fun, but I think it definitely takes a certain kind of personality to actually find it FUN. I have to admit, it is great when I get a piece of code right first time, or solve a really tough problem... but generally, I'm more of an end-user than a programmer.

In our group projects, we had one guy that was a far better coder than us. He wrote much better code than any of us -- but also understood nuances that none of us could ever really assimilate.

He wrote almost all of the code, and we did the documentation :P

Eleni said...

I'm getting better, breaking myself of the for-loop habit so my code is more efficient, etc. I also tend to comment way more than is probably necessary.

And to be clear, it's still not as fun as, say, Mass Effect 2.