the property value, the local market condition (trending down or up), the speed of foreclosure, the need to fix the property or not and to what degree, third party cost (legal cost, government cost/tax, ...), bank internal cost (resource cost)...
Adding everything up, it could cost a bank up to 20% or more of the sale price for processing a foreclosure. Keeping in mind that short sale also cost bank money, but in general not to the level of foreclosure.
But this does not mean that you can buy a short sale at 20% discount to foreclosure. It depends on local market, and the pricing difference is actually not necessary significant. In a down trending market, you can turn out paying high for a short sale (because your offer price may be based on a market condition of 6 months ago when the market price was higher).
This said, in general, you'll still get cheaper on short sale, which is the reward for waiting and for handling (often nasty) current owner moving out yourself.
If you need to buy with loan, you also take risk for sudden interest rate move-up in the case of short sale which you generally don't have good control over the timeline.
On average, you'll and your realtor also spend a lot more time and energy to close a short sale.