For his ninth birthday I bought my son Frank a bike. A hundred and fifty quid and I knew it was a mistake even at the time. I don't understand the concept of a boy's bike in 2005. Over what stretch of public road are the full possibilities of those 16 gears to be tested?

I had the vague idea he might ride it on Hampstead Heath, which is not far from our house, but the first time he did this a donnish-looking man told him to get off it, as he'd strayed from one of the few paths on which you are allowed to cycle. So now we walk across the heath instead: Frank, his brother Nat and me. I inspect certain likely-looking trees as we go. I am looking for nails, which might mark a route up the tree for any agile boy. I never see them.

When I was a boy, growing up on the edge of York, every tree had its nails, left in like crampons on an ice face. They were a communication from boy to boy at a time when the pre-pubescent male still had his place in the world.

I had a bike, or more accurately about 15 in the course of my boyhood. They got worn out: I mean, you can only get so much mileage out of a second-hand Elswick-Hopper with threadbare, whitewall tyres. When I arrived at my destination, I would throw the bike down as casually as a cowboy dismounts from his horse, and I'd be just as confident that it would be there when I returned.

I played outdoors every night of the week. My father, a widower, would say: "I want you out of the house." Three hours later, he'd see me again. I would come in exhausted, drink a long glass of water, burp violently while parking the glass unwashed on the draining board, and proceed upstairs for a bath. I was required to fold my clothes neatly, during the course of which I would pick the twigs out of my jumper.

In the bath, I would review the latest scabs on my knees before lowering them slowly beneath the Matey bubble bath. Out of sight, out of mind - that was the best way with knee wounds. The idea that you might be able to go for an entire day without in some way drawing blood from at least one of your knees ... well, it was conceivable, but only just.

I did not have a country childhood in the grand, romantic sense. My territory was the stretch of scrubby fields, copses, ditches and quiet roads between south-east York and the outlying villages. In the intervening 30 years, York's population has all but doubled, and the city has now incorporated those villages, the only barrier between town and over-developed country being provided by the foul ring road.

But in my day, they were lonely enough spots, as proven by the stashes of rain-sodden pornographic magazines in the ditches. We might ride our bikes along those roads four abreast. Occasionally one of us would shout out, "car's coming!" and we'd proceed self-consciously in single file, allowing some berk in a Morris 1100 to putter by. But it felt priggish to ride a bike like that, and we'd soon bunch up again, talking and disputing, like a little parliament on the move. It was the modern world in some senses: Top of the Pops, Radio 1 around the clock, and yet you lived with the seasons: the smell of cut grass, brambles, conkers, a muffled gratefulness, come spring, at the lengthening days.

"Pure nostalgia!" I hear the cry, and I admit that my memories do seem to accord to an ideal of boyhood as depicted in various books from Huckleberry Finn onwards. Its main British manifestation is in the William stories of Richmal Crompton, begun in 1919.

William roams free, in a land comprising, as Crompton's biographer, Mary Cadogan, puts it, "manor house, village and church halls, workmen's cottages, dogs and ditches ... it is surrounded by the proper quota of irate farmers, muddy fields, crumbling barns, woods and cows." He is, according to Cadogan, "the archetype of the adventurous, outdoor boy"; a noble savage who proclaims in response to his mother's urgings: "I don't want to behave like a civilised yuman being." And yet I lived his life, or a dowdier version of it, when I was 10, and the inter-war development of suburbs meant that boys of my generation could taste something of the freedom described in the stories.

William's HQ was at the Old Barn. Here, he meets his mates, the Outlaws. There's usually no very definite plan of action: "'What'll we do this morning?' said Ginger. It was sunny. It was holiday time. They had each other and a dog. Boyhood could not wish for more. The whole world lay before them."

The Outlaws are a gang, and Cadogan reminds us that Baden-Powell, founder of the Boy Scout movement, regarded the gang as the best social unit for a boy. But a boy's gang in the country is one thing to the public mind; a boy's gang in a town is another, and the William books can be seen as reflecting an anxiety about the moral effects of urbanisation that had been growing since the industrial revolution. The street gang was demonised at the turn of the 19th century, just as it is today, only where once the objection was to harmonicas and narrow-go-wide trousers (the sure sign of a cockney ruffian) today it is mobile phones and hooded tops.

But when I look at old photographs of boys in Edwardian inner cities I am torn between a horror at their gloomy, brick-bound world, and an admiring wonderment at the way a football game played, say, in the East End in 1910, might range across a whole street. I'm not saying that the lack of cars makes up for the lack of boots on some of the boys' feet, but the motor car is the anti-boy factor that is common to inner city and countryside.

Aside from having killed many boys, the motor car has also killed British boyhood. It and an exaggerated fear of crime make most boys housebound for most of their leisure time. They become prematurely like their fathers: stressed-out, trapped in front of an eye-burning screen, ruthlessly targeted as consumers. And in this equivalence between boy and man we begin to see a reversion to the days before the notion of childhood as a discrete way of life took root.

Boys are like dogs: they need to get out and be walked. At any excuse, I take my sons to a wide open space. A beach will do very well. Many middle-class parents of boys try to make permanent this escape into physical freedom, but you have to hand it to the motor car: it doesn't discriminate between rich and poor. The barrister, his wife and their young son move to the country but the motor car has killed the village, so they have to drive everywhere and the boy becomes a querulous voice from the back seat: at once tyrant and victim.

It's strange, given their fatal consequences for boyhood, that cars should often be referred to as "boys' toys". The word "boy" is being taken away from boys, to be used as an arch substitute for "man". Footballers have a "bad boy" reputation; and what did that Wonderbra advert say? "Hello boys." To a real boy, the proffered breasts of Eva Herzigova would be of little interest, except possibly as a biological curiosity. I know one four-year-old boy who looked at his teacher's cleavage and said, "I can see her lungs!"

When it comes to girls, most boys surely take the William line: "They can't play fair or talk sense." Yet many of the products aimed at boys are trying to hustle them on to puberty as fast as possible. Once you've got sex in the equation you can sell a magazine, market a car and target any product. Whereas boyhood ... Well, what is that? It's beginning to seem an increasingly mysterious, abstract realm, something existing frozen in time on the covers of the William books, like a distant, slightly troublesome memory, or a reproof to the way we live now.