This answer says:
Short sale or foreclose and kill your credit for a few years.
And that made me curious - how badly does a short sale or foreclosure hurt your credit, and for how long?
It's impossible to give a specific answer as to how much your score will decrease, because it depends on a lot of personal specifics. Experian suggested they were similar; short sale averaged around 120-130 points while foreclosure averaged 130-140. However, it's very much dependent on other elements; if you have an 800, it's going to knock off more than if you are already at 500, because some of the negatives are already baked into that 500.
A short sale is reported on your credit report as something like "paid in full - not full amount", and thus lenders can see that you didn't pay the debt in full. It will appear on your credit report for either seven years from the date of the sale (if no payments were missed), or seven years from the beginning of the delinquency (if some payments were missed prior to the short sale), according to Experian.
A foreclosure will last for seven years from the date the foreclosure is filed, regardless of whether the foreclosure is completed or not. It likely makes a difference whether or not the foreclosure resulted in the bank taking a loss or being made whole, but I couldn't find any specific information about that.
Another option you don't mention is loan modification programs (where the lender agrees to a different schedule or a different amount, but you still make payments rather than selling the home). Experian doesn't have specific data yet on the impact of these (that's an 2009 article on them, but I haven't found anything better), but they will have some negative impact as well (similar to those credit card modification programs, perhaps).
Foreclosure is an admission that you couldn't be trusted to pay off a loan. That will definitely look bad on credit reports, and may look bad to prospective employers or landlords. Penultimate resort, just short of bankruptcy.
Selling in order to pay off the loan, and taking a loss f necessary, would be considered the financially responsible and honorable thing to do, if you have already exhausted all the other alternatives. It's probably going to leave you with more money than a foreclosure would, too.