Nearly any intellectual activity in life teaches you similar lessons.
What does it mean to “code?”
Richard Kenneth Eng

That’s a good point! As it turns out, computer programming happens to be particularly good at teaching certain kinds of critical thinking. It’s drastically better than chess or math class in many ways. I’d refer you to the work of Seymour Papert who pioneered the field of teaching kids to code in the ‘70s as a means to teah critical and mathematical thinking way before it became in vogue.