DEV Community

Cover image for Should You Really be Coding in Dark Mode?
Simon Pfeiffer for Codesphere Inc.

Posted on

Should You Really be Coding in Dark Mode?

There are few debates as contentious in the development and UX world as color schemes. Among developers, however, there seems to be a pretty significant skew towards coding in a light on dark mode (This poll found that ⅔ of surveyed developers prefer to use a dark mode in their code editor).

Alt Text

Dark mode advocates cite a number of benefits, including reduced eye strain, better sleep, and reduced power consumption. While many of the arguments for dark mode undoubtedly have merit, there is far from a scientific consensus on many of its benefits.


A Little Bit of History

While we might think of dark mode as a relatively new trend, it was actually the original color scheme that was used for computers. Most early computers used light text on dark background in order to save power. As computers became more consumer-friendly, however, developers began to use black text on white backgrounds to imitate the black ink on white paper that most people were used to.

More recently, countless devices, websites, and apps have added support for dark mode for both optical and aesthetic reasons. Software developers, who spend most of their work time staring at computer screens, have been some of the most fervent advocates for dark mode.


1. Eye Strain and Readability

The first argument for dark mode that's worth taking a look at the claim that dark mode is better for your eyes. While there is no doubt that using light mode in a dark room can be blinding, there also seems to be evidence that our brains are just better at reading and comprehending black text on a white screen.

For example, A 2013 study by Psychologist Dr. Cosima Piepenbrock looked at how adults with normal vision performed at visual acuity and proofreading text across dark and light color schemes. The study found that:

"Pupil sizes were smaller and proofreading performance was better with positive(Dark on Light) than with negative(Light on Dark) polarity displays"

In other words, for substantial digital tasks where you are attentively reading text(Such as coding), *having dark text on a light background (i.e. light mode) can help you focus and comprehend better. *

What this means in practice is that your eyes and brain may have to work harder to read and write code if your IDE is in dark mode.

2. Blue Light and Sleep

Another commonly cited claim is that using your IDE in dark mode reduces blue light consumption, and therefore can help you sleep. While dark mode definitely does reduce blue light, blue light may not be the primary culprit that actually messes up your sleep schedule.

A 2019 study by the University of Manchester found that blocking blue light only slightly improved people’s sleep patterns. Instead, the real culprit is the use of warmer colors(Like reds and yellows) at night, which trick our brain into thinking it's daytime.

If you want to get better sleep, dark mode may in fact help, but the real solution is to not use screens altogether before going to bed.

3. Power Consumption

Another argument for using dark mode in your IDE is that it can save you money on your power bill. If you are using an OLED display, which most modern monitors do, then this is definitely true.

It is probably important to note, however, that if you are developing software that is computationally heavy, like rendering 3D graphics or training and using machine learning models, the reduced power consumption from dark mode probably won’t make any sort of noticeable dent in your power bill.

4. Accessibility

Regardless of what you personally prefer while you code, you should always add support for both dark and light modes in the software that you build. Many people who have certain color blindness or eye conditions can find one of these themes extremely hard or even impossible to use. Giving your users flexibility is therefore very important.


Conclusion

In summation, the jury is still out on whether dark mode is actually better for coding. While it might save you a tiny amount of power and, if you are using it at night, marginally help your sleep schedule, these benefits don’t seem to be that substantial. In addition, reading dark text on a light background may help you read and write code more efficiently.

Your theme therefore should come down to what is best for you, because there is not a scientific consensus that one color scheme is going to be better than the other. If you think dark mode looks sleeker and you are doing a lot of coding at night or in the dark, then go ahead and use dark mode. If you prefer the readability of dark text on a light background, then go ahead and use light mode.

So what do you prefer and why? Personally, I think dark mode is more aesthetically pleasing but I definitely notice how it can be harder to read.

Let us know in the comments what you think!

Latest comments (54)

Collapse
 
ingosteinke profile image
Ingo Steinke

Dark mode can be aesthetically pleasing, and so can light mode, and even more so if the colors match. Often I saw a theme which looked promising at first glance but turned out that I didn't like the palette. In general, I prefer lighter themes!

I like to switch themes to adapt to the surrounding environment, as I find dark themes mostly too low-contrast when coding in the sunlight. I also enjoy sepia / yellowish / espresso themes, but my current favourite is a light theme with deep pink accent colour: WebFreak's Cute Pink Light Theme for VisualStudio Code and VS Codium.

When I started to use PhpStorm as my default IDE again, I found no theme to match, which is why I started to copy Cute Pink Light as a theme for PhpStorm / WebStorm / IntelliJ IDEA. It's already released, but still work in progress. So, if someone likes pink light themes, and has experience in customizing IntelliJ colors, I'd be very glad if they help me to finish the theme.

Collapse
 
mistval profile image
Randall

I feel more comfortable using dark mode, and at night I enable Windows night mode which makes my screen very red, and it has improved my sleep significantly.

Collapse
 
suther profile image
Samuel Suther • Edited

Best mode against eye strains is Off-Mode ^^ - but the downside is, productivity by coding also decrease to 0%

