C Programming Tools Lectures: May/June 2017
d.white@imperial.ac.ukIn late May - early June 2017, my colleague Evangelos Ververas and I gave four 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. This year I gave 3 of the 4 lectures, while Evangelos gave the second lecture. These 4 lectures were counted as part of the course CO120.3: Programming III.
July Update: I've just received the SOLE (Undergraduate Survey) feedback on this course, and I thought you might like to see one comment I received from one (anonymous) satisfied customer: The C tools lectures are excellent: extremely well organised, interesting and useful. We're very lucky in DoC to have people like Duncan, who is both extremely helpful and knowledgeable.
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 Professional Software Development webpages, please find it here.
This year's brief for the lectures is given by the following syllabus, as each lecture is ready, we'll add a link here to the lecture materials (slides and examples tarball):
Lecture 1: Thursday 25th May 2017, noon-1pm, room 308
- Intro: Pragmatic programming, toolbox approach.
- Editing: A quick review of what to expect from a decent programming environment, 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. Mention alternatives like CMake for larger projects.
- Multi-directory C projects, Makefiles and libraries, covering the include path, lib dir path, -lLIB syntax, one Makefile per directory.
- First Lecture Materials Here
Lecture 2: 1st June 2017, noon-1pm, room 308
My colleague Evangelos Ververas gave the second of these lectures, covering:
- Debugging: description and basic use of gdb.
- Memory leak detection: application of Valgrind to a leaky hash table example.
- Profiling: noone understands even their own code's runtime behaviour. Work through profiling example using gprof.
- Automatic Testing: Highlighting the importance of testing and describing the concepts of unit tests and TDD. 'make test'.
- Second Lecture Materials Here
Lecture 3: 8th June 2017, noon-1pm, room 308
- 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. 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: 15th June 2017, noon-1pm, room 308
- 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).
- A series of worked examples starting with a calculator, ending up with a Tiny Haskell Subset.
- Code generator spits out C, so without noticing it we end up writing a compiler that translates the Tiny Haskell Subset to C.
- Better yet, we only write 16% of the code and our tools write the rest.
- 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.
- Fourth Lecture Materials Here
d.white@imperial.ac.uk
Updated: 15th June 2017Back to my Personal Pages. ![]()
![]()