Statistically Significant

May 16, 2010

Random Thoughts on Programming

Filed under: Life,Math — Hoxie @ 9:05 am

This past week, I learned of a cool little resource for people learning a new programming language: Rosetta Code. It’s a wiki-style site that contains user-submitted solutions to many common programming tasks in a variety of languages. R is definitely my language of choice these days, and while many R solutions had already been provided, I filled in a few blanks this week: Amb, Luhn, pangram, binomial, permutation, Hailstone, reversalGame. (Yes, I did beat the reversalGame in 4 moves. No, I can’t do that consistently.)

A few thoughts I’ve been having about programming lately:

- Writing code, especially solving little problems like these, is a lot of fun!

- I once watched an MIT Open Courseware data structures class introductory lecture, and one of the first things that the professor was, “To get good at programming, you can either do it for 10 years or you can take a data structure class and then do it for 1 year.” For about January-March, I was working through an introductory Python book, which exposed me to some new data structures and programming ideas. Applying some of those ideas to my R programming made me a much better programmer almost overnight. It was great.

- J appears to be an insanely powerful language with an equally insane learning curve. Consider, for example, the Hailstone Sequence task on Rosetta Code. My solution in R is pretty straightforward… even if you don’t know R, it’s pretty easy to just read along and assume that the syntax is correct. Now consider the J function that does the same thing:

hailseq=: -:`(1 3&p.)@.(2&|) ^:(1 ~: ]) ^:a:"0

Crazy. I saw this when I was doing Project Euler problems, too. Note to self: learn J. But only after improving your Python skills, learning C, and beefing up your scripting skills.

- Most of what I’ve been doing for this past year has been programming, not statistics. But programming and statistics are different activities. Therefore, I expect a pretty serious transitionary period away from writing code and towards doing theoretical statistics problem sets. (I don’t expect to write very much code at all next year, although my R skills will definitely come in handy when I need to.)

On a related note, I subscribe to Scott Adams’ (author of Dilbert) blog, and he made an interesting observation that really rang true with me in a recent post:

During one period of my life I wrote a number of computer programs that involved intense manipulation of objects in my mind, for hours each day. I discovered that it was difficult to be social at night when my mind had been manipulating object during the day. It felt as if I were deep inside a cave and yelling to the people who stood at the cave opening. It seemed as if the practice of programming interfered with, or exhausted, the part of my brain that handles social skills.

That metaphor, of standing deep inside of a cave and yelling to the people standing at the entrance, so accurately captures the way that I feel sometimes after a long day of being totally in the programming zone. Any other programmers experience a similar phenomenon?

2 Responses to “Random Thoughts on Programming”

  1. Paddy3118 Says:

    Hi,
    I note that you are interested in stats. I wonder if the Monty Hall problem at http://rosettacode.org/wiki/Monty_Hall_problem will interest you?

    It is issues like that that make me try and simulate problems involving probabilities as so often the answers are non-intuitive.

    Have fun, Paddy.

  2. Hoxie Says:

    Thanks for suggesting the Monty Hall problem! Very cool problem, and definitely a great example of an eye-opening simulation. I stared at that one for a long time when I first saw it :)

Leave a Reply