I lost 100 pounds once thanks to a database. This was before the “quantified self” movement, and there were no Fitbits or Fuel Bands to rely on, so I had to devise my own solution. I built a web site that let me observe every calorie and total up how much I’d eaten, and exercised, throughout the day. On good days I would stay under 2,100 calories (adjusted for exercise expenditures), and on bad ones I’d get a cautionary red number to tell me that I’d crossed the threshold. It worked really well, until it didn’t. I named it ohlih.com: One Huge Lesson in Humility.

I built that site six years ago. My life had gone pretty sour. My career was stalled, and my wife and I were, after years of trying, still unable to have children. I was drinking a bottle of wine a day, smoking, too, and I couldn’t get my eating under control. I must have gotten near 400 pounds, although who knows—when you’re up that far you don’t jump on a scale too often. One night, I looked at some pictures of myself on Facebook from a Fourth of July party. I’d gotten into some pie that evening and felt guilty about my second helpings. It seemed to me that I was simply a vehicle for the expression of a multitude of compulsions. More specifically, my true self, whoever that person was, had been lost—all filling, no crust.

I read articles, web sites, and books in search of expert guidance. This was depressing. No matter how I tried to lose weight I would be letting some people down. The fat-acceptance folks were sure it was oppression that kept me from celebrating my fleshly self. They wrote essays about the politics of airplane seats and “health at every size.” For them, dieting was counterrevolutionary. The new-agier types talked up colonics and cleanses. I considered these but my imagination overwhelmed me. Some doctors seemed to be saying that weight loss was basically impossible. Others recommended therapy before reduction. The Atkins bubble had popped so I wouldn’t be trapped in a purgatory of steak. The burgeoning paleo movement advocated for pork chops and greens. And everyone agreed that the caloric model of nutrition was a cultural disaster, a great lie—that food was more than numbers. My body was a battlefield.

Calories, even if wrong, I could understand. I knew how to program a computer, so I went with calories, with the thesis that although I couldn’t manage myself from moment to moment, a machine could. So I built the site. I used the programming language Python and wrote some code using a framework called Django (named for the musician) that makes it very easy to construct a database.

To create the kind of application I wanted required a firm definition of my model of the world. This is good. Simple. Everything could be divided into events and energy. Breakfast, for example, was an event, during which I’d add energy to my body, in the form of pancakes or eggs or, as was increasingly likely, high-fiber cereal with skim milk. Every food that I added to my database was an energy source, and I assigned it a certain number of calories. Riding a bicycle, meanwhile, was an event, one for which I’d use the energy in my body; I associated it with a negative number (-500 calories per hour). After each event, I’d hurry to a computer and log what happened. This was my system.