My public highschool CS course was an honors elective taught by the calculus teacher, so I think that made it unattractive as a playground spot. However, I think it was really that the teacher was incredibly patient, kind, and unable to resist tacky puns. I think that helped us students see him more as a teacher than an authority figure to be resisted.
Thats
A) really fucking hard to do, I tried it once*, and I wasn't cut out for it. Teaching takes a special kind of person and a fuckton of effort, and deserves to be paid honestly more than I make as a programmer of computers which at least stick to their syntax rules.
B) the class was small enough that he could put in the individual attention and working-together to make it happen for us.
Unfortunately for the public school system the teacher left a year later.
* I did a boot camp for middle through highschool, and while highschoolers are tough, they were far more willing to work together towards an abstract goal than middle schoolers, for which every day is a bad time for everyone involved.