I thought so too. This always made me so angry. Last time I posted a rant about that here someone urged me to read the REPAYE Act, and it completely changed my mind.
Under REPAYE, students get income based repayment, even down to $0 payments if you're anywhere near poverty level. After a certain number of years of repayment, the government just pays off your entire balance.
This solves the same problems bankruptcy is designed to solve without ruining people's credit. It also prevents doctors from declaring bankruptcy right after medschool -- I'm honestly unsure whether that was a real or just anecdotal problem, but income based repayment for a fixed term seems like a better way to let people escape debt while still expecting them to pay what they can.