Absolutely. There are fewer harder things in software development than taking criticism over code you've lovingly crafted, but ultimately it's this criticism that makes you understand the code better.
Additionally, if you're posting code on the Internet then you're there for everybody to shoot at. It sucks sometimes, but that's how things go.
There is a big difference between being cruel and being helpful. Very often I see the former. I don't post my code, so this isn't about me. It's about what I see from others.
You're absolutely right, but it's the current nature of sharing code on the Internet. I've had enough of my code slated to know, and at times it has stopped me posting what could be valuable code for others.
It also depends on where you're sharing your code, and what kind of communities will pick it up. In my experience, the Python and .NET communities have been great when dealing with both damning and constructive criticism of any problems of mine.
Additionally, if you're posting code on the Internet then you're there for everybody to shoot at. It sucks sometimes, but that's how things go.