NO CONTINENT is urbanising faster than Africa. Why? One answer is partly statistical: Africa has been the slowest to get started. Another is that parts of Africa, such as the Sahel, have been affected recently by severe climate change, making marginal land unfarmable. And in countries like Angola and Congo years of fighting have propelled millions to the cities. But a fuller explanation is needed. A look at Nairobi provides some answers, and throws up more questions.

For many years the biggest city in east Africa, where human life seems to have begun, was not a bad advertisement for the urban condition. As the capital of Kenya, Nairobi had the subdued bustle of an administrative centre, some industry, hotels for tourists on their way to or from wildlife safaris, lots of greenery and even a small forest. The population in 1960 was about 250,000. Today the forest remains, but, with 3m people, Nairobi has lost much of its charm. The traffic is awful, as is the crime, and the superlatives are usually reserved for Kibera, which is supposedly Africa's largest, densest and poorest slum.

It probably is not. Luanda, Kinshasa and Lagos, the world's fastest-growing megacity, may all have slums to match Kibera, whose population is put at anything from 600,000 to 1.2m, depending both on the estimator and on the time of year, many of its inhabitants being seasonal migrants. What makes Kibera unusual is, first, that its 256 hectares (630 acres) sit right in the middle of Nairobi and, second, that it finds itself on the doorstep of Habitat, the UN's agency for towns and cities, which is based in a campus of bucolic tranquillity not far away. Accordingly, Kibera gets no end of attention from outsiders, whether governments throwing money at it, NGOs engaged in mapping and studying it, or film stars shooting “The Constant Gardener”. Ban Ki-moon paid it a visit within a month of becoming the UN's secretary-general this year.

