I have an iPhone 4 which is really my communications hub whenever I'm out of the house. I can e-mail, surf the net, use instant messenger, and whatever other apps/games, call, text, and skype.
There is a little tab on the side of the phone that you flip to set the phone to silent. I use this tab whenever I enter a movie theater, classroom, library, church, high end restaurant (fast food restaurants I don't bother), or any other place where you are supposed to be quiet.
As long as you turn off the "Keyboard Clicks" sound (Settings -> Sounds -> scroll all the way to the bottom where it says Keyboard Clicks), or just use the "mute tab" as I call it, I don't see any problem texting in a library. In a church or classroom, it would probably be disrespectful, but if it is urgent, go for it...and only for texts.(again, be sure it is set to SILENT!!!) However, in a movie theater, the glow from the screen can be distracting at times, that even with the phone set to silent, people can get agitated if you use your phone in there.
People who know my phone number know that if there is an emergency, they call me 3+ times in quick succession if I don't answer the first time. In those cases, I would excuse myself from the situation, whether in a restaurant, movie theater, or class and take the call.
Edit: 50th post!