Modern C on Sea
If you are a seasoned C++ programmer you might think about C as a prehistoric language stuck in the times of K&R. But have you ever heard about compound literals and about how they can be used to enable default function arguments in C? Or have you ever used flexible array members to simplify dynamic data structures creation? What about anonymous
unions, designated initialisers or
static array arguments? Never heard of those? C is a living language that has much to offer to those who care about performance, who program close to hardware or whose daily routine involves interfacing C++ with C code. If you are such a person, or you are just curious and would like to learn about the older, little brother of C++, this is a workshop for you. We will (re-)discover the perks and perils of modern C. Step by step, we’ll see how leveraging the latest language features helps readability, improves safety and leads to better runtime performance. Who knows, maybe you’ll find writing C enjoyable (again)?
Have a laptop with a recent C-standard compliant toolchain (gcc or clang-llvm) at hand. You’ll need it for exercises.
- Quiz (yes we start with an interactive quiz): test your C knowledge. (15 mins)
- Arrays: VLA’s and flexible array members, why, why not, and how. (20 mins)
structand array initialisers. (15 mins) (short break)
- Compound literals: (30 mins)
- Anonymous values — what are they?
- Applications: pointers, object initialisation, function arguments.
- Activity: transform the code (using compound literals and flexible array members and designated initialisers). (15 mins) (short break)
- Quiz: what do you know about keywords? (10 mins)
- The big five++ keyword differences between C and C++:
restrict. (20 mins)
structs. (10 mins)
- Activity: transform the code (using safer pointer arguments with
bool, compound literals). (15 mins) (optional break)
- Exit quiz: what you’ve learned. (15 mins)
All times are approximate.
Dawid is a computer engineer with a heart for teaching. He's been programming for over 20 years evolving through Basic, Turbo Pascal and many other languages to finally find his home in the land of C++ (with occasional visits to C and Python). He teaches at Saxion University of Applied Sciences in the Netherlands, where he tries to convert new generations of programmers to use modern C++. Besides teaching, he uses C++ in the research on probabilistic state estimation for industrial applications. His interests focus on the design and evolution of programming languages and paradigms. In his free time he explores the evolving landscape of online teaching pedagogy or reads books.