I think it's important to distinguish the two types of residents/attendings who do this.
1) Jerks - People who just get off on putting down students, and have no real interest in teaching you or helping you get ahead.
2) Decent docs - Medicine has historically been one big hazing ritual, and there are still a lot of docs out there who believe that they can "toughen up" their students by berating them. This type does teach you, does want you to succeed, and does not believe their comments should be taken "personally".
I have experienced a little of #1, and much more of #2. While it still stings to take shots, I have no interest in butting heads with a doctor who is actually interested in helping me, even if they can be rude or mean.
The attending who called me "weak" in the middle of the OR (and several other names on multiple occassions) was also the best teacher I had on surgery, and several times stood up for me when residents or anesthesiologists came after me. At the end of my rotation, she wrote me a really beautiful letter of recommendation.
My surgical residents were much the same way. I was yelled at several times on rounds in front of the entire team ("Who the hell do you think you are?! You're not a resident, and I expect you to give complete presentations on every one of your patients! If you can't even remember a simple creatinine value, how the hell do you think you'll ever make it Orthopedics?!"). I, and my classmates, were frequently put down ("Did you learn anything in your first two years of med school?!"). But at the end, the chief gave me honors, and sent me a very nice email saying that she only rode me so hard because she knew I could take it, and believed in my potential as a surgeon.
In short, while these experiences have been painful, I believe that they made me a tougher person, and a better student. By correcting my mistakes at an MSIII level, I performed better on my sub-i's, and was able to match to my first choice program. Does it hurt? Hell yes. Am I glad it happened? Actually, kind of.