Monday, September 28, 2009

Python : The Good, The Bad, The Ugly

Recently, I started to really jump into learning Python. I'd been interested in it before; the live interpreter was awfully handy and it seemed like another good language to pick up. For whatever reason, I wrote a couple trivial programs in it and never really got back into it until a few months ago. Since then, I've wound up rewriting a couple Perl + shell scripts in the language and really liking it a lot. What follows are my impressions after trying the language out for a little while.

The Good

Python is really easy to learn, almost stupidly so. Much like my early days with BASIC on an Apple II, I can jump right in and try new things in the interpreter to see if they work as planned. This interpreter is also a very nice way to play with and test a half-complete script in pieces before letting the whole thing run, which is terribly handy.

Overall, Python seems to go out of its way to be really helpful; even if you don't have documentation handy, it isn't difficult to dissect a module and figure out how you can use it thanks to the dir and help keywords. Most documentation I've run into is surprisingly useful -- informative without being stupidly verbose.

Speaking of being verbose, I can't help but draw some comparisons to Java here. Python is certainly object-oriented, much like Java and C++ but it lacks those languages' distinction of being wordy and obnoxious. Yes, lots of things are objects, but you really don't notice unless you want to. Python doesn't seem to care what paradigm you use when programming.

I've also noticed that the various libraries available in Python are really helpful; tools like Mark Pilgrim's Feedparser make handling RSS and Atom a fucking breeze. You give it either a url or a file name and it figures out what you mean on its own and parses it into a homogeneous data structure. This saves me a lot of time compared to poorly-maintained junk like XML::Simple or some of the other XML parsing tools out there. This seems largely prevalent in the community as a whole; APIs are ridiculously easy to use I've found. pyAudere is another example; in roughly three lines of code, I can have a sound card initialized, an audio file (most formats supported, and it'll figure out what you mean on its own) loaded into RAM, and played back. I don't know that I've replicated such a feat with other tools.

Which brings me to something else I've really liked; the functional programming primitives that are readily available in Python. Tools like map, reduce, and filter and of course lambda are all just sitting there waiting to be utilized. These are awfully useful if you're hacking at Project Euler for fun, but quite handy for more typical usage.

As a new user of the language, I don't think that I can escape commenting on whitespace. For the most part, Python's whitespace rules are exactly what you should already be doing in the first place and as such I don't really see them as an issue. Lately, I wish that Java had a similar mechanism for when I have to read other people's code.

The Bad

Python is constantly evolving. Right now, there are two major branches of the language, the Python 2 version family and Python 3. Within Python 2, there seem to be three significant versions (2.4, 2.5, and 2.6). Here's where the fun begins; I wrote a program on my netbook which had Python 2.6 installed as that version seems to be both current and well-supported by major libraries. Python 3 has some nifty changes, but it seems that a good number of libraries don't support it yet. This will undoubtedly change in time, but right now I only play with Python 3 a little bit and tend not to use it for anything I'm trying to really work on.

Normally when there's multiple versions of a language, it would seem a simple task to just avoid other versions. I did however bump into issues with this, and while it isn't Python's fault, it is annoying. I wrote a script on my netbook, tested it and everything, only to have it crash when I ran it on the Debian box at home. The problem? I was using a string formatting method that wasn't supported in 2.4 (the default version on the system) but was most certainly present on the copy of 2.6 on my portable machine.

I'm also not a fan of how bugs just seem to lie in wait with Python scripts. Because Python scripts don't get compiled at runtime like Perl, I've been bitten by the occasional bug hiding down an obscure branch of a program, such as a syntax error or type mismatch that I never noticed before. Being new to the language, I often make late discoveries about things returned by objects, or member functions that are apparently missing in today's version of the language. This is highly irritating to me.

While I haven't run into this, I have heard tales of poorly-behaved editors in collborative projects utterly wrecking a script because one was using tabs and another turned the tabs into spaces (and so on). It's a little alarming to me that an editor can break a build that badly, but this isn't something I've run into in practice.

The Ugly

That multiple versions problem I mentioned? It can rapidly escalate into its own special world of pain and suffering. Again, this isn't really a problem that I pin on Python's tail, but it has been a bit of a headache. While downloading and building a version of the Python interpreter isn't an arduous project, it seems that the standard library isn't assembled for you in the process. My current installation of 2.6 on Debian 5 is halfway braindead because at no point in the configure script did it bother stopping to say, "hey, you need a current version of simplejson for this to work!" or anything like that. Even better, the instructions supplied when I attempted to make these things were not accurate. I think I know how to fix it, but I'm bothered that this should be an issue. Oh well, it could be worse; evidently there's problems getting it to build at all on OSX 10.6.

Conclusions

I'm really liking Python as a tool, and have barely looked back at Perl for the most part. I like Perl regular expressions better and how they just flow into the code as opposed to Python's re module, but that's mostly an issue of culture shock for me. Otherwise, I'm finding that a lot of my projects just work better, and seem to do so with less work on my part, which is really the important thing.

Labels: ,

Tuesday, September 08, 2009

Internet down since 0945 today. Mediacom cant send a tech until thursday - when im in michigan. Useless.

Saturday, August 08, 2009

Everything is Better With METAL

I think that they should run this clip by Mastodon before movies.

Labels: ,

Friday, August 07, 2009

PSA

Parents, remember to talk to your kids about black metal before somebody else does.

Or else!

Labels: ,

Monday, August 03, 2009

Movies : Primer

If you don't have time to read my blathering today, take one thing away from this post : See Primer if you haven't already.




