Wanted: Advice from CS teachers
-
@futurebird @wakame The metaphor I use with line numbers in error messages is "I fell down on line 32. I don't know where I tripped, but this is where I fell."
It is a hint, and you can find it from there, but the cause could be before. Students understand that tripping and falling are distinct, causal actions, and that knowing what you tripped on may be unknowable until you go back and look.
This a brilliant 'trick' for understanding what actually may have happened.
-
So Your Code Won't Run
1. There *is* an error in your code. It's probably just a typo. You can find it by looking for it in a calm, systematic way.
2. The error will make sense. It's not random. The computer does not "just hate you"
3. Read the error message. The error message *tries* to help you, but it's just a computer so YOUR HUMAN INTELLIGENCE may be needed to find the real source of error.
4. Every programmer makes errors. Great programmers can find and fix them.
1/
"The error message *tries* to help you": the error message was written by people who had no interest in helping you
-
I do this with my older students and with those with more experience. This is the one course that I teach that EVERYONE must take. So there are kids there who have never programmed anything. Kids who were confused when I had them use a computer with a mouse since they'd never seen one in person before.
I'm glad we have such a course. But they just don't know enough to do this yet.
And I have an agenda: I want them to have fun.
@futurebird @Zwifi how are you currently teaching that debugging is a skill and part of what they're learning? Do they take notes on, or see presentations of, how bugs (including typos) were identified and fixed? Maybe even presenting to each other the problems they each got stuck on, or debugging as a class on occasion so they can see the process in real time while they're not currently panicking?
-
Wanted: Advice from CS teachers
When teaching a group of students new to coding I've noticed that my students who are normally very good about not calling out during class will shout "it's not working!" the moment their code hits an error and fails to run. They want me to fix it right away. This makes for too many interruptions since I'm easy to nerd snipe in this way.
I think I need to let them know that fixing errors that keep the code from running is literally what I'm trying to teach.
Argh, this sounds very familiar, I've been trying to teach *from the very start* that encountering errors is useful - they're opportunities to learn, and to think / design in successively more detailed levels of abstraction - working "outside in" - calling methods which don't exist yet to sketch out the general shape of a procedure, watching it fail, then defining them... (1/2)
-
Argh, this sounds very familiar, I've been trying to teach *from the very start* that encountering errors is useful - they're opportunities to learn, and to think / design in successively more detailed levels of abstraction - working "outside in" - calling methods which don't exist yet to sketch out the general shape of a procedure, watching it fail, then defining them... (1/2)
... This worked very well for a while, until I got a cohort who were already *deep* into LLMs who would encounter the errors, not wait for the rest of the class to catch up, paste the message into ChatGPT, and set out on confusing, frequently completely wrong paths that it was difficult to bring them back from
(2/2) -
So Your Code Won't Run
1. There *is* an error in your code. It's probably just a typo. You can find it by looking for it in a calm, systematic way.
2. The error will make sense. It's not random. The computer does not "just hate you"
3. Read the error message. The error message *tries* to help you, but it's just a computer so YOUR HUMAN INTELLIGENCE may be needed to find the real source of error.
4. Every programmer makes errors. Great programmers can find and fix them.
1/
@futurebird
I've been a professional software engineer for over a decade now. I still make errors.What's interesting is that at a certain level it's possible to write code that in isolation works exactly as you want it to, but it doesn't work in combination with the rest of the existing code.
But I also have tools to help me. My IDE checks for typos or syntax errors for me and flags them. It suggests solutions and offers to apply them. I have build tools written by other engineers to catch problems I might not have ever thought about.
No one person knows everything, but anyone can learn enough to be effective
-
Sometimes I have them write the code on paper with the computers closed. And this is fine, but I'd rather have them using the IDE or textedit and there is a limit to how much fun you can have with code on paper.
And it does tend to be the weaker students who are almost happy to find something to stop the onslaught of information "see it doesn't work! we can't go on!" and that obviously makes me very grouchy.
I need them to see this is like saying "Teacher my pencil broke! Stop the lesson!"
@futurebird I have done some classes, explicitly saying I had not prepared anything, completed the exercises improvising there and then, made some mistakes of my own and corrected them. Showing that correcting yourself is part of the game.
-
@futurebird Not a teacher, but that sounds great.
Learning what error messages are and what they can tell you is so important. It's so different to many other subjects where you don't get that kind of information when something goes wrong, plus they will have grown up using computers of various kinds where an error message really is just a cryptic string of words that they can't do anything with.
@phronetic @futurebird I can imagine a classroom where there's a running list of error messages encountered, and you get a sticker or bonus points or something for finding a new one, and explaining to the class what it means once you've figured it out. These days I can get an error message and approach it with "ooooohhhh never seen that before", but in my earlier years, hah!
-
Wanted: Advice from CS teachers
When teaching a group of students new to coding I've noticed that my students who are normally very good about not calling out during class will shout "it's not working!" the moment their code hits an error and fails to run. They want me to fix it right away. This makes for too many interruptions since I'm easy to nerd snipe in this way.
I think I need to let them know that fixing errors that keep the code from running is literally what I'm trying to teach.
@futurebird What a great set of discussions and thanks for being a teacher! (They pretty much make the world go round, imho.)
I'm not one, but have taught some people coding over the years. Most recently I've seen that LLMs compound the problem you describe, because when the student has posted hundreds of lines of code to answer some fairly standard coding assignment, they have jumped so far into the deep end, that it's very hard for them to get out. The pasted code does all sorts of things they don't yet know about. Hopefully not your situation. Hopefully a lesson in its own right, but getting this young person to slow down and *do it themselves* was non-trivial.
On a different tack, a project manager I knew once said energy project needs a project teddy bear. Any coding issues have to be explained to the bear first before getting senior help. The bear apparently solves 60%+ of the issues. Apocryphal, maybe.
-
@RogerBW @futurebird (some) C coders have a saying:
If the compiler emits an error, then your code can't run;
If the compiler emits a warning, then your code won't run, at least not the way you expect it to;
If the compiler emits no errors and no warnings, then it's high time you updated your compiler.
@aaribaud @futurebird When I moved from Perl to Rust as my primary language I was very pleased to find that whole classes of errors which had previously been runtime debugs turned into compile-time debugs. I am now an enthusiastic convert to strong typing.
-
I think they become anxious when their code isn't working the same as what I have up on the projector and they want to get it fixed RIGHT AWAY so they won't fall behind.
Then when one of them starts calling out they all do it.
I may take some time to explain this.
This never happens when I'm teaching math. Something about coding makes them forget some of their manners, and become less self-sufficient. "It's broke! I'm helpless!"
What is that about?
@futurebird when I bumped on that problem with my students, I made a lesson focused on:
* provoking error messages
* reading them, learning where in stacktraces is the info about them
* correcting the errorand categorizing them systematically: oh, NameError: this means I'm using a var that does not exist, maybe this is a typo here, or a typo there when I defined it.
It helped them not panic when seeing errors and gave them tools to fix common ones on their own.
-
Wanted: Advice from CS teachers
When teaching a group of students new to coding I've noticed that my students who are normally very good about not calling out during class will shout "it's not working!" the moment their code hits an error and fails to run. They want me to fix it right away. This makes for too many interruptions since I'm easy to nerd snipe in this way.
I think I need to let them know that fixing errors that keep the code from running is literally what I'm trying to teach.
@futurebird not a teacher, so take with a cup of salt, but maybe having them not coding during your speaking parts could help?
Like, locking their screens or all looking at you rather than typing at the machine.My guess is that anyone calling out like that got distracted with the coding and was not strictly paying attention to what was being said, so when they get the error, they may not see or hear anything aside from the error in front of them.
-
Wanted: Advice from CS teachers
When teaching a group of students new to coding I've noticed that my students who are normally very good about not calling out during class will shout "it's not working!" the moment their code hits an error and fails to run. They want me to fix it right away. This makes for too many interruptions since I'm easy to nerd snipe in this way.
I think I need to let them know that fixing errors that keep the code from running is literally what I'm trying to teach.
Present them or a piece of code and tell them this piece code has a problem with it and ask them to figure it out if you can find a fun thing all the better.
Have them perform a code review and look at code and say well figure out the failure modes of this piece of code.
I would actually have code refuse be part of your class.
-
@futurebird I'm also interested how to add LLMs to the mix: how to use them in a way we use IDEs now: we still know how to program/read code, but IDEs are so useful.
This will add another level to the me/them, where sometimes I'd want them to use LLMs, other times not.
But first I need to convince the school it's a good approach: I'm an external teacher, and as such have very little influence...
@ligasser @futurebird i'm interested, but very skeptical as well. Before the LLM craze, I was working through the CS50 Intro to CS class that Harvard offers online for free through OpenCourseWare. Even back then, they offered a rubber duck debugging program that you could type your questions to. And back then, I don't think it did anything except quack. But today, I would be curious what it does because I suspect they would try to use LLMs.
-
My students aren't lazy, but they *can* be a little perfectionist: scared to take risks or sit with not having the answer right away.
They are really upset when their code won't run... but staying calm and *systematically* looking for the cause of the problem, knowing that if you just work through the tree of possible causes you will find it is not something they are good at.
I think I need to teach this.
Maybe I will give them some broken code and we will find the errors together.
@futurebird
Teach The Ten Commandments of Egoless Programming. Especially "you are not your code" and "kindness to the coder, not the code"
Managed Coder: Advice to a New Programmer https://share.google/ahp9eb3GQvBOIfo8bTeach paired programming, giving everyone a coding/debugging buddy. This is one of the most effective ways to level set coding standards and skills. Students learn from each other. It also prepares them for more public code reviews.
-
@futurebird I know what you mean, and you're perfectly right when it comes to sane programming languages. However, C++ compilers have a habit of spewing out error messages the size of a Tolstoy novel in response to mistakes as trivial as a missing comma. Now I assume you're not teaching the kids C++ as that would be quite irresponsible.
@mansr @futurebird my highschool programming class was C++ based, but it was a joke. It was paint by numbers and we didn't learn programming.
The main thing I learned in that class was that Gmail existed and my classmates sent me an invitation to use it. Because he was checking his email during class time.
-
@AbramKedge @futurebird I do this (in the context of a different academic subject) with "bad" essays, where we work collaboratively to find errors and redraft improvements. Hope it's effective for you.
@MintSpies @AbramKedge @futurebird when I was taking cartography classes our teacher would put up student work on the board but with the names removed and we would discuss it together. We didn't know if it was folks in our class or previous years and it was really helpful especially when you saw your own work up there and other people were kindly pointing out their suggestions.
-
Wanted: Advice from CS teachers
When teaching a group of students new to coding I've noticed that my students who are normally very good about not calling out during class will shout "it's not working!" the moment their code hits an error and fails to run. They want me to fix it right away. This makes for too many interruptions since I'm easy to nerd snipe in this way.
I think I need to let them know that fixing errors that keep the code from running is literally what I'm trying to teach.
@futurebird Are you familiar with the work of @Felienne ?
-
Wanted: Advice from CS teachers
When teaching a group of students new to coding I've noticed that my students who are normally very good about not calling out during class will shout "it's not working!" the moment their code hits an error and fails to run. They want me to fix it right away. This makes for too many interruptions since I'm easy to nerd snipe in this way.
I think I need to let them know that fixing errors that keep the code from running is literally what I'm trying to teach.
@futurebird
I teach physics, but I know what you mean. I usually start by saying that 500 years ago ppl. like Leonardo da Vinci would easily have understood how the (classical) physics of a modern car works, but they would never have believed we could manufacture the parts with such precision. So the class is more about error control than new concepts.I also remember it being quite a mental leap for me as a student.
-
@futurebird have a look at some of the stuff Phill Bagge wrote about Learnt Helplessness https://philbagge.blogspot.com/2015/02/eight-steps-to-promote-problem-solving.html?m=1 and ways to work around it. I remember him doing lots of related work on it about 10 years ago.
@DavidAmes @futurebird note however that the term is misused here (and elsewhere) -- learned helplessness is a clinical term describing people no longer attempting things that have previously gotten them punished (usually physically hurt), even if that response is no longer present. https://en.wikipedia.org/wiki/Learned_helplessness This is often an explanation for seemingly illogical behavior in people who've endured abuse, and it's frustrating that the word is now being used to shame people for exhibiting the behavior! I point this out not as a criticism of the blog piece but in hopes that we use different terms going forward.