Is Coding in Dark Mode better for Your Eyes?

Among developers there seems to be a pretty significant skew towards coding in a light or dark mode.

There is not a scientific proof that one color scheme is going to be better than the other so your theme therefore should come down to what is best for you. But here are a few facts to be aware of if you still didn’t build strong opinion. 

Focusing depend on the light

Focusing is largely affected by how much light is coming into our eyes and how we focus that light.

If a lot of light is coming in (like when using light modes) eye pupils contract allowing less light in, creating a wide depth of field. Meaning, everything is in focus.

If this is inverted, less light coming in and our eyes have to put more effort into focusing on individual objects. And when you are reading, you want everything to be in focus. You need that light background for the pupil to work appropriately to minimise amount of light coming in.

Light scatter

White text on black is a sort of a halo effect where the light from each letter glows light around it making it difficult and more time consuming to read. This is the complete opposite of light mode which is easier and more comfortable to look at for a long time.

How your brain will process your code in different mode

Dark text on a light background is interpreted as language to your brain. Meaning your brain will create memories and easily string these memories together as a story. This is why books are all typically dark text on a light background. It makes it much easier for your brain to process and retain this information.

Light text on a dark background is interpreted as symbols to your brain. Meaning your brain sees them as objects and recognizes shapes rather than interpreting them as language or a story to convert to memories. So, with light text on dark background your brain will remember where blocks of code will be in the overall structure of a program rather than what the code may do.

Use the color scheme depend on environment light 

You should use a light color scheme if you write code during the day in a well lit room with lots of backlighting, white walls etc. This is an environment where a white background color scheme is going to be much easier on your eyes.

You should use a dark color scheme if you primarily program at night, in a dark room with no lights on or very few at a minimum.

The goal here is to make it so your eyes have to adjust as little as possible to the light being projected into them. You want to reduce strain on your eyes caused by them adjusting to more or less light and allow your eyes to relax and stay the same while you’re writing code.

For most developers dark mode is more aesthetically pleasing but I definitely notice how it can be harder to read.

In the end, there’s no evidence that using light or dark modes in text viewers has any effect on long-term eye health at all, but it should be studied more.