C Programming Tools Lectures: May/June 2021
d.white@imperial.ac.ukI have now started giving my 5 first year lectures on C Programming Tools, building a toolbox of useful tools, and the craft skills to use them effectively, in order to make C programming easier.
Once again this year, thanks to COVID-19, I'll be recording these lectures (slides+audio+working in a terminal) at home via a Linux screencasting application called "Kazam", editing the results with a Linux video editing suite called "OpenShot", and then uploading the results to Panopto. New this year: I'm splitting each lecture into several (eg 3 or 4) separate videos, to make them easier to watch in bits.
In addition, to try to recapture some of the spontaneous interaction, Will Knottenbelt, Konstantinos Gkoutzis and I will be doing joint Q+A sessions (via Teams) with as many first year students that wish to take part, from 10am-11am BST (ie. UK time) on Mondays, Thursdays and Fridays starting 17th May for 3 weeks. You can ask C-related questions you have on all of Will's lectures released at that point, and similarly any C-tools related questions on my released lectures too.
In the lectures, I strongly recommend The Pragmatic Programmer by Hunt & Thomas. The woodworking metaphor and many inspirational tips comes from there. A few years ago, I wrote a review of this book in my Practical Software Development webpages, please find it here.
This year's syllabus for the C Programming Tools lectures is shown below. As each lecture is ready, we'll add a link here to the lecture materials (slides, examples tarball, and Panopto recording) :
Lecture 1: released online Wed Tues 18th May 2021
- Intro: Pragmatic programming, toolbox approach.
- Editing: A quick review of what to expect from a decent programming editor, especially extendability, choose one and specialise.
- Compiling: Description of Make and work through an example in detail. Give tips on how you can build your own simple makefiles even for small projects.
- Multi-directory C projects, Makefiles and libraries, covering the include path, lib dir path, -lLIB syntax, one Makefile per directory.
- Conclude by giving an example of CMake, a similar tool than some prefer for larger projects, and introduce my own make-replacement tool CBuild.
- First Lecture Materials Here
Lecture 2: released online Wed 19th May 2021
- Debugging: description and basic use of gdb.
- Memory leak detection: application of Valgrind to a buggy hash table example.
- Profiling: noone understands even their own code's runtime behaviour. Work through profiling example using gprof profiling.
- Automatic Testing: Highlighting the importance of testing and describing the concepts of unit tests and TDD. 'make test'.
- Second Lecture Materials Here
Lecture 3: released online Mon May 24th 2021
- Building your own tools - aka, what to do if the tool you want doesn't exist: consider building it yourself, to save time over the long term. Core principle: Spot patterns, bore easily, automate, save time!
- Build tools at a range of scales:
- Tiny: Build shortlived tools (eg Perl one liners or awk/sed/grep pipelines, or their C equivalents), short throwaway programs that you write in minutes, use for minutes and then discard. Examples: generating repetitive output from simpler input forms.
- Medium: Generating C prototypes automatically: a tool called proto that I wrote a long time ago to solve a problem that irritated me.
- Build/gather a collection of reusable ADT modules (hashes, sets, lists, trees etc), well tested, general purpose, that you know well.
- Building Large tools: Why not generate ADT modules automatically from Haskell style "inductive data declarations": my tool called datadec, and wider lessons: do you think "make" is amazing? it only exists because someone sat down and wrote it. You can do something like that too!
- Third Lecture Materials Here
Lecture 4: released online Fri 28th May 2021
- Building little languages easily by using parser generator and lexer generator tools (eg. the combination of Yacc/Bison, Lex/Flex, and datadec for Abstract Syntax Trees).
- Presents a series of worked examples around integer expressions with named constants, to introduce Lex and then Lex+Yacc+Datadec.
- Fourth Lecture Materials Here
Lecture 5: released online Thurs 3rd June 2021
- Continuing the Lex and Yacc theme, scaling the example language up to a tiny Haskell Subset in a series of step by step examples. We end up writing a Code generator which spits out C syntax, so without noticing it we end up writing a (tiny subset of) Haskell to C compiler, of which we write a very manageable ~15% of the code and the tools write the rest.
- Thoughts on an alternative parsing technique.
- Conclusions: use tools as much as you can. choose ones you like; become expert in their use. build a toolkit of trusted tools. Build your own tools where necessary. Define your own little languages, use parser generator tools to help.
- Final Lecture Materials Here
d.white@imperial.ac.uk
Updated: June 2021Back to my Personal Pages. ![]()
![]()