5 ms·
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 t
by wcarey 7y ago
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.
- imglorp 7y agoCurious 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.
- wcarey 7y agoIt'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.
- rramadass 7y agoNeat! 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.
- wcarey 7y agoC++ is the language with which I’m most comfortable, having used it professionally for the better part of a decade. I’ve gone back and forth on using it in HS. It’s abstractions are so opaque if you don’t already have a well developed model of programming. For the arduino, I’m really interested in teaching control systems. So we will start with finite state machines and go from there to implementing PID controllers. I’m intrigued by the idea of avoiding the IDE, so will totally pick up that book!
- DougGwyn 7y agoEverybody seems to draw pictures of the raw memory (word-oriented) data.
- wcarey 7y agoI'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.
- jayp1418 7y agoHave you given ada language a thought ? Also there are lot of competition your students can take part in https://www.makewithada.org/ https://www.makewithada.org/
- wcarey 7y agoI haven’t - is there a good tool chain you’d recommend me checking out? What’s the enduring idea in ada?
- pascal_cuoq 7y agoThis 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/ 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 7y agoThanks! 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 7y agoI 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.