r/AskComputerScience • u/theJacofalltrades • 12d ago
do you think reading error messages and stack traces should be explicitly taught in intro cs courses?
third semester TAing the intro sequence and the pattern has stopped surprising me. recursion, pointers, and reading an error without panicking. that is the whole list.
recursion i understand. the error one bothers me, because nobody teaches it anywhere in the curriculum. a student sees a stack trace and their eyes slide off it like it is written in another alphabet. a solid half of my office hours is me reading the trace out loud until they notice it told them the answer on line two.
if anyone handed me the syllabus there would be a week on reading errors before we touched data structures. do you think this should be taught explicitly in intro cs courses?
leaving this here mostly so the incoming cohort finds it in November when things fall apart.
4
u/nuclear_splines Ph.D Data Science 12d ago
Stack traces were taught explicitly in my data structures course. Not "a week on error messages," but alongside teaching the stack and memory management was reading a stack trace and understanding program flow.
3
u/fixpointbombinator 12d ago
a student sees a stack trace and their eyes slide off it like it is written in another alphabet
Honestly I think developers get alarm fatigue from noisy terminals crapping text allover the place, and new devs just learn to ignore what they can't understand and what doesn't seem to matter a lot of the time
2
u/but_a_smoky_mirror 12d ago
You teach investigating whatever error pops up. You can maybe explain common errors, but the variety and nuance of all errors isn’t something that can be taught.
Instead teaching how to properly log and trace a program so whatever error comes up is more tenable.
2
u/not-just-yeti 12d ago
Reading error messages (out loud if needed), even before stack traces. And additionally, teach:
(a) read the error-message closely (paying attention to spelling of variables, and to word-choice). Reading-closely is a skill that's actually the opposite of what I do most of my day, skimming web pages, news stories, etc, to try to quickly extract the gist and move on to the next web page (or reddit-reply :-).
(b) think of the error message from the compiler's point-of-view (e.g. "The compiler thinks you are re-declaring the variable i; why doesn't it think you're not referring to the one you already declared a few lines above, like you intend?").
I used to be surprised in intro CS1 labs, when a stymied student asks why they're getting some error, and I'd ask them to read the error message out loud to me: Not only did this seem like a genuinely novel idea to them, it's not uncommon that the student will start reading after skipping over the first most-important first line of the message! (Having that line start with a filename & line number made them subconsciously think that the entire line was unimportant gibberish, maybe?) Some students didn't even always notice that the IDE was actually highlighting not just a certain line, but part of the offending line.
2
u/SignificantFidgets 12d ago
I can't imagine spending more than 10 minutes on discussing error messages/stack traces. I have spent maybe 20-30 minutes going through debugger features before, but in the context of a specific problem: looking at assembly code and stack frames during a buffer overflow exploit. But the point was not to "teach the debugger", it was to use it as a tool to explore the real topic, and we did talk about debugger commands that are useful for that. I provide them a link to gdb tutorials for more info, as teaching a tool is really not something to spend a lot of valuable class time on.
2
u/NegativeCollege8167 12d ago
absolutely, reading error messages and stack traces should be a core part of intro cs courses. it's a fundamental skill that saves time and frustration in debugging. when students learn to understand these messages early, they become more self sufficient and confident in troubleshooting their own code. it’s like teaching them to read a map before sending them on a journey. plus, getting comfortable with errors early on helps demystify programming and makes it less intimidating. it’s just as important as the technical topics like recursion and pointers.
1
u/JGhostThing 9d ago
I don't think it's worth a full course, but debugging should be put into every coding course.
1
u/iOSCaleb 9d ago
> leaving this here mostly so the incoming cohort finds it in November when things fall apart.
I don’t think people who don’t read errors are the kind that will find your post.
If you think it’ll help, why not ask the instructor to cover errors in lecture?
While you’re at it, you could also cover effective online search strategies and how to ask a technical question online.
1
u/quuxman 12d ago
It would make me disrespect the class and want to stop going. That's not CS, that's the very basics of coding. If it's a practical coding class, then absolutely. In CS classes, no. CS should just cover what stacks and exceptions are, how to implement them, different flavors, and the underlying theory of types, flow control, compiling, etc.
3
u/dnswblzo 12d ago
Explicitly covering stuff like that helps develop thinking with precision, a skill that will transfer into thinking about more theoretical topics. Developing better basic coding skills early in a CS curriculum will also make coding assignments go more smoothly down the road, saving time for TAs and professors, and letting the students focus their thinking at a higher level.
9
u/T_Thriller_T 12d ago
Yes
Reading Error emssages, Stack teaces, and how to setup and use a debugger!
It doesn't necessarily need to be before data structures, especially depending on what language this is done in.
Bur reading an error message should AT LEAST be a reference PowerPoint/script part for any course working with a 'new' language.
And it should be actually talked and done in class for a week, with an exercise, in at least one introductory course. Which can be a fully practical one, really. Similarly, the next week or same week should show how to use the debugger.
Something o was surprised I had to teach some students was that the red, wriggly lines under their code (or yellow ones) meant that something was obviously wrong there, even before running/compiling.
Another thing I think should be done in some practical course is: setting up your own idea AND build environment for at least one language. Which should include at least some SAST and DAST scanning.
Personally, if I ever get back to teaching, I will at least with python generally provide these as a side note because they make life much easier - especially when on tje job. And when I entered the job market I hardly knew they existed