Lurker News
Hi HN,

We are members of the C Standard Committee and associated C experts, who have collaborated on a new book called Effective C, which was discussed recently here: https://news.ycombinator.com/item?id=22716068. After that thread, dang invited me to do an AMA and I invited my colleagues so we upgraded it to an AUA. Ask us about C programming, the C Standard or C standardization, undefined Behavior, and anything C-related!
The book is still forthcoming, but it's available for pre-order and early access from No Starch Press: https://nostarch.com/Effective_C.
Here's who we are:
rseacord - Robert C. Seacord is a Technical Director at NCC Group, and author of the new book by No Starch Press “Effective C: An Introduction to Professional C Programming” and C Standards Committee (WG14) Expert.
AaronBallman - Aaron Ballman is a compiler frontend engineer for GrammaTech, Inc. and works primarily on the static analysis tool, CodeSonar. He is also a frontend maintainer for Clang, a popular open source compiler for C, C++, and other languages. Aaron is an expert for the JTC1/SC22/WG14 C programming language and JTC1/SC22/WG21 C++ programming language standards committees and is a chapter author for Effective C.
msebor - Martin Sebor is Principal Engineer at Red Hat and expert for the JTC1/SC22/WG14 C programming language and JTC1/SC22/WG21 C++ programming language standards committees and the official Technical Reviewer for Effective C.
DougGwyn - Douglas Gwyn is Emeritus at US Army Research Laboratory and Member Emeritus for the JTC1/SC22/WG14 C programming language and a major contributor to Effective C.
pascal_cuoq - Pascal Cuoq is the Chief Scientist at TrustInSoft and co-inventor of the Frama-C technology. Pascal was a reviewer for Effective C and author of a foreword part.
NickDunn - Nick Dunn is a Principal Security Consultant at NCC Group, ethical hacker, software security tester, code reviewer, and major contributor to Effective C.
Fire away with your questions and comments about C!

Comments (962) 182 threads

Show all comments

Showing thread 76 of 182

wcarey5 replies#
I'm teaching C to high schoolers as their first language, which is quite the adventure. Do you have any good advice or resources on how to introduce the way C treats the function stack and heap allocated memory? Most of my students struggle (naturally) with making sense of function scoped identifiers and pass-by-value semantics.
imglorp1 reply#
Curious what were the requirements to select C as a first high school language over many other choices? I imagine there's a balance of practicality (after the class), and then the usual questions about tooling, sharp edges, and ease of learning.
wcarey1 reply#
It's a three year rotation: Python, C (Unix), C (Arduino). My goal with the class is to teach ideas that will stand the test of time. C (and Unix) certainly fit that bill.

Happily, the tooling is the easiest part. Every student has a rasberry-pi running debian, no mouse, no window server, and no extraneous software. You can spool kids up on a nano-based C toolchain in one class period with remarkably few sharp edges. There's even some fun accidental learning the first time they nano their executable file.

rramadass1 reply#
Neat! I think your choice of C and Python as the languages to be taught is very right. The idea of showing the use of C in both Desktop/Server and Embedded environments has long been the approach i had advocated. C is truly the de-facto "universal" language and students should be made aware of it from the start.

I would suggest the following additions;
* The Arduino "language" is C++. Use this as a gentle introduction to C++ as a "better C". From there you can move on to proper C++ (do NOT teach "Modern C++" in the beginning). The intent is to show how "C + some syntactic sugar for expressing abstractions" is quite powerful and that is what is C++. This should prepare the students to embark on a proper study of C++.
* Instead of using the Arduino "language+library" through the IDE, show them how to use the same GNU gcc toolchain to program the MCU directly in C. See Make: AVR programming by Elliot Williams for details. This teaches the students the idea of a "cross compiler toolchain" and all other related matters from first principles.

Continue this thread — 1 reply

DougGwyn1 reply#
Everybody seems to draw pictures of the raw memory (word-oriented) data.
wcarey1 reply#
I've been doing the same! It certainly helps for strings. Pointer block diagrams (like K&R use) seem to help too. Mostly what melts their brains is the idea that an identifier can be "in two places at once" - for example, you can have a variable x declared in some scope and a function one of whose arguments is named x, and those are two different things.
DougGwyn1 reply#
Try explaining the concept of "scope", starting with nested blocks. It does require some practice. I suggest not unnecessarily reusing identifiers associated with different objects.
wcarey#
Thanks!
jayp14181 reply#
Have you given ada language a thought ? Also there are lot of competition your students can take part in https://www.makewithada.org/
wcarey2 replies#
I haven’t - is there a good tool chain you’d recommend me checking out? What’s the enduring idea in ada?
pascal_cuoq1 reply#
This service has been designed to try out small self-contained C examples online (in a manner reminiscent of Compiler Explorer):

https://taas.trust-in-soft.com/tsnippet/
One advantage is that it identifies a LOT of undefined behaviors during execution for which traditional compilation and execution only give puzzling results.
One drawback is that some of the undefined behaviors it identifies are obscure, and for others the message may be unusual. For instance, using a standard function without including the appropriate header may result in a warning about the mismatch between the type in the header and the type of the arguments the standard function was applied to after arguments promotions.
Overall, you may still find it useful for teaching.

wcarey#
Thanks! Definitely an interesting tool. Two of my students are fascinated by the idea of undefined behavior right now (having run into it in practice; the idea that off-by-one errors sometimes crash their program and sometimes behave "normally" is really odd to them), so I'll point them at this to play with.
rramadass#
I suggest The C Companion by Allen Holub for getting an idea of "behind the scenes".

For a more modern look, i suggest Computer Systems: A Programmer's Perspective by Bryant and O'Halloran
Of course, you would need to pick and adapt the content for your students.