Home > Uncategorized > See, my philosophy is —

See, my philosophy is —

“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.”


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
  1. Greg Hunt
    November 5, 2008 at 11:03 pm

    Send that C program over to me and tell me where it was segfaulting and I’ll find the bug for you!

    I love both C and OO languages like Python and Java. They’re good for different things, however, and having all of them in your programming tool belt is a good idea.

    I understand your position about C. However, I do disagree. Learning C shows you how the computer is doing things under the covers. That ultimately makes you a better programmer in Python, for example, because when you create a new object you can understand how much work that is for the system.

    I have worked with a number of programmers who only knew Java, for example. They would happily write code that would create and destroy dozens of objects for simple tasks and then they’d wonder why their programs were running so poorly. They also had little idea how to track the problem down and solve it. If they had understood what they were asking the system to do, they’d have been able to design their algorithms and data structures to be more efficient, cleaner, and faster. That’s still a very important consideration, even in today’s world of gigahertz plus CPUs.

    C can teach you that level of understanding about what the inside of the computer is doing when you write programs. It’s valuable understanding for your chosen profession, in my opinion.

    Hope this makes some sense to you.

  2. Hober Short
    November 6, 2008 at 2:25 am

    Oh, I completely agree. It’s important to *know* C, because of the way it forces you think about how things work.

    I’m just saying that for me, personally, for getting stuff done, it seems a better use of my time to do it in Python.

    Perhaps it was just because I wasn’t able to really grok C the first time around (I’m sure there will be more) but this post was mostly borne out of the frustration and mentally taxing effort of trying to troubleshoot faulty programs in C.

    I still value it as a program language and I’m hanging on to my copy of K&R that I bought as the textbook for the class — the cheapest text I’ve bought for a class yet, and the only one I’m planning to keep. This is just a mental snapshot of the utter demoralizing effect that C had on me.

    I also know the type you speak of, who construct programs by rote instead of as a craft where you have to understand each component being brought to the mix. In a university where programming is just another subject to be learned and regurgitated, the attitude can come very naturally. And you can lead them to the refreshing waters of C, but you can’t make them drink in the fundamental enlightenment to be gained by using it.

    I’ll see if I can roll back my program to its error state and let you have a crack at it. I would genuinely be interested to understand what went wrong.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: