News for hackers. Stuff that matters.
Re:Why don't schools teach debugging? (2014) by majewsky on Tuesday April 25, 2017 @04:57AM (#14191834)
> Anything that has one right answer is going to smell like a made-up classroom assignment.

If you're doing C (or any other language where that particular problem exists), it's always a nice exercise to have students write a program (or a function) that takes the radius of a circle and outputs its volume. Most students will write:

  double volume(double radius) {
    return 4 / 3 * M_PI * radius * radius * radius;
  }
Can you see the problem? ;)
Re:Why don't schools teach debugging? (2014) by julian_1 on Tuesday April 25, 2017 @07:27AM (#14192490)
4 / 3 would be computed as an integer (eg. 1), before the result is implicitly coerced to float for the rest of the expression calculation?

A nice example for debugging, and for understanding the value of languages with better typing discipline.

Re:Why don't schools teach debugging? (2014) by the-dude on Tuesday April 25, 2017 @07:07AM (#14192395)
Circle has no volume
Re:Why don't schools teach debugging? (2014) by noxToken on Tuesday April 25, 2017 @09:36AM (#14193348)
Although I laughed, I'm sure GP meant sphere. That is the correct formula for volume of a sphere, and a sphere is a circle in 3-space.
Re:Why don't schools teach debugging? (2014) by majewsky on Thursday April 27, 2017 @08:07AM (#14210824)
Aw snap. Yeah, of course I meant a sphere.

(And technically, it's the other way around. A circle is the 2-dimensional special case of a (hyper)sphere.)

Re:Why don't schools teach debugging? (2014) by the-dude on Tuesday April 25, 2017 @10:00AM (#14193545)
Sure. But getting the spec right is more important than being smug about a silly mistake only novices make. And C has much more interesting caveats than this one.