Friday, February 26, 2010

One Language a Year: Haskell - update 2

Not much to report, except that I am still trucking along through Real World Haskell (currently chapter 7). This is much better than last year (the year of smalltalk) where I was already having lots of trouble with motivation by this point.

I've been thinking alot about what the chances are that haskell will become one of my daily use power tools like python is. Or what the chances are that haskell will "take off" like a python.

I've already (mostly) gotten over one of my haskell phobias: dealing with "do" blocks. When I only had a passing understanding, I always got confused with "<-" and "lets" and "return"s in do blocks (and nested do blocks) and the rules seemed rather arbitrary, etc. Of course I'm no expert now, but at least I don't look at them as magical things. They have a precise use and logic and now I (mostly) get them.

A couple things from python I miss in haskell: list access syntax (e.g. x[2:]), default args/kwargs, etc. Both of these haven't really hurt me yet but just the thought that I don't have them available makes me sad.

Monday, February 1, 2010

How to Run

I came across this site a few weeks ago and it has really rehabilitated my capacity for running. I'm not a big time runner but I try to run at least once a week and once a month I like to go at least 5 miles. The problem is that my knees haven't been very happy about this project for quite some time. In fact this summer I was trying to ramp up for a half marathon and by the time I got to 8 mile training sessions my knees (one in particular) really laid down the law. Basically they said stop that. I would end up taking ibuprofen and doing hot/cold treatments for a few days. This did not seem like a very wise course to continue and so I backed off.

So I've been trying the idea of barefoot running for the last month or so and the change is striking. I'm not actually going "barefoot". There is about a foot of snow in my front yard currently, but the running style is still the same. The idea is essentially to run on the front pads of your foot rather than landing on your heel. Rather than sending a shock straight from your heel to you knees and hips, you absorb most of it in the front of your foot.

I did my 5 mile route today and instead of finishing in agony and limping into my house I feel like I could easily go and do it again tomorrow.

It definitely takes concentration and practice to run this way and it doesn't feel completely natural quite yet, but at this point I don't think I could go back to "normal" running again. The main difference currently is that my calves get much more of a workout and I can still feel that and the front pads of my feet are just a little tender. They are absorbing a little more impact so I'm not surprised. It's not the feeling of my foot being abused just the tenderness you feel as you are developing tougher skin.

My wife has also adapted this style. She has suffered from plantar fasciitis for quite a while and she has noticed a huge reduction in foot pain.

So the question is, how is this just now getting around? I sure wish I knew about this 20 years ago. I could have saved my body a lot of wear and tear (possibly removing the need for my knee surgery of 6 years ago). Has this been known forever and I was just oblivious? I'd honestly never heard of the idea but now it seems sort of obvious.]

You can't help but wonder how many other easy fixes for modern problems there are out there.

One Language a Year: Haskell - update 1

So one month in and so far Haskell is treating me much better than Smalltalk did a year ago. What is better? Well to start with my main learning period is a 20 to 30 minute window each morning before work. For whatever reason Smalltalk put me directly to sleep and I would often literally find my forehead mashed into my keyboard. I haven't had that problem at all yet with Haskell. One thing is for sure, if you want to learn a new programming language, you have to be awake.

What is the difference? For one it may just be that I like functional rather than object oriented thinking better. I'm fairly comfortable with object design ideas, but things like design patterns more often than not seem like bandaids over language problems rather than powerful solution cookie cutters. Also I admit that I generally expect object based solution to be over engineered. There is such a thing as beautiful OO solutions, but they seem to be the exception in my experience.

But probably the number one success factor for me is the fantastic book: Real World Haskell. 4 chapters in and I find the pacing quite nice. And there is no shying away from mundane things like reading and writing files and reading command line arguments. I swear I have a Haskell book that doesn't do any discussion of IO until chapter 17. I get that IO is about monads and monads are serious mind benders, but you still need to crank out a "Hello World" program early on. RWH gets that and many other things right.

One of my main rules for making sure I understand everything as I'm going along is to retype in *all* code from scratch as I come across it and to do so without directly copying it. In other words I have to understand it enough to retype it in directly from memory. This is probably something I should always have done, but cutting and pasting is just so easy and there is so little time....

In any case, the year of Haskell is doing quite nicely so far.