Learning to Program in C
I recently endeavored to get back to basics in coding and teach a simple course covering the very basics of C to students in my school. I realized quickly that given today's many different tools learning to code isn't like it was back when I was born in the 90's or compared with the date the K&R book was published.
Over the years, through the classes and coops I've had, the mentors I've met and kept (including my retired dad) I came to understand that while learning is supposed to take sweat and effort, it does not need to be necessarily confusing or frustrating. With every introduction book to C I find that they are still missing out on walking the user through some basic steps like making sure that GCC is installed, or how to test the code to allow you to quickly run the program through its paces. By focusing only on code they are missing out on teaching some necessary habits and skills.
When it comes to instruction I feel the best methods follow the format of:
- Introduction to abstract idea
- Example of how to use the abstract idea to solve a problem
- The opportunity for the learner to apply the new idea and example in a different context to see that they've understood the material
From there, a learner is able to develop if they've understood the material or if they need help. Learners excel at this process when they are in an active learning environment surrounded by peers and mentors. Instead of suffering through a long period where they have questions, but not the tools to resolve those questions they can talk to people about their current understanding and shape it back to what was meant to be taught.
A while back I wrote about my ideas on what a basic CS program should cover (link). Being that I hold strong opinions and am not afraid to share them freely so that they can be tested I would like to share a link to my basic course in C.
https://github.com/betsalel-williamson/C-Programming-Tutorial/wiki
My introduction to C is structured over two tutorials.
- The first tutorial covers installing the damned thing and making sure that you understand how to compile your first "Hello world" program in C along with using the scripting language TCl/Expect to test your "Hello world" program.
- The second tutorial runs through a kitchen sink style program that generates a pseudo-random code. The purpose of this program is to create a problem for the learner to solve. After learning more about how C works they are then set to crack the code generated by this program.
My initial time estimate to complete this tutorial, which was tested on a dozen students in the student chapter of IEEE at the University of Pittsburgh, was 2 hours. It was crunch to finish it all, so I edited it to focus more on C. I removed a section on version control because that topic is best taught over a longer period of time when it can be shown the specific advantages of having such a system. All told I think 2-4 hours is a better estimate on how long it takes to make it through the tutorial.
If you've been out of touch with C and gasp at the idea of pointers, or pointers to pointers, give it a shot. All of the code examples and answers are included and have been commented throughout.
Cheers and happy coding!
-Saul
Comments and Suggestions
Thanks for reading! Give a thumbs up, comment, and share this if you liked this article. Do you think coding tutorials need modernizing to cover best practices or do you have a favorite tutorial in C that you recently used?
Update 8/27/2019
Updated the link and made some edits to the instructions.