Most of what makes Kibera interesting, though, is what it shares with other African slums. The density (shacks packed so tightly that many are accessible only on foot); the dust (in the dry seasons) and the mud (when it rains); the squalor (you often have to pick your way through streams of black ooze); the hazards (low eaves of jagged corrugated iron); and the litter, especially the plastic (Kibera's women, lacking sanitation and fearing robbery or rape if they risk the unlit pathways to the latrines, resort at night to the “flying toilet”, a polythene bag to be cast from their doorway, much as chamber pots were emptied into the street below in pre-plumbing Edinburgh). Most striking of all, to those inured to the sight of such places through photography, is the smell. With piles of human faeces littering the ground and sewage running freely, the stench is ever-present.

Not much, but it's home

Striking, too, though, is the apparent contentment with which the inhabitants accept their lot. It falls short of cheerfulness: tension is constant in Kibera, and small incidents can quickly turn nasty. But most people are busy getting on with life. Churches abound, and schools too. Children play in the dirt or on the railway tracks that bisect the slum. Stall-holders sell their goods. Men, ragged or smartly dressed in dark suits, clean their teeth wherever they can spit.

Indoors, things can be more wretched. On the northern slope of the area known as Soweto East, Josephine Kadenyi lives in a shack three metres square (ten feet by ten feet). It consists of one room, with a curtain dividing it. It has no electricity and no sanitation. Outside is a vast heap of litter and plastic bags used by children as a lavatory. Just below that, 14 thin water pipes emerge from the ground, bound with sticky tape in a half-successful effort to stem the leaks. Sewage runs alongside. Mrs Kadenyi makes her living by selling uncontaminated water and looking after the disabled child of a neighbour.

In NGO-speak, Kibera is an “informal” settlement. That means it does not officially exist. The government provides nothing. If there are schools or latrines or washrooms, they are privately run (it costs three shillings, about four American cents, to use the latrine). The government provides no basic services, no schools, no hospital, no clinics, no running water, no lavatories. It does, however, own nearly all the land, so if you want to put up a shack, you must go to the chief, a civil servant in the provincial government, and get his permission. For a consideration, perhaps 5,000 shillings (about $70), this can be obtained, but you receive no piece of paper, merely an oral consent.

Most shacks are in fact owned by “landlords”, some of them descended from Nubians rewarded by the British for their military service in the first world war with the right of abode in Kibera. They now jostle with others who have established, through custom, corruption or force, the right to put up a “unit”. These are then rented out to tenants, who have no rights of any kind. The cost of erecting a shack is recouped within a year or two.

Daniel arap Moi, who served as president of Kenya from 1978 to 2002, has long owned a house that abuts Kibera. Like almost all other ministers of his as well as the present government, he does his best to ignore the slum next door. Kenyan politicians seldom if ever visit it, or indeed the 200 or so smaller “informal settlements” in Nairobi, even though 60% of the capital's population live in these slums. Several politicians are, however, reputed to be landlords, as are many civil servants and other local worthies.

Why does the government not bulldoze Kibera and rehouse everyone in multi-storey flats on the same site? Oh, that would be very complicated, the questioner is told. The difficulties abound, apparently, and they are not all financial. The real reason is that lots of people make lots of money from the slums, providing the services the state does not provide and extracting the bribes that anyone living in an illegal city has to pay just to survive. Moreover, the slums provide the cheap labour that enables the city to operate. The status quo suits the authorities quite nicely.

And what about the people who live in Kibera? Strangely, it suits them too, up to a point anyway. Asked whether she wouldn't prefer to go back to the village in western Kenya that she left six years ago, Mrs Kadenyi says, “Yes, of course. But what would I do back home?” What indeed? Kenya's average rate of population growth for the past 30 years has been over 3% a year, putting enormous pressure on the land. With mouths to feed and no prospect of a job in the countryside, the rural poor head for the cities. There at least they have some hope of employment.

Hope is all it is for most of them, at least in the formal economy. But hope is what keeps them in places like Kibera. It may be a dump, but it is central. This means that anyone lucky enough to have a job, either in the offices or houses of the city, or in the industrial area nearby, can walk to work. Those who have to peddle goods or search for casual labour are equally well placed. Being able to avoid a time-consuming and expensive commute is a great benefit.

Still, centrality does not have to mean squalor. In many cities the slums are on the outskirts, by the airport or somewhere out of sight. But the people of Kibera are suspicious of efforts to improve their housing. In the 1980s they saw some of their land taken for new flats, 400 in all. No one in Kibera benefited, says Raphael Handa, a clergyman who heads a community committee set up with support from Habitat and the government; all the tenants were brought in from outside.

Same story in Mumbai

The people of Kibera are increasingly organised, and increasingly determined to be involved in any plans to spruce up their slum. In this they are typical of their counterparts elsewhere. But in other respects, do Africa's new cities, slums and slum-dwellers resemble those in other continents? An ocean away, Mumbai offers plenty of parallels.

Between 14m and 18m people live in Mumbai, according to where you draw the city limits, maybe half of them in slums. That is about the same proportion as in Nairobi. But as you drive in from the airport or along P. D'Mello Road by the port, you quickly see that these slums are classy. Many of the shacks on the pavements are double-decked, and beds, chairs, goats and children spill on to the street, where head-carriers—porters with straight backs—wash themselves from buckets.

The peninsula of modern Mumbai was, 350 years ago, seven islands, which have gradually been joined and expanded by landfills to make up 65 square kilometres of land shaped a bit like a chilli pepper. The city is hot in every sense but, more seriously, it is crowded, and room for expansion is limited. Until 60 years ago newcomers to Mumbai tended to settle just outside, at Dharavi, where no rules applied and so sheep could be slaughtered and hides tanned. Over the years ever more people came and squatted, and the city, India's financial and commercial capital, expanded. Today about 600,000 people live in Dharavi's 210 hectares, which now lie in the heart of Mumbai. Dharavi's boast is that it is the biggest slum in Asia.

Conditions here are similar to Kibera's: miserable housing, no security of tenure, contaminated water for the 40% lucky enough to have it piped, mud for four months out of 12, bribes needed for a blind eye to be turned to an illegal electricity connection, one lavatory for 800 people, the stink of sewage, and so on.

People come here for familiar reasons, too. Life is grindingly hard for many rural Indians. Agriculture has recently been growing at only 2% a year, while the economy as a whole booms at over 8%. Crops fail, and many farmers are so deeply in debt that they are little more than bonded labourers. Suicide is common: in just one region of Maharashtra, the state of which Mumbai is the capital, 1,450 farmers killed themselves last year. In particular, many dalits, members of the lowest Hindu caste, see no hope of betterment amid the harsh conservatism of rural India. Their only hope is to move to the cities. It is an echo of what happened in medieval Europe, when moving to a city was for many an escape from serfdom. Stadtluft macht frei (City air sets you free), said the Germans.

Beats commuting, too

Life may indeed be a bit easier in a city. Jockin Arputham, who has lived in Mumbai's slums since 1963, when he was 16, makes Dharavi sound almost romantic. “You don't have to work very hard to make a living,” he says. “You can collect and sell garbage. You can always ask people for food, and to sleep somewhere.” He made his bed on someone's verandah for 12 years. Then he founded an organisation for the inhabitants of India's slums. Now he is also head of the international federation of shack- and slum-dwellers.

People in Dharavi look cheerful. Everyone is busy and many are reasonably well off. Some live in flats and own television sets and other electronic gadgets. Among slum-dwellers they are fortunate, for, like Kibera, Dharavi is central, close not just to the diamond market and the financial centre but also the airport, beyond which most Mumbaikars live. Many therefore spend hours getting to and from work. About 7m commuters make their journey to and from the bottom of the peninsula each day. The roads are jammed and the trains overflowing: 700 passengers are crammed into (or clinging onto) carriages meant for 120. About 3,000 people are killed on the tracks each year.

Panos

Even Diogenes would despair

Some people from the slums have been happily resettled farther out but close to a railway, which gives them ready access to their work. Others are benefiting from the citizens' groups that have taken root. Mr Arputham's National Slum-Dwellers Association, for instance, is allied to a co-operative through which some 250,000 people, nearly all of them women, regularly put money aside for their common good. And governments, donors and international agencies find the two organisations to be reliable partners if they want to improve slum life.

Mr Arputham got involved in community action in 1975, when the authorities decided to clear the slum in which he lived to make way for the Atomic Energy Department. He failed to stop the evictions, but learnt that people affected by such clearance schemes had to organise if they were to have any influence. Plain confrontation is much less successful, says Celine d'Cruz, who works with Mumbai's pavement-dwellers, than informed argument, backed by statistics, surveys and the involvement of lots of potential victims.

Thanks to the efforts of such groups and consequent changes in the law, there are fewer evictions nowadays. The controversies, instead, surround efforts to improve the slums. The idea now in vogue is to bring in a developer, let him put up multi-storey buildings, use some of the flats to rehouse those living on the site and sell others at a profit. Slum-dwellers often have enough money to pay rent, and such deals remove a financial burden from the local authority or landlord.

But the scheme is controversial. Some slum-dwellers are too poor to pay even a service charge, which will be levied in return for water and the use of a lift, even if the flats are rent-free. Others complain that only those who were resident before 1995 will be eligible for rehousing, leaving newer arrivals with nowhere to go. Mr Arputham, who is not against development, says the chosen developer has no plans for a sewer and will undoubtedly make 25,000 families homeless.

Others worry that such schemes will allow corrupt officials and corrupt developers to make huge fortunes at the expense of the poor. Under the headline “Mumbai's great slum robbery”, the Hindustan Times recently published details of a police investigation involving, it was claimed, pay-offs to officials to free the builders' hands. Shirish Patel, a civil engineer with a long-standing concern for planning the city, believes that there are simply too many people in Dharavi to allow a developer to rehouse everyone and at the same time make an honest profit.

More generally, he believes that both government and developers have a strong interest in keeping property prices high—and Mumbai's rank among the highest in the world. Vijay Mahajan, of Bombay First, a businessmen's group formed to promote and improve the city, agrees. The higher the prices, the more builders can charge. As for the politicians, they profit from an invisible line that runs directly from slumlord to local politician to state minister to his boss. Money runs up along this line, and so do votes. In return, the government lets the slums remain undemolished. It is a pay-and-stay arrangement.

Nairobi and Mumbai certainly have lots in common. Luckily, other places have fared better. The outlook is not all bleak.