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."
Johannes Monareng arrived three years ago, leaving his family in a rural community 200 miles away. He found temporary jobs as a welder but, even before the work dried up, saw no alternative to living in a shanty. He erected a stifling, windowless 8-by-10-foot shack on a bare patch of dirt for which he paid the government $65. He scavenged most of the building materials, though he says he paid $20 for a metal overhang to shade what he calls his veranda.
He lives off the money he makes reselling milk bought from the government at a discount. He has a small plot of corn, and eats or sells whatever the rats don't consume; three hens supply eggs.
"I want to go back home and be with my wife," he said. But he does not go home because work is even scarcer there, and he cannot wait six years for his government pension to kick in.
Whenever someone moves from a shack into a new government house, someone is waiting to move into the shack - if the government hasn't razed it.
Masekoameng, the young history buff, lives with his family in a two-room shack off a rutted dirt lane. A portable toilet serves several families. Water comes from a green tank a hundred yards away. The kitchen is a patch of ground where a nightly fire heats cornmeal, the only food the family can regularly afford. In the distance loom power lines and a large sewer pipe that do not serve the squatter camp.
The family has lived in this shack for three years, after two years in another.
Masekoameng, 20, dreams of finishing high school, winning a college scholarship and becoming a lawyer who represents the poor and imprisoned. He is grateful that his mother found enough housecleaning work to scrape together the annual $25 school fee for him and his younger sister.
Affixed to the shack's door is a housing department sticker bearing a barcode and a 15-digit number that indicate the family's place on the lengthy waiting list for government houses. He has no idea how long that might take and blames the delay on the ANC.
"They always give everyone promises, saying we'll all get water and houses," he said. "Now we're still suffering, and we voted them [into office]. I know I'm not the only one complaining about the ANC."
His anger is tempered by what he sees beyond the stream - government houses where his classmates can study by electric light. If his shack is a constant reminder of unmet promises, those houses give him hope that his family's turn may come.
Bertha Mosemola, his neighbor, is waiting, too. She has lived in a series of shacks since 1993, she said, when the family for which she worked as a live-in maid moved overseas. She supports two adult granddaughters and three great-grandchildren on her monthly $125 pension.
"I can't live in a shack my whole life; you have to live in a better place," she said, sitting on a mat in her shack where she works as a traditional healer, dispensing herbal remedies and throwing bones to tell futures.
She offered no predictions about her future. But she was not ready to give up on the ANC.
"It has changed a lot of lives," she said. "We have schools. Our children are getting educated. The police are not chasing us at midnight. But we have no houses."