The moment I step inside Puerta de Atocha – Madrid’s central railway station – I feel a familiar pang of excitement. My heart flutters, my pulse speeds, and my mood goes up a few points, much the same way that the outside temperature climbs when the sun peeks from the clouds. I am not here to greet a long-lost friend, to rendezvous with a lover, or to embark on a journey on my bucket list. I am here to take a routine, two-and-a-half hour train ride to Barcelona, for a work assignment. Yet suddenly I am happier than I’d been only a few minutes ago. Inexplicably happier.

If there is a greater thrill of travelling than the discovery of unfamiliar places, for me it’s getting there by train. Atocha isn’t the only station that turns me into a five-year-old about to unwrap a present. Over the past 40 years, I’ve boarded trains in Tashkent, Munich, St Petersburg, Bangkok and Boston and, to this day, every time I stand on a platform, I smile. When I mention this curious fact to my friends, many nod in agreement. ‘I have seldom heard a train go by and not wished I was on it,’ wrote Paul Theroux in The Great Railway Bazaar (1975), his first in a series of books dedicated to rail journeys. So what is it that draws us to train travel?

My own love affair with trains began while I was still in kindergarten. Every August since the age of five, together with my parents, I boarded a long-distance express named Sochi. It left Moscow daily at 11:59pm for a 30-hour journey that connected the capital of the then Soviet Union to Sochi, a city on the Black Sea coast. Our destination was Tuapse, a smaller town and an intermediary station on the train’s trajectory. My father’s parents lived there.

While a month-long vacation at their house was always a treat – lazy days at the beach and my grandmother’s cooking among the definite highlights – what I really looked forward to was the train. To spend two nights and a day lounging around on a bunk while eating picnic-type food packed by my mother, looking out of the window at the changing landscape and listening to strangers’ stories fascinated me equally, both as a young child and, later, a teenager.

‘If you like travel, it’s not just about the destination, it’s about the journey,’ says Mark Smith, who after years of working in the railway industry created Seat61, a website that helps travellers plan train trips. ‘The journey itself has value,’ he continues. ‘I think the food equivalent [of the opposite view] would be “I don’t care what my food tastes like, I just want to stuff my face.” Can you imagine telling a famous chef that? Well, telling me “I don’t care about the journey and I just want to get there” is a bit like telling me that.’

When Smith started the site, the typical users were either people with a phobia of flying or those who already knew they liked trains. In the past few years, however, that demographic has changed. Now the site attracts more and more travellers who’ve grown frustrated with the experience of air travel. Disenchanted with subhuman treatment by the airlines and exasperated at the time vortex of delays, cancellations and security procedures, they want something less stressful and more comfortable. But ease isn’t the only thing they find. ‘Once they try it [travelling by train], it’s like having a whole new door open in their world, a door to a whole new world,’ Smith says.

A new world was exactly what people discovered when trains burst onto the scene at the beginning of the 19th century. Although, to be fair, the history of train-like transport goes back more than two millennia. In Egypt, Babylon and Greece, goods and people were transported in carts pulled by horses or bulls. When engineers of that era noticed that animals expended less energy while travelling on pre-made tracks, they decided to construct roads with built-in ruts for wheels. The remains of these ancient railway prototypes, called wagonways, can still be found in Italy and Greece.

With the fall of the Roman Empire, wagonways disappeared from use until the 18th century, when almost all mines in Britain had laid tracks to help horses pull coal from mines to factories. Then came the invention of the steam engine, and by the late 1820s a commercial network of railways began spreading through the country. It sped up the march of industrialisation and secured for Britain a spot as the world’s dominant economic power – at least for a time. Ultimately, the steam engine brought its clouds of misty smoke to continental Europe as well as Russia, India and the United States.

In addition to creating an economic boom, the spread of railways had a significant social impact. At first too expensive for the average working man in England, rail travel became affordable after the 1844 Railway Regulation Act, which required all train companies to supply at least one daily train at prices many could afford. ‘There was virtually no aspect of 19th-century life that wasn’t affected by the railway,’ says Christian Wolmar, a railway historian and author of The Iron Road (2014). ‘A day at the seaside became possible, people were able to visit their local market town, and later on we got sport events being created by the railways. And, of course, the produce. The one example I like is milk. Milk in London was produced by cows living in basements until they developed refrigerated trains to carry milk, and cows could be moved out of central London.’

