In New York City, Mayor Bill de Blasio is struggling with the issue of homelessness. There are tons of people sleeping on the street, and New Yorkers are upset about it. One police union briefly trolled the mayor by urging officers to post pictures of homeless people on the union's Flickr page.

In a rich nation like the United States, homelessness, like poverty generally, is a simple problem to solve policy-wise, but a tough nut to crack politically. Utah, of all places, has demonstrated that the simplest imaginable solution — namely, giving nearly free housing to the chronically homeless — works like a charm, and actually saves money. The only problem is overcoming the political barriers.

The first thing to understand about homelessness is that it's mostly a transitory phenomenon. Of any particular population of homeless people, the vast majority of them will find some place to live in a few months.

The people you see out on the street, panhandling and sleeping in doorways, are almost always part of the small hard core of chronic homeless people, about 10 percent of the homeless total. These are the people the New York Police Department is complaining about, and they're typically older people with serious addictions or mental illnesses.

Such people are very expensive for the state. Homeless shelters cost a lot, and people on the street are constantly being picked up by the police and getting sick from being out in the elements. Shelter beds, jail cells, court time, and repeated emergency room visits (if not time in intensive care) add up to truly spectacular bills. Utah found that it was spending $20,000 per year per chronically homeless person — fully 60 percent of the total spending on homeless overall, despite them being only a tenth of the total. In New York, the figure is more like $40,500.

Practically, this means that you could spend a lot of money on concentrated social services for the chronically homeless, and still come out ahead financially if it keeps them off the street. So when Utah tried just handing such people their own apartment in a program called Housing First (though participants do have to pay $50 or 30 percent of their income, whichever is more), and combined that with regular attention from social workers, hey presto — the state decreased chronic homelessness by 91 percent.

It's not a perfect solution. Some people wreck their apartments, while others simply prefer the street life. But on the whole, the program has been a smashing success — and not just at reducing government outlays, but at helping people stabilize their lives. It turns out that it's easier for people to get jobs and cut back on substance abuse when they aren't on the street.

Of course, this is not to neglect the much larger population of homeless people who are transitory. There is a similar program in some places called Rapid Rehousing that works with people who have recently lost their homes to get them into new ones and keep them out of shelters, which can be violent and dangerous. It's a simple solution, but a difficult fiscal proposition in a place like New York, which has a desperate housing shortage. The city could easily afford to house the chronic population given the likely savings, but the tens of thousands more who are temporarily homeless are a different story. The best solution here would be to implement a general public housing plan with hundreds of thousands of new units (which de Blasio has been trying to do, with some success), and reserve some of these for homeless use.

What this policy orientation runs headlong into, however, is the typical American attitude about moral desert. The idea of the most basketcase homeless people getting more services sets many people's teeth on edge. "I'm working hard and paying my bills," the argument goes. "How come I don't get a free apartment?" This sort of attitude produces wretched welfare-for-the-rich policies like the mortgage interest deduction, which pays out more the more money you make.

The answer to this hypothetical questioner, of course, is that he is fortunate enough not to need a free place to live. Incidentally, if he wants to quit his job, get himself a mental illness or three, and spend a few months sleeping on subway grates, all to get that sweet efficiency apartment, he's certainly free to do so.

When it comes to the hardcore homeless people that get the police and the tabloids all worked up, the solution is obvious and proven to work. All you have to do is try.