2024-05-14 00:00
I put the deepcode Stack Machine to work teaching C to others.
Teaching
Some colleagues in my current company at the time of this writing wanted a practical introduction to C programming. I held a week-long class (half-days each day) attempting to teach enough C to bootstrap everyone's further self-study of the language.
The deepcode Stack Machine (DSM) touches on what I consider to be the most important fundamentals of C, at least in this case--my colleagues were all fluent in at least Python. These fundamentals are wrangling binary and hexadecimal numbers, dealing with pointers, the stack and heap, and manual memory management.
So, I worked backwards from a reference DSM implementation I created and prepared teaching material for fundamental concepts required to have a rough idea of how to implement the DSM. This is the C Primer I put together, extended in places where I found gaps. I have since reflected the extensions back into the C Primer. Because we only had 5 half-days, we had a total class time of 20 hours. Things were fast-paced to say the least. I wanted to focus mostly on implementation, so I tried to work through the entire section of theory in just one day (4 hours). I needed to use another hour the following day, but the bulk of the rest of the class time was spent coding. I did present additional things from time to time, often screen-sharing and doing some live coding or interactive diagramming on digital whiteboards.
Overall I had a great time, and people shared that they thought the class was useful and enjoyed the project. We found bugs in my material, and I corrected some but turned others into questions for future learners, interesting things to think about. At the end of the class, I found an interesting commit to Karpathy's "llm.c" project. (My colleagues were all ML engineers in this case.) I shared the commit with the class and found examples of many points that we covered in class and implemented in the project and was happy to share that all of these students now had fundamental "readability" in C in the wild.
Were I to run this kind of course again in the future, I would add more tips for the implementation up front if I had only 20 hours, enough to allow participants to focus on exercising their C skills without grappling too much with tangential concepts such as how parsers work. Most participants made it through the VM implementation but did not have time for the other parts.
There were between 5 to 8 participants on any given day.
The deck I prepared and taught from is available here.