I've been watching more movies lately as I finally broke down and got a Netflix account. While I have seen a fair number of pretty good films, I am reminded that Sturgeon's Law is in fact quite true. Not to mention that in an era where "science fiction" seems to mean "tits and explosions, but they're in space" it seems that really good science fiction has been hard to find, at least in the cinema. Still, there are good movies to be found if you look hard enough, and one of the best that I've seen recently is an obscure independent film called Primer.

Primer is about a couple engineers producing computer parts out of their garage and then trying to take things to the next level. They attempt an experiment with superconductive materials and are surprised by anomalies in their test results; further examination of the data reveals that they have created a device that may well allow them to travel through time. Once they've confirmed that this is the case, they ask themselves "what do we do with this?" Instead of bewildered disbelief and grandiose plans, they approach the use and circumstances surrounding their time machine in a fairly convincing manner; they're actually aware of time travel stories in popular culture and approach the situation as carefully as they can.

Also, the fairly natural dialogue of the movie is something I appreciated; people interrupt each other. They speak in jargon without explaining it to the audience. Between this and their fairly believable reactions to the situation as a whole, the character became very human and believable. It's also nice to see that the entire story was moved along by the characters instead of increasingly implausible situations. There's no villain or monster waiting to devour them. There's no plot to assassinate a famous leader or anything like that -- it's all about the people and one great big "what if?"

Anyhow, I really liked this movie and don't want to go into it too much for fear of revealing the plot. Suffice to say, I really liked it and recommend taking the time to watch it twice.

Labels:

Thursday, July 30, 2009

138/84 we are good to go!

Wednesday, July 29, 2009

If I worked in human resources, I would change my name to Giger.

Thursday, July 23, 2009

Quickie

Here is a short but funny clip about pseudoscience in today's culture.

Never heard of this guy before this morning; caught it on Pharyngula this morning.

Labels: , ,

Wednesday, July 22, 2009

Podcasts: Metalcast

It isn't often that I write about this particular form of media; out of everybody I know, only one actually listens to podcasts at all. Anyway, I've recently become hooked on Metalcast, a weekly one-hour music show featuring a mix of songs by various heavy metal bands.

Anyhow, I have rarely listened to music podcasts before and didn't really know that there were good ones out there. The first one I listened to was terrible and another was only "almost good." Metalcast is completely unlike those so far -- I've enjoyed every episode so far and find that it's really top-notch material on the whole. They consistently play a good sampling of tunes, and don't typically waste a lot of time introducing the songs. Audio quality is good on the MP3 version and probably better on the standard M4A feed.

They've been running since 2006 and have 119 episodes in their archive right at this moment. Many of their episodes are basically grab bags of interesting songs and just as many are specials focused on specific bands, sub-genres, and even countries. If you're into metal, there's no way you won't find something worth checking out.

Best of all, I'm hearing new and interesting music that's very well-selected by people actually interested in what they're doing. It's like radio, minus the HORRIBLE SUCKING SOUND. I strongly reccomend this show to anyone who might be remotely interested in it. It's really worth checking out.

Labels: ,

Tuesday, July 21, 2009

Gamestop Sucks

This is something less than news, but I just thought I'd take a moment to point out that GameStop has managed to sink my opinion of them to "Internet scammer" or at least a bunch of incompetent buffons who have never heard of "customer service" in their lives. To be clear, after hearing stories about the lengths that Nordstrom's would go to to serve customers, I have to conclude that GameStop is the anti-Nordstrom's.

Back in May, I got a copy of Guitar Hero: Metallica from my Dad, and really enjoyed it. However, as this title is based on the GH: World Tour engine, it sometimes uses a feature that my normal guitar doesn't have -- the little slider bar near the base of the guitar. Generally, this isn't a big deal, but I figured it might be nice to pick up a guitar made for the game and it wouldn't hurt to have a second one around anyway.

My options seemed pretty limited; most place I went wanted to sell me the guitar + game for about $90, which struck me as pointless since I didn't want the actual game, just the guitar. At best, one shop told me that if they had the PS2 guitar in, they'd sell it for about $40-$45. Of course, nobody ever had one in stock.

Back in June, GameStop started a sale of copies of various plastic-instrument games to clear out their warehouse. I looked idly and saw that it was an online only deal, and that the PS2 version of the game with the guitar was listed at $34.99. Perfect; It was like getting the guitar for $5 to $10 off and another set of songs for free. I figured "why not?" and placed the order.

In about a week or so, I finally got the package from the UPS guy and discovered that they had sent me the Xbox 360 version of the game. So, I called customer service and explained it to them and they confirmed that there had been a mistake and e-mailed me a return label to send it back.

Awesome; now I have stupidly-large box to send back and no vehicle to get to any UPS store with. I have no printer to speak of, AND the clowns at UPS won't print the label if I bring it in on a flash drive. I wound up hauling it to work on the bus, printing the label there and having the UPS driver there pick it up.

Then, I wait.

The package gets delivered to them quickly enough. Then - nothing. No phone call, no e-mail. I give them a week and then call on a Friday afternoon inquiring about the order. They tell me that they have to find a copy of the game yet. Annoyed, I wait another six days before calling again. They *still* can't find it.

Horseshit; it does not take that long to find something in a modern warehouse unless those in charge are completely incompetent. At this point, I'm not seeing any option other than calling my credit card company and filing a fraud report. Sending me something other than what I ordered is understandable. Leaving me hanging and fucking around instead of sending what I bought and paid for this long is unacceptable.

Fuck Gamestop.

And UPS, while I'm at it :P

Labels: , ,