Python - the first 200 lines
So I’ve spent about 4 days coding in Python. I’ve been writing a likelihood maximizer, which doesn’t sound very interesting (and isn’t, really). What I can do with it will be more interesting. In any case, here’s what I think about Python so far. Please take into consideration that I have no idea what I’m talking about when it comes to this language.
- Is it just me, or is every line supposed to be a lambda or a list comprehension? It’s not just that they’re useful features of the language – it’s every single line.
- Because of this, I wish that multi-line lambdas were possible (are they?), and that one could use a haskell-like \ symbol instead of writing out the word.
- I also wish for just “comprehensions” not involving lists .. in other words, I want to write
print i for i in arrand have it work (does it?) - Memoizing stuff is awesome. I might be over-using it. It seems necessary when all of my functions return lambdas, which seems like they might as well be memoized (most of them are called repeatedly with identical arguments).
- Numpy is OK but not great. Working with that library still feels quite clumsy, and I’m having a hard time writing code that looks visually pleasing with it. This is unfortunate, because Python is an otherwise pleasing language.
- But vectorizing with Numpy is cool. Nicely done.
- Whitespace as a control flow … (hold breath) … is fine! I’m shocked. I thought I’d be apoplectic about stupid whitespace issues, but I’m not.
- Having to put goddamn colons at the start of every new block is NOT fine. I always forget the colons. What on earth do you need the colons for?! Surely the parser can figure out what I’m doing without the need for a colon. They make an otherwise nice language annoying.
My main worry is that I’m over-complicating my designs, possibly because I feel like I need to use Python’s cool features at every instant. I’ve been undergoing a rather rough self-drubbing with a Haskell tutorial this past week, so it might very well be some of the hair-shirt rubbing off on to my otherwise object-oriented code.
In general, I like this language, it’s not abysmally slow (love ya, Ruby) and it’s not unloveably ugly (hi, curly brackets). However it is also definitely not inspiringly beautiful or particularly exciting. It’s sort of like the suburbs: “Oh. This is nice,” and bland. Whatever, it’ll work fine for my project.
Haskell is a much more Mediterranean relationship, with passionate moments and violent, crying rows. Ask me how it’s going later – right now, I’m back to the tutorial .