The Programmer's Longevity Guide: Living Longer as a Math Problem
Source: the open-source project HowToLiveLonger (geekan/HowToLiveLonger) — every number below comes with an academic citation in the original. Translated and adapted by this site.
Sitting all day, all-nighters, takeout, bubble tea — the programmer's standard four debuffs.
Someone turned "how to live longer" into a math problem. There is exactly one objective function: all-cause mortality (ACM). Every recommendation is tagged with "cuts ACM by X%", and every number links to a paper.
Three caveats before the numbers seduce you:
- These are correlations from observational studies, not proven causes. People who walk 7,000 steps a day live longer — or maybe the chronically ill simply can't walk that much.
- Numbers don't stack. −47% plus −54% doesn't get you below zero; the variables interact.
- Contested claims are flagged, not hidden.
Below: the parts most relevant to programmers.
Key takeaways
What is the one objective function of longevity?
All-cause mortality (ACM). This guide treats living longer as a math problem: every recommendation is tagged with how much it cuts ACM, and every number links to an academic paper. Percentages don't add up — risk factors interact — but they rank the levers honestly. Source: geekan/HowToLiveLonger, translated and adapted by this site.
Which lever matters most: diet, exercise, or sleep?
Exercise, by the mortality math. 150–300 minutes of brisk walking a week is linked to about 30% lower all-cause mortality; 7,800 daily steps to roughly 45% less than 3,500 steps. Diet and sleep still matter — five daily servings of fruits and vegetables run about 13% lower mortality than two — but movement is the king of value.
How much sleep do I actually need?
About 7 hours a night, ideally starting between 22:00 and midnight. Both short and long sleep are linked to higher mortality — the curve is U-shaped, not ‘more is better.’ Consistency beats weekend catch-up: a regular bedtime stabilizes the circadian rhythm that governs blood pressure, glucose, and immune function.
1. Eat: the input side
Staples
- Vegetables and fruit first (−26%~−17%); white meat instead of red (−11%~−3%). Two-plus servings of red or processed meat per week: +3% all-cause risk.
The power trio
- Spicy food (−23% — people eating spicy 4+ times a week had 23% lower total mortality)
- Nuts (−27%~−4% — a small handful a day)
- Moderate carbs + plant protein (−10%)
- Go easy on ultra-processed food (chips, burgers, chocolate and the like).
Drinks
- Coffee (−22%~−12% — 2–3 cups a day is the sweet spot), tea (−15%~−8%), milk (−17%~−10%)
- Sugary drinks are the disaster zone: each extra cup a day, +7% all-cause mortality; two cups a day, +21% total death risk.
- Quit alcohol — otherwise +50% ACM, no upper bound.
Smoking
- Don't smoke — otherwise +50% ACM and 11–12 fewer years on average. Light smoking is harmful too; there is no "moderate" smoking.
2. Move: the output side — king of value
- Racket sports: 3× a week, 45 minutes each — −47% ACM. The single best-value exercise on the entire list. Badminton, table tennis, tennis all count — and badminton is probably the easiest game for programmers to organize.
- Walking: 7,000+ steps a day. A decade of follow-up in a JAMA journal: step count strongly tracks all-cause mortality.
- Sitting: each extra hour seated: +4% cardiovascular risk, +3% all-cause mortality. Over 6–8 hours a day is the danger threshold. When the Pomodoro timer rings — actually stand up.
3. Sleep: 7 hours, between 22:00 and midnight
- Data on 300,000+ Asians: 7 hours a day has the lowest all-cause mortality. Over 10 hours: +34% for men, +48% for women.
- Bedtime is contested: one Canadian study says 22:00–midnight is best — before 22:00 was +43%, after midnight +15% — but it relied on self-reports and the authors admit the limits. My take: don't stay up late, but don't stress yourself into bed at 9pm either.
4. A few counterintuitive ones
- Sunlight: −40% ACM. A 26-year Danish study: more sun, significantly longer life. What programmers lack most — grab lunch downstairs and get 15 minutes.
- Brushing teeth: −25%. A 500,000-person Chinese study: poor brushing, +25% premature-death risk. Two minutes, twice a day — possibly the cheapest longevity move there is.
- Hot baths: a daily hot bath — −28% total cardiovascular risk, −26% stroke.
- Weight: going from obese to overweight — −54% ACM, the most dramatic single number on the list. Losing weight moves the needle more than most "wellness hacks."
- Mood: pessimism tracks with higher all-cause mortality, but "forced optimism" shows no protective effect. Less rumination beats more chicken soup.
5. Honest disclosure
The original author listed four methodological warnings; reproduced verbatim:
- lifespan vs. ACM is nonlinear — his conversion formula is open to improvement;
- variables can't simply be stacked; they aren't independent;
- some papers directly contradict each other (e.g. carb ratios);
- all studies show correlation more than causation.