If a random country is in debt, is printing money a good way to pay it off at the expense of the citizens?
For example, lets say you owe an entity $100. If you print an extra $100 bill you pay off your debt, but unbeknownst to the entity the $100 that they lent you is now worth less.
Would the barter system be a good way of combating this?
That's why inflation is considered by some as an invisible tax.
This is completely possible and evident in countries such as Zimbabwe, Germany in the past and countries like Venezuela now. Printing money to pay back old debt at the expense of fiat currency holders, specifically middle income earners is nothing new.
Why does it affect the middle class the most? The poorest hold little currency to begin with while the richest own factors of production, whose value will rise in nominal terms in line with inflation. That's also a reason why I think decentralized cryptos is a good hedge against this phenomena ever happening in your country.