“Teaching C” is really nice write up on what to teach in a C class. It has been a while since I was a student in University but there are some important points that I would have loved to know at that time. I think C is a much better language that people usually says, but the shortcomings make it have really bad publicity. If teachers can do a good job when teaching newcomers maybe we would not be creating software with such a poor performance and quality, and accepting it as a normal thing.
Teaching undefined behavior using sanitizers is a piece of cake: the tool gives students exactly the feedback that they need.
Agree, but more important is to teach WHY undefined behaviour exist in the first place.
Detecting errors and doing something about them is a really important part of programming that we typically don’t teach much about in school.
Yes, is a really important part of real world software development that gets ignored by the bast majority of people.
I’ve always taught C as a side effect of teaching operating systems, embedded systems, or something along those lines. In a course where the primary goal is C we have more freedom, and could look at more domains. Image processing and cryptographic algorithms would be really fun, for example, and even the old standby, data structures, can be used to good effect in class.
C and C++ was the primary language that I used in the University, together with Java. And I can say that C was a really great way to learn data structures and how things really work. I honestly think that some things could have been explained much better, but that’s not the language’s fault.
I’m really happy that C is in my toolchain and even more that it was one of the first languages that I learned.
I’m also leaving out build systems and version control. They should use these.
If some teacher is reading this, please, make build systems the biggest priority. Maybe it was just me and my colleagues, but the hardest part of being a computer science student is dealing with the tooling. Installing compilers, toolchains, dealing with different network setups, seeing how things work in my computer and not in the one where the test happens, etc. Is really frustrating. Makes the student spend time in things that are not relevant, honestly, writing the code and solving the exercises is the easiest part compared with installing stuff and make everything work toghether.
Tools have improved, but still, think that people doesn’t decrypt immediately the errors of a compiler in it’s first month or even year. So make build systems and tooling a core part of what you teach, help them, because if starting to solve problems is easier, solving the actual problems is more fun.
In some courses I will give students access to the test infrastructure that will be used to grade their code.
This is really useful. For the student because it removes the doubt about understanding the problem and also because is a good way of learning good approaches to developing using tests and specs.
“C is mostly taught very badly, and a student who aims at becoming good at maintaining C code will need to unlearn much that they have (typically) been told in class.” This is regrettably true
One might argue that we shouldn’t be teaching C any longer, and I would certainly agree that C is probably a poor first or second language.
As I said I’m really happy to have learned it as my first language. Looking at what could replace learning C as a first language I immediately look at Swift or Rust.
And I’m not sure if it would be better. What I liked about learning C and Java was that in Java we could focus on more high level algorithmic topics and “”best”” practices using OOP while learning what the hell is happening under the hood and understanding and enjoying low level programming with C.
Obviously, if this could have been learn with a single language maybe it would have been better, this is where Rust or Swift can play an important role. What I’m not that sure is if learning the abstractions that Swift and Rust present before what is really going on would have been counterproductive in the long term.