“IS ANYONE here actually hoping to make any money, or are you all just trying to minimise your losses?” The question, asked at a dinner in London for investors who specialise in Africa, showed how the mood has changed in the past year. The financiers around the table—mostly holders of African bonds—all said they were simply trying not to lose money.

Only a few years ago people were queuing up to invest in Africa. As recently as 2012 Zambia paid less than Spain to borrow dollars. Private-equity funds dedicated to Africa raised record sums to invest in shopping malls and firms making everything from nappies to fruit juice. Businessfolk salivated at the prospect of selling to the fast-growing African middle class, which by one measure numbered 350m people. Miners sank billions into African soil to feed China’s appetite for minerals.

Now investors are glum. In the short run, they are right to worry. In the long run, as our special report on African business shows this week (see article), the potential rewards from a market of 1.2 billion people are too juicy to ignore, despite the risks.

From oil in the gears to sand in the wheels

For decades, sentiment about Africa has followed commodity prices, rising and falling like a bungee-jumper at Victoria Falls. The recent plunge has caused a 16% drop in sub-Saharan Africa’s terms of trade (the ratio of the price of its exports to that of its imports). Growth across the region will slow to about 3% this year, predicts the World Bank, down from 7-8% a decade ago. That is barely ahead of population growth of 2.7%. Nigeria and Angola, two big oil exporters, will probably need bail-outs from the IMF within a year.

Yet Afro-pessimists should remember two things about commodity busts. They don’t last for ever. And they don’t hurt everyone: 17 African countries with a quarter of the region’s population will show a net benefit from the current one, thanks to cheaper energy. More important, by focusing on the minerals markets it is easy to miss some big trends that are happening above ground—and these are mostly positive.

The first is that Africa is far more peaceful than it was even a decade ago. The wars that ripped apart the Democratic Republic of Congo and sucked in its neighbours, causing millions of deaths, have largely been quelled. A few states, such as Somalia, South Sudan and the Central African Republic, are in chaos. But overall the risk of dying violently in Africa has tumbled. The latest ranking of the world’s most violent countries by the Geneva Declaration includes just two African states (tiny Lesotho and Swaziland) among its top ten.

Africa is also far more democratic than it was. In the 1960s, 1970s and 1980s, only one sub-Saharan government was peacefully voted out of office. Now nearly all face regular elections, which are harder to rig thanks to social media. Voters have real choices—one reason why policies have improved.

Old-style governments favoured nationalisation, printing money and (in some cases) rounding peasants up at gunpoint and forcing them onto collective farms. Small wonder Africa grew poorer between 1980 and 2000. Now inflation has largely been tamed, most central banks are islands of excellence and many ministers boast of cutting red tape. Five of the ten fastest reformers in the World Bank’s latest report on the ease of doing business are African. Better government has led to better results. The proportion of Africans living in absolute poverty has fallen from 58% to 41% since 2000. In that time primary-school enrolment has risen from 60% to 80%. Annual malaria deaths have fallen by more than 60%.

Pessimists fret that much of this progress will reverse now that Africa faces economic headwinds. There are some worrying signs. Leaders once hailed as democrats are amending constitutions to escape term limits. In Congo, Joseph Kabila’s efforts to cling to power risk restarting a civil war, as the president of neighbouring Burundi already has. The continent’s two biggest economies are making needless and costly policy errors. Nigeria is trying to prop up its overvalued currency by, in effect, banning imports. Instead it is driving up inflation. South Africa, meanwhile, has prompted capital flight and brought economic growth to a halt by keeping in power a president who was found to have breached the constitution and on whose watch corruption has flourished.

But massive missteps like these are now the exception rather than the rule. Most countries in Africa are following sound economic policies, controlling government deficits and keeping inflation in check. Dig beneath the headlines, and even in countries that are making big errors there is momentum for reform: in South Africa once-taboo policies such as privatisation are back on the table, and in Nigeria the government is clamping down on corruption and trimming a bloated civil service. Ethiopia is sucking in foreign investment, and smaller economies such as Ivory Coast and Rwanda are growing rapidly after making it easier to do business.

Minds, not mines

The continent’s future is in the balance. Whether it bounces back from this commodity slump or slips back into stagnation, war and autocracy will depend on whether enough of its leaders keep moving forward. Two goals stand out. The first is to recognise the new reality. Given the decline in its terms of trade, Africa’s buying power has gone down. Currencies must fall and governments adjust. Those that relied on mineral royalties must broaden their revenue bases: taxes are just 10-15% of GDP in most African countries.

Second, African governments need to keep up the hard slog of improving the basics. Bad roads, grasping officials and tariff barriers still hobble trade between African countries, which is only 11% of total African exports and imports. Improving that means investing in infrastructure, fighting corruption and freer trade.

Africa’s past has long been defined by commodities, but its future rests on the productivity of its people. By 2050 the UN predicts that there will be 2.5 billion Africans—a quarter of the world’s population. Given good governance, they will prosper. The alternative is too dire to imagine.