DIEPSLOOT, South Africa --At dusk, Joshua Masekoameng burrows into his history books as an escape from the shantytown that is his home, but it is hard to ignore the setting. The high school senior does his schoolwork by candlelight.
The 10-by-20-foot shack that he shares with his mother, two sisters and a nephew lacks electricity and running water. There are four corrugated metal walls, a metal roof, a concrete floor, a faded shag carpet, a single bed and an old stereo on a battered shelf - but that is all.
"I love history very much," Masekoameng said, reading a textbook last updated in 1988. "History talks about life, the olden days when people were fighting. A long time ago, people weren't equal. Now we are equal."
Equal to a point. Since the end of apartheid, an explosion of shantytowns, many within urban townships, has made a mockery of the government's promise of adequate housing for all.
Since 1994, the government has provided 1.8 million houses at little or no cost. But the backlog of people waiting for government housing has grown to 2.4 million households, says national housing spokesman Ndivhuwo Mabaya. Up to 12 million people live in crude shelters lacking basic services - a quarter of the country's population, and a 50 percent increase from a decade ago.
The cause is not a mystery: People from rural areas who decades ago were forcibly moved to remote "homelands" under apartheid are flocking to South Africa's largest cities to find work, joined by immigrants from other parts of Africa. They find too few jobs that pay enough for families to afford even a modest house.
In a faint echo of the anti-apartheid tactics of the 1980s, a growing number of people are taking to the streets to protest the lack of services, as well as local government corruption. In November, police fired rubber bullets at protesters in a shantytown near Durban, injuring two.
Diepsloot, 15 miles north of Johannesburg and almost within sight of a wealthy suburb, was the first community to erupt, in July 2004, amid rumors that residents would be moved farther from Johannesburg. Protesters threw stones at cars, and police made numerous arrests.
The governing African National Congress has been scrambling to respond. With an eye on local government elections March 1, President Thabo Mbeki announced this month a $67 billion program to provide all South Africans with clean water and sanitation by 2010 and electricity by 2012. The campaign slogan of the opposition Democratic Alliance is "Stop Corruption, Start Delivery."
The unrest poses little immediate threat to the ANC at the polls. In addition to dominating the national government, the party controls local governments in seven of the country's nine provinces. But the street protests have prodded the country's leaders to act faster - and might thus be able to do more for the poor than the country's opposition parties can, said Adam Habib of the Human Sciences Research Council in Pretoria.
"When politicians are uncertain about their future, they act in the interests of their citizens," Habib said. "That is what democracy is about, enshrining uncertainty."
He expressed hope that the government's promise to do more signaled a shift away from the conservative economic policy that has kept inflation below 4 percent and drawn cheers from the business community - but without providing the jobs, housing and services needed by a large part of the population. While new homes and better services could reduce the anger, he said, the most important step is to create jobs for those mired in squatter camps such as Diepsloot.
Diepsloot ("deep ditch" in Afrikaans) is barely a decade old. Officials assumed that its first residents would be here only briefly, after being moved to relieve crowding in another township near Johannesburg. But people have been arriving ever since.
The area, which used to be rolling farmland, is now a Dickensian scene with about 5,800 brick, two-bedroom, government-supplied houses competing for space with well over 10,000 shacks. The population has grown to around 150,000 people, crammed into two square miles.
One of the few shelters from the dust and crowding is a meandering stream, but in heavy rains it becomes a torrent. Last month, a 30-year-old woman died when her shack was swept away; rescuers saved her husband, baby daughter and 11-year-old son.
Officials say that improving conditions here is a high priority and point to construction of a youth center, clinic and police station. But they concede that the housing challenge is enormous.
"Unfortunately, we can't do everything for everybody," said Mongezi Mnyani, housing spokesman for Gauteng Province, which includes Diepsloot. "With the number of people still coming into Diepsloot, you find demand for housing will always be there, irrespective of whether we meet targets or not."