This is a complicated question and for a detailed understanding, one should consult both an accountant and an attorney. One thing is for sure: it seems like when the topic of foreclosure or bankruptcy is brought up, people come out of the woodwork with opinions, most of them not lawyers or accountants.
So it bears mentioning that I am neither. So I will only answer as far as mortgages are concerned.
Foreclosure is not a very good thing. Basically it is a result as opposed to an intended action. It’s a result of falling many months behind on a mortgage payment which causes the lender to foreclose or take the house back.
Foreclosure damages one’s credit and makes it very difficult to finance real estate for several years unless they have some excellent compensating factors. One thing most people don’t realize is that after the lender forecloses on a house they will attempt to sell it or otherwise collect income from it. Any deficiency is the liability of the original borrower. The borrower will be pursued for the deficiency unless they pay it or file bankruptcy.
Bankruptcy (BK) is an intended action as opposed to a result. Depending on the nature of the BK it can be a source of relief or a fresh start. I won’t get into the details of what I understand BK to do or not to do. It is not a fresh start in terms of creditworthiness however. It has similar impacts on one’s ability to finance a home as foreclosure.
So neither is favorable, but both are sometimes necessary. Foreclosure doesn’t really get you anything whereas at least the BK can provide some debt relief. I do not advocate using BK irresponsibly to write off debt.
Despite some popular opinions, people that go through foreclosure or BK can still obtain financing within a surprisingly short amount of time after the negative mark.