Archive

Archive for October, 2008

See, my philosophy is —

October 30, 2008 2 comments

“Skating uphill like this is amazing. Years of gliding downhill and pushing uphill, and now suddenly it’s gliding both ways. It’s like going from C to Python. You don’t realize how much time you were spending on the boring parts until you don’t have to do them any more.”

But coding C or assembly makes you a better programmer. Maybe the boring parts build character.”

    —http://xkcd.com/409/

I’ve heard this all before. This comic basically sums up the two things that geeks say about C.

First of all: programming in C makes you better at programming. This is because, the argument goes, that C requires you to pay attention to the finer details of the program, forcing you to be more mindful of your surroundings, so to speak.

The other thing? That programming in C is dull, arduous, and requires an absurd requirement for attention to detail.

What’s the advantage? The programmer mentally does the low-level work while programming, instead of having the computer do it automatically when the program runs. If this sounds counter to how the computing world in the last three decades has evolved, that’s because it is.

C was written in the early 70’s and first publicly defined in 1978, with the definitive second version (ANSI C) released in 1989. That’s right, the year of my birth. The year when Communism fell and the Apple IIc was shiny and new, with its 4MHz processor and 128k of memory.

For reference, I’m typing this up on a 1.6GHz (400 times faster) with 1GB of memory (8192 times more). And this laptop was bought specifically for its low price (and therefore low specs) in order to make it expendable.

So at this point, you may be wondering, as I have been, why we would still be programming significant codebases in C. Aside from places where performance is absolutely critical (this is why the Linux kernel is in C), I can’t think of a single good reason.

This is a position that I feel has been justified by my limited stint in learning C. A few months ago, I picked up C starting at the beginning of “C and Software Tools”, a course required for my Computer Science major, which is being taught as being about two-thirds C and one-third Python. Thus, the first five of eight programming assignments were to be in C, where these last three will be in Python. So Monday, with assignment five due that night, in class we began discussing assignment six. I realized how trivial the program would be in Python, even though it was rather previously laborious when we executed what was largely the same assignment in C.

So in 20 minutes (and 36 lines), I had programmed the solution, before we’d even finished covering the assignment in class. I then left class and spent five hours working on finishing assignment five in C, still being stymied by niggling little bugs that were uniquely C-related. In the end, I had to get a two-day extension on submitting the assignment because my program was inexplicably causing a segfault when using a string created with malloc() instead of created as a character array. For the unitiated, these two techniques are supposed to be roughly equivalent. But for some mysterious reason, beyond the comprehension of even our TAs, one was causing catastrophic errors and the other wasn’t.

And let’s be clear: this would never happen in Python. Strings and all the other data types just work. You don’t have to worry about them.

But all of these minute, inexplicable errors, they say, made me a better programmer. I disagree. They sapped my will to program and made me realize that C is exactly as advertised: very efficient if you spend hours of your time to take milliseconds off of program execution time.

Now that I’m back in a Python mindset, I can’t wait to program. For the first time since starting to program C at the beginning of the semester, I’m actually keen on working on some Project Euler problems, where the thought of doing them in C caused me to shudder.

I can get stuff done faster in Python, and I don’t hate doing it, plus it’s easier to read and more portable? Sounds like a win. Coding in C hasn’t made me a better programmer: switching to Python has made me a better programmer.

Categories: Uncategorized

I think this would be amazing

October 13, 2008 Leave a comment

I hate tags. They’ve been nothing but a nuisance to me, and they seem to be the crack cocaine of Web 2.0. Everything can be made better with tags! Tag your friends, tag your pets, tag your individual hairs.

My only practical run-in with them was over at Long Trance, where we fitfully began tagging posts. That shit petered out pretty quick because it was a huge pain to keep it all up. Responding to a post with three different tags, but only two really applied to your response? What do you do?

So the answer became “Screw the tags and just make the post.”

Okay, now for a completely different field of background. I hate iTunes. Not only because of its piss-off DRM (I only buy CDs and Amazon MP3s, Dr. Horrible and his soundtrack be damned) but because I hate the way that it handles my library. Now, let’s be clear: this is true with everything else that essentially offers a few metadata criteria to use to filter songs: the Zune desktop software and Songbird all do this, and I hate it. I’ve tried to live with it, but it just doesn’t work for me.

Let’s say you have an album by Airbourne: one band, one album, no problems. Either select the band name or the album name and off you go. But what if you have, say, the Matrix Revolutions Soundtrack? Either all of the songs’ metadata say they belong to their respective artists, or they all say the equally useless “Various Artists”. And to make it worse, their metadata splits them among two volumes, even though most of the time you’ll want to listen to both.

Or, the most hellish of examples: a mix-tape (on a CD, natch) given to you by a friend. It has no real album name, and each of the artists is (and should be) credited separately, in case one piques the your interest (kind of the point of the mix-tape). There’s no way to retain full information resolution and have the “tape” be usable.

So I usually end up just changing the artist to be the friend’s name.

Now, more background: I’ve used Winamp forever because of the granularity of control it gives me. I can say “Play this song and then this song and then that song and then just shuffle through the rest of the list.” I love that. Of course, none of the do-all-the-work-for-you players like iTunes let me do that stuff. And the way that I choose which songs to play is by using Windows explorer to find the proper folder and then just drag the folder into Winamp to start the playing.

Ostensibly, the file hierarchy goes something like “My Documents/My Music/$artistname/$albumname/$songfile.mp3” so that, for example, we have “My Music/Airbourne/Runnin’ Wild/Too Much, Too Young, Too Fast.mp3”. But on the edge cases mentioned above, I realized, I’m using $artistname as tag. I put mix tapes in a folder with the name of the tape-giver, but preserve the songs’ metadata so that I know which song is by whom.

And now, the grand culmination: let’s get rid of three-column layouts seen in, for example, the Zune software with artists in the left panel, albums in the middle, and songs in the right. Selecting an artist makes the album pane only show albums by that artist and so forth.

Use ID3 tags in the Web 2.0 sense: just put whatever tags you want on a song. Want to play all the songs tagged with “Rage Against the Machine” (presumably all songs authored by them)? Just double click that tag in the tag browser. But want to handle a corner case like having 4GB of game music from various games where you really don’t care which game/developer/artist composed the individual pieces? Just hit the “Game Music” tag and away you go. Then decide you only want to hear Frank Klepacki’s video game music? Double mouse that “Klepacki” tag and you’re done. The key here being that some of the songs tagged with “Game Music” also have the “Klepacki” tag. The key is having multiple tags.

Include the granularity of control of Winamp and I think I might just have the best media player ever. Now just port it to the Zune and I’ll be the happiest kid alive. Hell, implement it on a flash-based PMP with decent storage and a good interface and I’ll buy a new one just for that. Seriously.

And if it’ll make it happen, you can even implement those silly-assed tag clouds so that the Web 2.0ers will feel like they can… well, do whatever it is they want with those things.

Categories: Uncategorized