Spending many hours programming is hard. It is mentally exhausting.
Focusing on the same thing for hours on end, it is not natural. While you are focused, your brain is consuming large amounts of energy. If you want to be the best programmer you can be, you need to train your body to process food into energy faster and longer. You need to push your metabolism and endurance to their limits. A split second of distraction can cause you to forget important aspects of the problem you are working on, and lead to hours of wasted effort.
To maintain mental clarity, you need to pump calories to your brain as quickly as possible. Your diet needs to be optimized to allow for this.
To maintain consistency, you want to keep the amount of energy flowing in your blood to your brain consistent. If your blood sugar spikes, this gives a very short term benefit, and then your insulin causes your blood sugar to drop, and your brain chokes from a lack of energy.
So to focus for long periods, it is best to avoid carbohydrates, especially simple sugars. Humans have a limit to how much protein they can efficiently process in a day, something like 80-150 grams, depending on how much you use your muscles and your personal genetics. So, you will need to get the majority of your calories from fat.
There are 2 principal forms of calories that your blood transports. Your blood can send sugar to your brain, and it can send cholesterol to your brain. Sugar comes from breaking down dietary carbohydrates, and from breaking down stored carbohydrates from your liver and muscles. Cholesterol comes from breaking down dietary fats, and from breaking down the fat stores in your body.
On the days when you program a lot, you are using a lot of energy. If you don't increase how many calories you eat, you will lose weight, and eventually choke your brain from lack of energy.
You want to train your body to use fat calories instead of carbohydrate calories. One strategy to accomplish this is called "intermittent fasting". It can take different forms. A simple strategy is to limit yourself to only eating once per day. An easier strategy is to only eat during a 8 hour period during the day.
A strategy to help your body adjust to using fat calories instead of carbohydrates, you can do cardiovascular exercise after a period of fasting. I do my daily run in the morning, before eating anything that day. By combining fasting with endurance exercise, you can completely consume the carbohydrates in your body, and force your body to start burning fat.
Besides calories, the human body needs about 30 essential vitamins and minerals to survive. Being deficient in any one of them can negatively impact your ability to program.
The most common nutrient deficiencies in the modern world are magnesium, calcium, iodine, vitamin D, and iron.
Sodium, magnesium, potassium, and calcium are electrolytes. Electrolytes are essential for your nervous system. Your nerves are able to send signals by creating ions from calcium and sodium, and storing the ions inside the nerve to create an electric potential, so your nerve can send a fast electrically powered signal. Your brain is a part of your nervous system. The process of thinking, it is mostly made up of creating and releasing electric potentials. It is critical that you consume enough sodium and calcium so that your brain can think.
Every cell in your body is using mitochondria to transform the sugar or cholesterol it receives from your blood into the ATP which is used to power cellular processes. Mitochondria are able to produce ATP by creating calcium ions and storing them inside of a membrane, so that there is an electric potential. If you don't have enough calcium, then the cells in your body can't process energy efficiently. Your brain wont get as much energy as it could be getting.
Magnesium is an ingredient for many enzymes. Enzymes are important tools for creating the complex proteins that make up the human body. So that your body can produce muscle and nerve tissue, and so you can process energy, and much more besides. You need magnesium to be a good programmer.
Because of modern agriculture techniques, the land has been stripped of magnesium and calcium. A standard diet will probably not give you enough of either.
A lot of people get their calcium and magnesium from their drinking water. If you live in a place with soft water, then you are not getting calcium or magnesium from the water, so you need to be more concerned about whether you are getting enough.
A good way to get calcium and magnesium is from making soup out of bones. After a couple hours of boiling, many bones become soft enough to chew up and eat. Small fish can be eaten whole, along with the bones. This is a good source of calcium and magnesium as well.
Iodine is essential for the health of your thyroid, which is the human organ that maintains your metabolism. Your metabolism is the system that controls how quickly you are processing energy. If you don't get enough iodine, your body will not be able to efficiently pump calories to your brain, and your ability to program will be impacted. There is iodine in seaweed and in the soil near the ocean. If you are eating food produced far from the ocean, then you need to be more concerned about whether you are eating enough iodine. Salt is often fortified with iodine. At typical concentrations of fortification, you would need to eat something like 10 grams of salt per day to get enough.
Vitamin D is produced in your body from cholesterol in your blood. Your skin uses sunlight to transform cholesterol into vitamin D. Vitamin D is the basis of many hormones that your body produces. These hormones are essential for maintaining your metabolism, so you can process calories quickly and efficiently, and give your brain the energy it needs. If your skin is darker colored, or if you live far from the equator, or if you live somewhere that is often cloudy, it is harder for you to get enough vitamin D from the sun. If your blood doesn't have enough cholesterol, then your body can't produce as much vitamin D.
Iron is used to create red blood cells which transport oxygen to your brain. Your brain needs oxygen in order to unlock the energy from the food you eat. Your body is like a fire burning food, fire needs oxygen to burn. Iron deficiency is especially problematic for women, because women lose blood and iron when they menstrate. If you are a heavy bleeder during menstration, you need to be more concerned about iron in your diet.
You need to be well hydrated to think properly. Your kidneys need water to filter your blood and keep your electrolytes in balance. Your blood needs water to flow and send oxygen to your brain. Your body needs water to maintain the correct temperature. Drinking water should be one of the first things you do after waking up from sleeping, and you should drink more every couple hours all day long.
A healthy diet can be very cheap. The tools you need are: a chef's knife. Something to sharpen it with. A cutting board for vegetables, and a second one for meat, if you eat meat. A large pot to boil water in. A big spoon to stir the pot. A hot plate or stovetop. A big mixing bowl.
When you are cutting, put a wet cloth under the cutting board, so it wont slide around. Sharpen your knife every time you use it.
The basic idea of cooking is that you heat some water in your pot, and you keep chopping up and tossing in ingredients. Starting with the ingredients that need more time to cook, like bones or hard pumpkins. Put in the final ingredients as you remove it from the heat, like herbs. Mix in your salt and lard or oil into the individual bowl while serving.
It is a good idea to maintain a container of sour krout (also called kimchi), because this will sustain the bacterial flora in your gut, and it is a very cheap and low effort way to get a lot of nutrition, and it reduces how frequently you need to buy fresh vegetables. Chop up crunchy vegetables that can be eaten raw, like cabbage, cucumber, or carrots. Optionally include chile if you like spicy food. Mix in a big bowl with salt. Jam into a container, with just enough water to submerge it all, and put some plastic over the top, against the water, so air wont touch the water. The bacteria will break down carbohydrates in the vegetables, and increase the protein content. They will break down anti-nutrients that cause gas and upset stomach. So the vegetables are more digestable, and you can get more nutrients from them.