But thanks for this article, I'll think about to give it a try again to switch from now to then between dark and light... and will see on which times a day I'm comfortable with dark or light mode.

Currently I prefer Dark, because it mostly feels less stressing to me.

Collapse
 
tobiobeck profile image
Tobi Obeck

I am wondering whether the proofreading study (Piepenbrock 2013) does transfer to coding. I assume it is focused on reading text in general.

From my personal experience I like dark themes, because different keywords are highlighted in distinct colors (bright green, hot pink, yellow...) which are easy to differentiate. In light themes most of the text colors look quite similar (dark sth.) almost the same to me.

I'd assume in dark themes the code can be easier parsed as the different kinds of keywords and it is therefore easier to understand the meaning of the code. For example while scrolling and skimming through the code you see all the green function signatures immediately.

Someone should conduct a study specifically on reading code with dark vs light themes. Maybe there the results would be different.

Collapse
 
braindawg profile image
Brian Dunne

It would be interesting to see the study in point 1 repeated with code that's syntax-highlighted. The contrast between colors is much easier for me to differentiate in dark mode, so I find myself having to look more closely at the code itself in light mode to puzzle out what's going on rather than being able to quickly scan through the code structure based on syntax highlighting.

Collapse
 
tlingit profile image
Tom Pittman

What a weird world we live in. So many people want to join a side.

I think it's cool MacOS will "night shift" your Mac automatically depending on the time of day. iPadOS and iOS do it too, but not many of us write code on those platforms.

Collapse
 
jenkstom profile image
Tom White

As someone who has been doing this for over 30 years... the eye damage is real. I wound up having to take beta blockers for a while to stop my pupils from spasming every time I looked at a monitor. I'm a big believer in dark mode, and you should be too.

Collapse
 
yarduza profile image
Yarden Even • Edited

I like dark mode so much, if I could I would have dark text on a dark background.

Jokes aside. I've known both sides, I've seen the light and now I live in the dark. I find it very convenient, everything pops at me from the screen, and I feel less bombarded than I do with the light from the background.

As far as sleep goes, I have a terrible relationship with sleep. I can lay in bed for 2 hours if my mind can even slightly wander. No amount of light reducing is gonna fix that problem.

My horrible workaround is to work until my mind is so exhausted, I can't even brush my teeth correctly. That way I just get into bed, and I don't have the strength to argue with sleep, so sleep wins.

Collapse
 
flokoe profile image
Florian Köhler • Edited

I once was supporter of the dark side ;)

After I discovered this article
stitcher.io/blog/why-light-themes-...

I switched and now I much prefer light themes, BUT there are some requirements:

  1. I always sit in bright rooms
  2. If it gets dark outside I turn the lights on
  3. I heavily rely on "nightmode" of my os to filter blue light

On my phone I still use a dark theme as my display is an OLED display to save battery.

Collapse
 
springhan profile image
Jim Huang

So why not use the two different themes at different time?
Now I'm using light theme during the day and dark one at night.
I think it's a nice choice.

Collapse
 
jsnanigans profile image
Brendan Mullins

I care more bout how good the contrasts are and how quickly I can differentiate different parts of the code, but after reading this I will try some light themes again, I have been using dark mode for years so I might be a bit biased

Collapse
 
dezfowler profile image
Derek Fowler

I find switching from an editor in dark mode to either the docs or the website I'm building which usually have a white background to be far too jarring. I think maybe due to getting an after-image on my retinas which makes it more difficult to read what's on the screen.

For that reason, although I quite like dark mode, I just can't use it when doing the job day to day.

Collapse
 
darkmg73 profile image
DarkMG73

I like the article, but I think you might want to add one more section based on the biggest reason I have heard from coders using dark mode: eye fatigue. The mention of “eye strain” in point one and “blue light” in point two were never really covered in their respective paragraphs.

Blue light is a major part of eye strain. Our eyes absorb light and hold blue light in for relatively long periods of time. This build up is part of eye strain and can lead to larger issues. Dark mode has significantly less light overall, meaning less light absorbed and lower eye strain.

The other major factor in eye strain is our eyes rapidly adjusting to dramatically different levels of light. This happens when we have a dim or dark room and bright screen. So, if a room is dim or dark and we can’t make it brighter (like at night in a bedroom with a sleeping spouse) dark mode and a dimmed screen can ease eye strain significantly.

Just some thoughts you might be interested in adding. This is all based on a lot of research I had done recently, including my eye doctor, because I had been suffering with severe eye strain issues.

Collapse
 
simoncodephere profile image
Simon Pfeiffer

thanks for sharing! really valid point.

Collapse
 
akashaj09 profile image
Akash Ahammad

For me, Dark background much better than white background. I tried white background for a while but it's hurt my eyes. While using dark mode I really don't notice any problem.

Collapse
 
samuelabreu profile image
Samuel Abreu

After O.S. offers dark mode and dark mode browser extensions, I really suffer when I have to use any light theme app/software. Even switch bank due the new bank offers dark mode on their mobile app.