For years, dieters have had to deal with a lot of conflicting advice on how to eat.

First, fat was the bad guy. Then it was considered ideal to avoid sugar and go low-carb.

Lately, dieters trying the trendy ketogenic diet have discovered that if they replace carbs with fat, they can trick their bodies into a natural starvation mode and lose weight, while still enjoying bacon and slurping heavy cream.

But a new, long-term study published Thursday in The Lancet suggests there may be a winning formula for the amount of carbohydrates to eat every day. It relies on some very unsexy, old advice: everything in moderation.

Lead researcher Sara Seidelmann, a cardiologist and nutrition researcher at Brigham and Women's Hospital in Boston, told Business Insider that her results suggested a diet "rich in plant based whole foods such as vegetables, whole grains, legumes, and nuts is associated with healthy ageing."

That usually means about half of the calories you eat in a day should come from carbohydrates.

A Goldilocks rule for carbs

For the study, Seidelmann looked at the diets of more than 15,400 adults in the US and another 432,000 people in more than 20 countries around the world. She and her team of researchers analysed that information in relation to how long the study participants lived.

They found that people who ate a moderate amount of carbohydrates – around half of their daily calories – tended to live the longest.

Conversely, people who derived more than 70 percent of their energy from carbs or got less than 40 percent of their daily calories from carbohydrates were more likely to die than people who ate something in between.

It's a kind of Goldilocks finding: we should eat not too many carbs, not too few, but just the right amount.

On one end of the spectrum are people who suffer health consequences from eating too many carbs, like in some lower-income countries where people tend to rely on white rice for sustenance without much else on their plate.

On the other end are people who consume not enough carbs. Surprisingly, the group at highest risk of death in the US study were those who didn't eat carbs, since those people tended to replace carb-heavy foods with animal fats and proteins: "beef, pork, lamb, chicken, and cheese," as Seidelmann put it.

"Clearly, filling your plate with those things increased mortality," she said.

In fact, the researchers concluded that a 50-year-old who eats within the 50-55 percent carbs margin could expect to live for another 33.1 years, while someone the same age who gets just 30 percent of their calories from carbs would be expected to live roughly 29.1 more years.

The important part is getting as many whole, healthful foods onto your plate as possible

There is a way to do a low-carb diet and age well: people who ate small amounts of carbohydrates but more plant-based proteins like veggies, seeds, and nuts were found to be less likely to die and tended to live to a ripe old age.

This might be because eating large amounts of animal fat and protein but few fresh plant-based foods can increase inflammation in the body.

"Try to make choices that fill your plate with plants," Seidelmann said.

She agrees there's a short-term link between low-carb diets and weight loss, but cautions that diets like keto and Atkins might not be great long-term strategies.

"There's absolutely nothing more important for our health than what we eat each and every day," she said. "I really would like individuals to realise the power that they have over their own health," she said.

This article was originally published by Business Insider.

More from Business Insider: