AT Ballikinrain, the ghosts of former occupants must recoil, now and then, and wonder what the world has come to. Sometimes even the living can share the thought.

The late-nineteenth-century baronial pile at Balfron, near Stirling, was once an imposing private residence. Then, fortunes ebbing by degrees, it was a hotel in the days when people still talked of "an hotel". Finally, before its exclusivity petered out entirely in the 1960s, it became St Hilda's school for girls. The shades of the Victorian past must have heaved a sigh: that fate, at least, counted as satisfactory.

But what now? Incoherent boys prowl and brawl in the undergrowth of the overgrown estate. The fine rooms echo with anger, violence and tears. One child, pausing between expletives, tells a group of film-makers that they're "jist filmin' at a zoo, really". Ballikinrain has become a residence of last resort and the residents, without exception, hate the place.

They hate a place designed to provide "a safe, family atmosphere" mostly, it seems, because they have no understanding of what such a thing might be. They have been "referred" to Ballikinrain, sometimes by their own parents, because they are out of control or, worse, in need of protection. Society cannot handle them; they cannot handle society; and this Kirk residential school exists to resolve the contradiction, if it can.

The Boys of Ballikinrain, the fruit of eight months' filming by producer Peter Barber-Fleming and director Stephen Bennett, would provide the Victorians and their spiritual heirs with plenty to fret about. Cost, for one thing. Our local authorities don't spend £2500 a week per head on the multitude of children who cause no-one any trouble. At Ballikinrain there are private bedrooms, TVs, computer games, pool tables, one-to-one teaching, a new gym, a football pitch, lots of outings and numerous staff. Even elite public schools could not compete.

Nor, as some might argue, would the private sector lavish such concern on 30 boys aged eight to 12 just because they have had "difficult starts", or absentee parents, or families with problems. Generations of the law-abiding have come through trials without turning into abusive, dope-smoking brutes whose definition of gratitude, at least towards Ballikinrain, is to "jist wish the place wid blow up. Wi the staff in it".

The law and order lobby would probably have its second wind at this point. What about those parents, then? Who is holding them to account for their fecklessness? Why should society pick up the pieces for boys who dog off mainstream education because words are "too hard" and school's just "cr*p"? Whatever happened to adult responsibility? Children do not become what the Ballikinrain boys have become by accident.

On the other hand, our prisons are apparently not empty, as yet, thanks to decades of governments proud to be "tough on crime". Some policy failures are never admitted. One of the Ballikinrain staff points out in the first of three films that the boys, unaided, might cost us all a great deal more in the long run. If they fail to see the light costly residential care might follow, or costlier secure units, or prison, each sentence accompanied by expensive damage to society at large.

There is a difference, too, between bad boys and boys who have done bad things. Extreme behaviour - the dope, the drinking, the repeat offending, the violent defiance of schools and parents - has a hinterland for a Bradley, a Steven, a Ryan or a Marco. Some of the reasons are "deeply hidden", or just unspeakable. Often enough, "these boys have had to grow up quickly" without being granted the chance to grow up at all. They are traumatised, quite simply, and powerless. Things just keep happening to them.

Ballikinrain seems to operate on the principle that there is not much point in punishing the traumatised. Nor is there mileage in deploring the world. A child is traumatised: that's the present. The narration in the first episode notes, for example, that most of the boys who come to the school are not used to the countryside. Therefore, it is said, they have a tendency to seek out "hiding places" in the grounds. I wonder. When a mouthy street kid seeks refuge in a quite place beside a waterfall, something deeper is going on.

You are reminded of that, and more, when you hear that most of the boys are lonely. They miss the society that has damaged them. Their best chance is to be removed from that society, yet the only alternative is an institution, albeit with a "family atmosphere", run as a boot camp, with tight rules, named rewards and strict punishments. So these junior yobs yearn for a world that has made them unfit for the world.

Families are missed, too. One problem with the observational documentary form is that it leaves the viewer to ask the questions. Here's a 12-year-old Glasgow child whose infirm grandfather, sick with cancer, is the last vestige of the family unit. Granny is dead; his brother is in foster care; his father has "disappeared"; and there is "no contact" with his mother. Bradley was kicked out of his last residential school for assaulting staff and fellow pupils. He is out of chances.

So those of us who wouldn't touch a job at Ballikinrain with half-a-dozen barge-poles ask our questions. Did it always depend on someone's Herculean effort to keep working-class families together? Or do we face certain new and distinct problems, these days, when a parent can simply withdraw "contact" and dump a child? Or does Bradley's unnamed mother have a horror story of her own to tell? The film does not, probably cannot, say.

The Ballikinrain boys are not stupid. Some have parents who are simply heart-sore and overwhelmed by life. Some boys have problems that are subtle yet deep: every diagnosis of brighter-than-average Marco, who reeled off the acronyms flawlessly, had failed. Then, though, there are some who have been through the mill in the traditional, Victorian sense.

Paul, from Ayr, another 12-year-old, had been the victim of "emotional and physical neglect". Which meant that someone had forgotten to wash him, or to feed him, or to clothe him adequately. All his siblings were in care. Kris, his brother, was also residing in Ballikinrain. Kris was eight, and angelic-looking. His parents, as brave in facing the cameras as their children, did not seem like bad people.

But then, neither the school nor the film-makers operate on the assumption that these boys are born to fail. The world depicted in BBC Scotland's recent, equally impressive Boys Behind Bars, on life in the Polmont Young Offenders Institution, is not pre-ordained. As you work through the films in Barber-Fleming's production, horrific and inspiring by turns, you are granted a final reminder about the assumptions by which we in the safe universe live.

Social mobility is a thing of the past, we say: the circumstances of childhood are a life sentence. Income inequalities grow ever-wider, we tell ourselves, and no-one can alter that fate: the poor are always with us. The criminal class are self-selecting and self- perpetuating, we insist, and all anyone can do is pick up the pieces, segregate and punish.

The Boys of Ballikinrain is hair-raising often enough, but the making of a remarkable film, and the work of a remarkable school, are acts of resistance in the face of such alleged facts. Watch it, if for no other reason than to see these boys speak for themselves, with a certain shy courage. And watch it to see who among them can recognise the light at the end of the tunnel for what it is, and beat the odds.

The Boys of Ballikinrain, a Saltire Film, is on Monday, February 19 at 9pm on BBC2 Scotland.