Image caption Joao Vitor ended up on the streets aged 14

In 1937, Jorge Amado published Captains of the Sands, a novel about a gang of orphaned children living on the streets of Salvador, north-east Brazil. Eighty years on, little has changed - thousands of children and adolescents still roam the city and sleep rough. David Baker hears some of their stories.

Zeca (not his real name) isn't proud of his past. A tall, skinny, slightly shy black teenager, he mumbles and looks down at his feet when he speaks about the years he spent living on the streets of Salvador.

He's 17, though he has the weary, cracked voice of an old man who has seen too much of life, and he talks about his time in the city's drugs gangs with regret.

"I found many types of job [with the gangs]", he says, "trafficking, packing, stealing…" And then, after a long pause, he adds: "killing."

He won't be drawn on the details but he says gang life was a case of kill or be killed.

I have come to Salvador to meet people like Zeca because of a book published here 80 years ago that became a classic of Brazilian literature.

Jorge Amado's Captains of the Sands tells the story of a gang of orphaned children and adolescents living in an abandoned warehouse in Salvador's docks area who live by begging, stealing and hustling.

"Dressed in rags, dirty, half-starved, aggressive, cursing, and smoking cigarette butts, they were, in truth, the masters of the city," Amado wrote.

Image copyright Getty Images

He wanted to show the freedom and fun these children could have looking after each other and having adventures through the city's streets.

But he also wanted to show the misery of their lives and to shame Brazil into doing something about the thousands of homeless children in the country that richer Brazilians at the time viewed as little more than pests.

That was then, but there are still gangs of children, like the Captains of the Sands, living on the city's streets.

I met Zeca in a government-run shelter that takes children and adolescents off Salvador's streets and helps them reintegrate into mainstream life.

Like him, many come from broken homes. And, almost the moment they arrive on the streets, they run the risk of being picked up by one of the many drugs gangs that run great swathes of this, Brazil's third-largest, city.

Find out more

Brazil's Modern-day Captains of the Sands was broadcast on BBC World Service's Assignment programme. Listen again on iPlayer.

When Zeca talks of his own time with them his eyes develop a far-off look, as if something has died inside him.

"It was very violent," he says. "If you live on the streets you have to be evil."

Zeca's story is so shocking that it's easy to forget he is still just a child.

"When I was 10 I used cocaine and smoked weed," says Zeca.

"I used to snort a lot of cocaine. And one day there was no coke for me to snort so I went on to the streets and started smoking crack."

Immediately he discovered how violent life on Brazil's streets can be.

"I had a knife, a gun, all these sorts of things, to defend myself," he says.

"I could only sleep in the morning because during the night I had to stay awake. There were many dangers, someone could come and kill me."

NGOs working in the city reckon there are as many as 3,500 people under 25 living on Salvador's streets still.

And among them is a friendly, intelligent and curious young man I met one day in a square down by the city's docks - Joao Vitor.

Joao Vitor is 20, black and very much at ease with his life on the streets. He's thrilled to talk and clears some space on the foam mattress he sleeps on for me to sit down and join him.

He grew up, he says, being looked after by his grandmother and, from the age of eight, he helped her cook and sell acaraje, deep-fried dumplings that are a classic Salvador street food. But when he was 14, she fell ill and had to move back to the countryside and Joao Vito ended up on the streets.

Image caption Grafitti of a street kid in Salvador

It was tough, he says, "having to sleep in the streets, having to eat food that I didn't like, worrying about other people trying to attack you, but as time went by you get used to it".

And, he says, like the teenagers in Captains of the Sands, you quickly find yourself part of a gang who look out for each other.

"I've got nothing of value here," he says, showing me the few possessions he keeps next to his mattress. "The things I really value are my friends here. They are my family."

Joao Vitor has kept clear of the drugs gangs and he's pleased about that. "Drugs diminish you as a person," he says.

But he has certainly experienced violence. He has scars on his arm and the side of his neck from when someone attacked him with a machete. And he has seen police attack people sleeping in the streets.

There is also, he says, the problem of poor people on the streets attacking each other.

"You will see many zombies on crack," he says. "When they have money, they're happy because everyone is their friend. But when they have no money, if you touch them there will be a fight."

His experience, though, is very different from Zeca's. He says he prefers to deal with arguments through talking rather than a fight. And, when it comes to enjoying the freedom of Salvador's streets, he absolutely sees himself as like the children in Captains of the Sands.

"I am a Captain of the Sands," he says with a big smile. "Because look at the life we live, bro. The only part I'm not is when it comes to stealing. But it's true as far as living adventures, always exploring the day that we're living, for sure I am."

He picks up his stuff and says he's off soon to have a dip in the sea and to catch up with some other people he knows who live on the city's streets.

"There'll be other friends of mine there too. If I need anything they'll sort me out," he says. "This is what friendship is. It's a family."

Neither Joao Vitor nor Zeca are certain about what the future holds for them - though Zeca, in the shelter, has at least taken a first step in getting off the streets. Both boys say they take life one day at a time.

But, however their lives turn out, there are thousands of young people like them living on Salvador's streets today and the Brazilian state has very few resources (and, some would say, very little political will) to help them.

If he returned to his city today, Jorge Amado would still feel the need to shame his country into action.

Join the conversation - find us on Facebook, Instagram, Snapchat and Twitter.