‘Trains were made for meditation,’ said the British poet laureate John Betjeman

The US saw its own share of social changes influenced by railways. Largely responsible for the great migration west, trains blurred the line between public and private. ‘Train travel requires people to do private things in public,’ says Amy Richter, a historian at Clark University in Massachusetts and the author of Home on the Rails: Women, the Railroad, and the Rise of Public Domesticity (2005). ‘And what’s fascinating about it is the possibility of being able to observe strangers. For women in particular who don’t have a lot of geographic mobility in urban spaces, riding on a train is as close as they can get to that flâneur experience of urban life – where you can sit and you can watch people and you can eavesdrop on conversations.’ Railways became public spaces where 19th-century US women legitimately claimed their place beyond the home.

Still, in the beginning, people were suspicious. Called the ‘device of the devil’ in the US and thought of as a potential source of damage to eyes and breathing in Britain, railways elicited fear. In Russia, which built its first line in 1836, train transport became synonymous with progress, which lacked soul and prioritised haste over contemplation. ‘Railway to travel is what the brothel is to love – just as convenient, but at the same time just as machine-like and just as monotonous,’ wrote Lev Tolstoy to Ivan Turgenev, a fellow Russian novelist, in a letter in 1857. Convinced that this new technology propelled his beloved Russia away from the purity of its traditional life into the abyss of speed, callousness and hebetude, he made trains the setting for both trouble and tragedy in Anna Karenina (1878).

Fast-forward a century and a half, and the monotony that Tolstoy loathed has become the antidote to progress rather than its derivative. ‘Trains were made for meditation,’ said the British poet laureate John Betjeman in 1940. Michael Williams, a British journalist and the author of The Trains Now Departed: Sixteen Journeys into the Lost Delights of Britain’s Railways (2015), echoes him. I spoke to Williams a few days after he’d returned from a journey that took him from his home in London to Hannover in Germany. Travelling exclusively by railway, he changed three trains and spent almost the entire day in transit. Still, he said, it was worth it. ‘There is something rather serene about a train journey,’ he explained, ‘a kind of mellowness. You can contemplate the landscape in a way that you cannot from any other type of transport.’

Contemplation was one of my favourite activities on the Sochi express. ‘Don’t interrupt me, I am thinking,’ I said to my grandfather once when he asked me something at an inopportune time. I was six and entirely consumed by the view outside of the compartment’s window. Our annual trip traversed almost the entire depth of the Soviet Union from north to south – and I watched the country go by from the top bunk, my head propped up by a pillow. Small villages with their wooden houses straight out of fairytales, country roads that cut through the fields and reminded me of Pushkin’s ballads, barefoot children running along the tracks and waving to the train. Seeing them allowed me to discover the parts of Russia I otherwise would never have known, and to ponder where and how I fit into its expanse.

In contemplation, as in travel, we construct ourselves. With everyday minutiae gone at least temporarily, and with scenery providing the backdrop so essential to introspection, we find the time to reflect. And while other forms of transport take away from this process, either by their sheer discomfort (think planes) or considerable effort (think driving), trains inspire it. ‘You are part of the constant process of the breaking and making of links, which is an element in the constitution of you yourself,’ wrote Doreen Massey, a British social scientist and geographer, in For Space (2005). A forgotten luxury in a society that moves with the speed of a viral post, this process of constituting ourselves has space to spark, germinate and unravel – only on a train.

The links we build while crisscrossing kilometres of land aren’t limited to those within us. We connect to places we pass: either through a quick glance at a railway station whose relationship to its city is palpable even from a distance, or as we buy snacks and engage in smalltalk with locals at intermediate stops. On the Sochi – as sometimes now on the Trans-Siberian Railway – whenever we stopped at smaller stations, a constant trickle of local vendors went through the cars. Old ladies in kerchiefs with baskets full of freshly made pirozhki – savory or sweet pies – shuffled by our compartment, closely followed by sturdy women in aprons selling apples, plums or peaches. The smell of their wares along with their accents and the affection with which they called their customers dochen’ka or synok – diminutives for ‘daughter’ and ‘son’ – invaded the train and lingered long after we pulled away from the station.

