# One man's look at The Hacker's Diet

This article by Dan Polansky looks at the book The Hacker's Diet by John Walker, a cofounder of Autodesk (makers of AutoCAD) who is an engineer by love and a manager by necessity rather than an audiovisual media celebrity. The book is freely available online in a HTML edition; other editions are available. This article shows weight loss data for Dan Polansky as a real-world example.

## Key principles

Key principles espoused by the book:
1) The only way to lose weight is to create energy deficit, that is, a condition in which the energy income is less than the energy consumption.
2) Exercise is useful for health, but it alone can hardly help in losing weight. The key intervention is regulation of food intake.
3) Weight measuring contains noise created by changing content of water in the body. Thus, a naive observation of the weight development may create false hopes and false despair as a result of a direct emotional response to changes visible in raw data. To overcome this problem, one may weigh daily but calculate a moving average, and then respond not to changes in the raw data but rather in the moving average. Excel is great for the purpose, but a slip of paper and a calculator does the job as well if one uses exponential moving average.
4) It pays off to have an idea how much energy (kcal or kJ) various food items contain.
5) It pays off to have an estimate of one's daily energy consumption. It depends on sex, frame and overall level of physical activity.
6) One does not have to pay close attention to food composition: a kilojoule is a kilojoule, and the deficit depends on kilojoule content and nothing else. One may want to pay attention for health reasons, but as for losing weight per se, it does not matter.
7) Eating vitamin supplements is unlikely to harm and mitigates the risk that nutrient intake is going to be impaired or skewed during the diet.
8) Somewhat counter to point 6), it pays off to eat low-energy food to fill stomach such as vegetables. One does not have to, but doing so creates a pleasant feeling of full belly without incurring the energy income cost.
9) It pays off to be clear about motivation. Fat people die earlier on average and have poorer health. Moreover, there probably exists a prejudice against fat people.
10) The start of the dieting is a bit more difficult. There is a delay before the body starts burning fats; at first, it slows down metabolism. Once the body switches to the fat burning mode, keeping the regime becomes much easier.
One is well advised to go beyond this summary and read the book.

## Dan Polansky's daily weight change chart

The following is a chart of weight loss of Dan Polansky using Hacker's Diet. One may get an idea to what extent the raw weight is subject to noise/daily fluctuation and what daily rate of weight loss can be comfortably sustained.
The peak weight loss rate calculated from the exponential moving average is about 130 g per day, but 70 g per day is more typical. This was achieved--as crude estimate--by reducing income from about 8000 kJ/day to about 6000 kJ/day.
The data is available in the plotting code in File:HackDietDP.svg.
Tip from personal experience: From what I remember, I (Dan Polansky) recorded the numbers on paper slips daily and transferred them to a spreadsheet only once in a while.
The exponential moving average (ema) is calculated using the coefficient 0.05. Thus, the ema of the day is calculated as 0.05 * day's weight + 0.95 * previous day ema.

## Energy content in various foods

One can often find energy content on food packaging. Moreover, the book has a chapter that contains this information, in calories (1 calorie = 4.184 kilojoule).
Haphazardly selected items in kJ, for orientation (not from the book):
* Chocolate: 2000-2400 kJ/100 g
* Fried potato chips: 2000-2400 kJ/100 g
* Nuts: about 2500-3000 kJ/100 g
* Bread: 850-1000 kJ/100 g
* Cheddar cheese: 1680 kJ/100 g
* Edam cheese, low-fat: 1000 kJ/100 g
* Lean ham: 400 kJ/100 g
* Egg (can have 50-70 g): 650 kJ/100 g
* White low-fat yogurt: 170 kJ/100 g
* Low-fat quark: 280 kJ/100 g
* Banana (one can have e.g. 100 g): 371 kJ/100 g
* Apples (one can have e.g. 120 g): 218 kJ/100 g
* Carrot: 173 kJ/100 g
* Lettuce, cos or romaine: 72 kJ/100 g
* Coca-Cola: 157 kJ/100 ml
One can also consider the components sugars, fats and proteins; among these, fats have the highest energy density per mass. As per FAO, "The energy values are 17 kJ/g (4.0 kcal/g) for protein, 37 kJ/g (9.0 kcal/g) for fat and 17 kJ/g (4.0 kcal/g) for carbohydrates.
Links:
* Calories in Various Foods, fourmilab.ch

## Minimum energy intake

As per Harvard Health, men/women should not reduce their energy intake below 1,500/1,200 calories a day, except under the supervision of a health professional. That amounts to 6,276 kJ for men and 5,020 kJ for women.

## Excel

One may track progress in Excel as follows:
* Enter "Date" into cell A1, "Weight" into cell B1 and "Weight (EMA)" into cell C1.
* Keep entering dates into column A and measured weights into column B, starting from row 2.
* Enter "=B2" into cell C2; thus, do not calculate exponential moving average for the first value but merely copy the current weight.
* Enter "=0.05*B3+(1-0.05)*C2" into cell C3. This creates exponential moving average with coefficient 0.05. Put differently, the current value of the EMA is the weighted average of the current value of the body weight and the previous value of the EMA.
* Spread the formula from cell C3 to other cells in column C.
* Create a line plot for the region A2:Cn, where n is the last filled row number. Thus, plot both the raw weight and the smoothed weight.
* Observe the trend and adjust food intake if unhappy with the trend.

## Units

In this article, we are using metric units, that is, kilojoule and grams. In the U.S., one usually uses imperial units, including "kcal". Curiously, in the context of food and nutrition, the unit referred to as "kcal" is often called "calorie", with nothing to correspond to "k". John Walker uses imperial units. For conversion, 1000 kJ = 239 kcal, and 1000 kcal = 4184 kJ. For volume, John Walker uses fluid ounce ("fl. oz."), which is 30 ml per US food labelling. Thus, the value 12 fl. oz. used in the beverages section amounts to 360 ml.

## Dan Polansky's weight loss in 2024

In 2024, I (Dan Polansky) tried to use The Hacker's Diet approach to losing weight again. I started on 3 March 2024 having 88.5 kg of weight; on 27 October 2024, I had 77.5 kg of weight. Thus, I lost about 10 kg of weight.
I did not plot the measured weight. I measured the weight rather infrequently (at most once per week), recording it on a slip of paper. I did not use a spreadsheet in any way. Thus, the approach was rather non-technological and simple. It turned out to work well enough.
Dietary adjustments I made:
* I dropped margarine. Rationale: high-energy food with probable low nutritional value.
* I added eggs. Rationale: eggs are likely to be good package of nutrients. A hen egg has all the nutrients that a chick requires before it hatches.
* I dropped nuts. I did it hesitantly: while nuts are high-energy food, they are reported to be of good nutritional value.
* I dropped white rice in favor of German whole-grain rye bread Mestemacher, richer in fiber. Moreover, I do not like Mestemacher all that much, which reduces the temptation to overeat.
* I dropped the Czech white bread in favor of German whole-grain rye bread Mestemacher, richer in fiber. I seem to like the Czech white bread together with margarine a lot, a problem: I then need to enforce quantitative limits and it is easier to impose a total prohibition.
* I used a vitamin supplement, to be on the safe side.
* I prohibited myself from uncontrolled buying of sweets, potato chips and similar food items. The only exception was a 21 g sweet bar bought approximately twice a week.
The regime did not take much will or enforcement. I did not have to struggle against myself to keep it.