if you're struggling to stay afloat and have no credit/assets, a short time in jail is way worse than bankruptcy. on the other hand, if you've worked as a SWE for a few years, loosing all your money and having terrible credit for years is pretty awful. you're broke, so you can't buy anything outright, and your losses are compounded by the fact that you pay much more interest on things you buy on credit (if you can even get financing at all). it's not hard to see that this could be worse than a short time in jail. it all depends on the length of the sentence and your total losses from bankruptcy.
also keep in mind we are talking bad credit and all your assets seized by creditors. i'm not saying a bad credit score is literal hell on earth, but if you have no money and no credit you are gonna have a really bad time for a while.
Did I understand you correctly? Are you saying that being in jail is almost the same as having a bad credit with bankruptcy record?