Programming Languages To Use In The Classroom; C vs. Python

Teaching programming concepts to new learners can come with many unique challenges, not the least of which is the choice of programming language. With many programming languages to choose from, how can you decide on what language is best for your students? There are a few criteria you can compare different languages with depending on the background of your students. For instance, math students might benefit from and have an easier time with languages like MATLAB which is used by people in that field of study. In this article we however focus on two popular languages; C and Python.

The C programming Language and Python

A picture of a C program which prints out "x is 5" if the variable x is 5.
An example of a C program.

The C programming language has been around for quite a while but is still used for many applications including operating systems. The University of Windsor currently uses C for teaching their Introduction to Algorithms & Programming I and II courses.

A picture of a Python which prints out "x is 5" if the variable x is 5.
The same program as above, but written in Python.

Python is a relatively newer language that is popular for its use in data science. It has libraries for almost everything which makes it useful for most purposes.

How do the two languages compare?

One of the first ways we may compare the two languages is how readable the code is. The C programming language undeniably has a lot of overhead compared to most languages. By this I mean, for the average program you will be writing more code in C than you would in another language to accomplish the same thing. Simple programs can quickly become complicated to read if care is not taken because of this. For more experienced programmers this may not be a big deal. If their code is structured in a logical way then others may be able to understand it without any problems. However for students who have not learned good programming practices yet, this may get in the way of their learning and make assessments in the course unnecessarily frustrating. On the contrary, Python is often praised for being able to do more with less. It is often the case that long programs in other languages can be rewritten in Python in much fewer lines. This makes the program much more readable which is helpful for new programmers. Although this seems like a definite plus for Python over C, one could also argue that using C teaches students the importance of good programming practices like commenting and proper indentation.

The C programming language uses many conventions that are common among most languages. Including variable typing (the need to specify a variables type), terminating statements with semi-colons, and code blocks are specified by surrounding them with curly braces. Many of these syntax requirements are relaxed in Python; for instance, in Python, you are not required to specify a variable’s type like you are in C. This arguably makes Python the language that is easier to learn. However, learning to program in C I think can strengthen students logic and reasoning skills, and overall benefit a students ability to tackle different programming problems.

Lastly, because the syntax of C is so strict, learning other languages after becoming familiar with C becomes a lot easier. This is a luxury that Python may not be able to provide, instead it perhaps could be used as a stepping stone to learn other languages.

Leave a Reply