When, several years ago, I returned to Russia after a long absence, I booked a 24-hour train journey for myself and my eight-year-old daughter from St Petersburg to Odessa in Ukraine. I wanted her to experience what I remembered: a whole day together, an uninterrupted passage of hours filled with books and conversations, an opportunity to spend time entirely on ourselves, by ourselves, and with ourselves. Just like my mother more than 30 years earlier, I packed boiled eggs, tomatoes, cucumbers, bread, cheese and apples. We ate all three meals together without television, telephone or the internet. When the conductor brought tea – much like I remembered from the Sochi express times, with two cubes of sugar, in a classic railway cup – we drank it with sweets we bought at an intermediate stop, looked out of the window, and talked.

The lengthy duration of a train ride – without being confined to a seat as in a bus or a plane – also leads to creating a community we otherwise wouldn’t have formed. Away from the familiar, this accidental collection of others offers us the potential to satisfy our curiosity about people, forge shared experiences, and form fleeting friendships. When we travelled on the Sochi, these conversations with strangers powered the journey not unlike the electricity that pushed forward the locomotive. The first question that occupied our minds after boarding as we stowed our suitcases was who would claim the fourth bunk in our compartment. We placed bets on whether it would be a man or a woman, a younger person or an older babushka, a talker or a quiet companion. In a microcosm of community thrust together for 30 hours, neighbours mattered. Whether or not our fellow traveller snored was of much less importance than what kind of person they were going to be.

Looking out of the window or reading while rhythmically swaying to the clackety-clack of the wheels recuperates the parts of us we neglect and miss

This potential to interact, connect and, as a consequence, to discover has been explored in countless novels, movies and even commercials. In Murder on the Orient Express (1934), Agatha Christie sets the action on the luxurious train that caught her imagination enough to act as the only setting for the novel. In North by Northwest (1959), Alfred Hitchcock uses the 20th Century Limited, an express passenger train on the New York Central Railroad, as the setting for some of the major themes. And an AT&T commercial from 2010 shows how the parents of a future president met each other by accident on a train. Just as narratives that take place on planes emphasise our fears and discomfort – of a crash, as in the movie Flight (2012), or of a soulless, hurried and empty existence like in Up in the Air (2009) – stories on trains often speak of romance, friendships and connections.

‘My parents met on the train,’ said one of the commenters to a question I posed on my Facebook wall. For an informal poll on whether my friends preferred rail, plane or car travel, I asked them to choose their favourite and explain the choice. Out of 33 comments, 28 chose trains. Reasons they cited run the gamut from comfort to the views, from romance to the ability to interact with people, from the time afforded for thinking to the chance to unwind and just be.

A P Herbert, an early 20th-century English playwright and novelist, said: ‘Slow travel by train is almost the only restful experience that is left to us.’ If, at the dawn of railway development, the speed was what sparked people’s fascination, today it’s the relative slowness of trains that attracts us. Their actual velocity aside (for modern fast-speed trains are anything but sluggish), what we crave is their potential of slowing down our lives, of allowing contemplation, and of spurring bonds both within ourselves and with others. ‘Things that seemed problematic in the 19th century – sitting around strangers and being drawn into conversation – are now experiences tinged with nostalgia,’ says Richter. This feels like ‘something that’s been lost’.

To say that today we live in an interconnected world is both a cliché and an understatement. Yet our ability to plug in and reach out to anyone hasn’t really fostered deep connections either with ourselves, with others or with the world around us. Trains offer a chance to correct that. The experience we create when we take the time to look out of the window, start a conversation with a stranger, connect with a family member or simply read a book while rhythmically swaying to the clackety-clack of the wheels helps recuperate the parts of us we neglect and miss.

When I come back from Barcelona, I plan another train journey, this time for pleasure. My daughter and I still reminisce about our trip to Odessa so I look into booking an overnight train from Madrid to Lisbon for the two of us. With most days spent navigating the Scylla and Charybdis of teenagedom, we can both use this time and space to retread.