3 ms·
Having taught C at University, I found the hardest bit being how many "well, but..."s to give. C feels like a very simple language, but there are lots of subtl
by CJefferson 4y ago
Having taught C at University, I found the hardest bit being how many "well, but..."s to give.
C feels like a very simple language, but there are lots of subtle corners which probably don't need teaching at first.
On the other hand, I think it's important to hammer home "undefined behaviour" early. There are too many guides that say writing outside the bounds of an array "writes to memory outside the array", which simply isn't true. It might write, it might not, who knows, undefined behaviour means all bets are off.
In general I feel a lot of practical teaching of C is teaching about undefined behaviour, which is something many other languages (Java, Python, Haskell, Rust), either don't have, or where they do beginners won't stumble across it.
- Doxin 4y agoA good tactic may be to teach D instead. It's rather close to C (especially with the -betterC flag which disables among other things the garbage collector) but fixes some of the more egregious flaws. No spiral rule. Proper modules. No preprocessor (but CTFE and mixins instead). It stays close enough to C that undefined behavior exists but far enough away to avoid nasal demons.