However, median compensation for really good doctors is vastly higher than median compensation for really good developers (in the US, anyway).
Your point still stands, but student loans from med school are nothing to brush aside.
E.g., in Belgium, any year spent studying at college- or university-level costs €550 (±$720), plus the cost of the books. If your parents earn less than a middle class income, you pay significantly less.
The major difference that does hold true everywhere, is the fact that doctors start earning a salary much later.