damn you, haskell! [01/02/2007 10:51:20]
Dammit all! I've been blubbed.
So, one of the forward chainy things I tend to do is this: I'll be sitting there thinking about a programming problem and then suddenly I'll be typing queries into google such as: "wx haskell" or "generators in lisp", or I just find myself looking at tutorials for languages like erlang or scala.
Why?
Because something irks me about python. You have no idea how common this is for me. I always wind up going back to python because I don't want to deal with the learning curve or the lack of library support.
Putting my goals on a schedule brought things into focus. There's a deadline, so I just have to tell myself no, I don't have time for that. Stick with python. And suddenly I can see exactly what that something is that's bugging me.
Most of the programs I think about involve trees or graphs of different types of data. And I was content to use objects for these things, until I picked up The Haskell School of Expression.
See to me, when I sit down to add a feature to a system... It's generally about adding behavior. With objects, you group the concepts according to the noun - the class. And sometimes that's great. But sometimes I just want to declare a tree of various objects, and then dispatch based on the type.
There are several ways to do this in python, but they're all clunky. For example, pirate (the python to parrot compiler) has one giant dispatch object that looks at a node in an abstract syntax tree, figures out what class it is, and then looks for a method on itself whose name matches the name of the class. This is okay, but it's much more flexible to have a separate object for each node type, which is what the failed pirate refactoring was all about. Then you just have a dictionary and map types to callable objects.
Well, I'm starting to ramble here. The point is that for the past year or two I've been thinking functional ideas and trying to express them in python. I've stuck with python because all my code is in python and I feel like it would be a waste of time to rewrite things in another language. But I've wasted a lot of time anyway just in terms of cramming square pegs into round holes.
So the decision I have to make is whether it's better to go through a learning curve and take on a new language, or just put my head down and do things the python way.
