4 ms·
That doesn't square with my experience. I've taught beginning programmers more or less the "C subset" of C++, and it was a nightmare. The biggest problem is th
by pcwalton 9y ago
That doesn't square with my experience. I've taught beginning programmers more or less the "C subset" of C++, and it was a nightmare.
The biggest problem is that when they inevitably hit undefined behavior, there is no easy way to learn what is wrong. The program hits a segfault or prints garbage on the screen—where to begin? I instinctively know what is likely to be wrong, but that's only through years of experience; it's almost impossible to teach that quickly. Even if, by luck, the program segfaults instead of silently corrupting memory, the line number where the failure occurred doesn't necessarily correspond to what is wrong—often the problem occurred earlier.
Rust is in a much better position here, since the compiler can actually isolate precisely what is wrong in those cases and emit diagnostics at the exact location where the problem occurred. That's much easier to teach.
- naasking 9y agoLearning C via an interpreter that errors out on undefined behaviour seems like a good way to address those issues. Not sure if any of the interpreters I've seen over the years actually does this though, though I imagine altering something like PicoC would be straightforward enough.
- pcwalton 9y agoJudging by the development of UBSan and ASan, I think such a thing would be anything but straightforward, even with a simple C compiler.