Why I believe that Python should be taught over C as a first programming language in universities.

It is (or maybe was) a worldwide trend for universities and colleges around the globe to introduce students to the C programming language as their first programming language. While some schools have now changed to Java instead, some are still teaching C as the first language one gets exposed to.

While there is nothing wrong with C (disclaimer: I love C, and I also consider it a must for software developers to learn, whether working high or low level), I firmly believe that is not suited to be used for such roles. C, being a medium level programming language, is somehow high level (this of course, is relative to comparison) while still managing to stay relatively close to the metal. C of course, derives much of its power from this single fact. Hardware interaction, while not useful to every single programmer, is still very useful for some tasks. One task I can think of, due to my work, is computer infrastructure projects. Compilers, Virtual Machines, and more, all can benefit from being close to the metal, and have a direct interaction with the computer’s hardware. I am sure this is all there is to it, but the aforementioned examples, can serve to demonstrate the need for low level interactivity.

However, tradeoff for this power is the fact that low level facilities get in your way when you program in C. Pointers quickly come to mind. No matter how powerful pointers are, most people are unable to effectively use them. This can be seen in most high level languages today, where pointers are pretty much extinct. Not only this, but to properly understand C, you need to have, at least some, knowledge of computer architecture. While you still can use C, regardless of the prevalence of such knowledge, it’s not uncommon to see students learn that a C x86 integer is 4 bytes, but not being able to answer why it is so if asked. Not to mention that the way student’s are taught C, by not telling them about the C standard library, they are getting reduced to exercises about array manipulation that get repetitive and tedious over a short amount of time, and don’t really add much to the student’s knowledge. The end result is that students feel incapable of delivering anything more than something trivial. Not to mention that there are schools (at least here in Greece) that teach C programming in Windows.

On the other hand, higher level languages today, such as javascript and python, at least in my opinion are more suited to serve as a language in an introductory course. That is because these languages are high level enough to abstract the underlying architecture in such a way, so that programming concepts can be demonstrated without the need to have knowledge of the underlying architecture. This way, algorithms, data structures, and more can be taught, without having the language’s idioms get in the way. What’s more, is that these languages are known to have an easier learning curve, and last but not least, they integrate a great standard library, that student’s can use to deliver something useful, and see real world applications development faster than in C. What’s not to love?

While I personally believe that a serious programmer should know at least one of the so called medium level languages (C, C++), even if they learn to one only to understand more about the way the machine works, I firmly believe that such languages should not be used in introductory courses in computer science.

So how do you feel about that? Do you think that C should be taught at introductory courses in computer science? Or do you feel (like me) that other languages are better suited, and why?

Advertisements

5 thoughts on “Why I believe that Python should be taught over C as a first programming language in universities.

  1. This depends largely on whether the course is programming or computer science. If programming, learning the theory behind programming is more important than understanding what’s going on “under the hood” at first, but it would be the other way around for a CS student.

    As you say, there is definitely also a danger of less-educated programmers becoming bad programmers if they don’t sooner or later come to understand the lower-level system workings – because the programming environment needs to be understood as a physical process where everything has a cost (time, heat, space) and not a limitless abstract space.

    • I agree with what you said, but there is also one thing I have to note: As things currently are today, with virtual machines providing all sorts of comforts to programmers (memory allocation, security, etc) one could have a career without really knowing what’s going under the hood.

      But in my opinion, I agree with you that one *has* to know what’s going on under the hood. Remember that a programmer’s job is to know what’s going on with the computer.

  2. I definitely agree with Python being a go to language for an introductory course however I am not sure it should be an introductory for computer science. I myself learnt C/C++ to begin with and would not change that for the world. I think the difficulty and theory that I learnt was invaluable and now whenever I approach a new programming language I always feel (With a few exception) that it is an easier language. In a rough way I think C could also differentiate the people who will excel at coding but of course put off some people, it is a hard thing to balance.
    At my university Electrical Engineering students have to do a Python introductory course. Recently they have been forced to do an OS and Networking course using C which I think is a little unfair (A systems C course might be more appropriate). I think in this situation the theory isn’t as important e.g. imagine learning principles to write an excel script?

    • Hello Brendon. My point is this exactly: While C (and C++, to a greater extent) are languages that are going to get the better of most programmers, so that they act to an extent as skill demonstrators for the best ones out there (those that master them), it’s still a language that is not suited to be used for a first introduction to programming, or to algorithmic classes, due to the language idioms that tend to get in the way.

      • Yeah, I see your point. Thinking more about it now, I realise when my friends tell me they want to learn how to program I always suggest Python. I just worry when they hit memory management but as the other commenter noted with languages like Python, Java, .NET Languages, web languages, etc. it is possible to not even need to learn some of the more technical aspects.
        I am definitely glad I didn’t learn algorithms or data structures in C/C++. I can just imagine me creating some massive memory leaks.
        Nice article by the way!

/comment

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