Light or the Dark side?

This is in reaction to an article and a tweet.

The article is full of sarcasm and this reply will not go into the statements on Docker and how you can use it from VS Code in a cool way, it has to do with the Tweet more than anything. It states that light themes for better for coding and are just better in general in terms of readability. I would like to dispute this statement.

Scientific study

He pointed to an article that in turn pointed to one Harvard study stating that in general readability is better for high contrast, meaning dark text on light background. There is an actual standard you can adhere to and there is a calculator where you can plug in values into to see how well it scores on that standard. In it you can plugin black background and green text and it scores surprisingly well. It only scores bad with people that suffer from color blindness, but in general it scores well.

First off I think you cannot use one study to state there has been research and therefore it is true and scientifically based. There need to be more studies, more well defined studies, bigger sample size, narrowing of the test subjects and more importantly meta data studies that either state that most studies will validate or invalidate or left undetermined the actual conclusion to the hypothesis stated.

For instance, I think in general the tests will be done for normal texts in daylight on paper. I think most of us find it easier to read black text on white paper in the daylight rather than some lighter text on a dark background. Were you to position yourself in a club, where the lights are colorful but overall quite dim and you could focus with the blaring music and sensual hip movements around you, you might find it easier to read lighter text on a dark background.

This also applies to normal texts, like prose or poetry or even a pamphlet. However what we are talking about is source code and understanding and reading that is quite different than just normal regular text.

So let us rule out the argument that Harvard says it so it is true.

Memory

So I recently read the book: The Idiot Brain: A Neuroscientist Explains What Your Head is Really Up To by Dean Burnett. In it are a lot of wonderful things explained that help you understand your brain better, and one of the things is concerning memory. More specifically short term memory and long term memory.

Short term memory

Most people will think of short term memory as what happened yesterday or three days ago or even a month ago. However all of those events are actually stored in the long term memory. If I make a mistake anywhere, I expect you, Dean Burnett, to correct me.

Turns out the short term memory is more like the maximum is a minute and it can hold a very limited storage. Only a handful of items. Luckily it can group things together so you can hold larger and larger collections instead of being limited to a few words. However this does mean you can go into a room and forget why you entered it, it is very easy for this short term storage to be overridden. Something else sparks your interest and it is gone. This also happens in conversation where you want to talk towards a point in response to something and suddenly you forget the point you want to talk towards because you went on to many tangents as you wanted to show all those tangents end up at the point.

As a side note this is why generally texts should be composed of not too long sentences and without an endless stream of long complicated words. As your memory just cannot hold it very well.

Going back to the short term memory and readability.

Normal text

In normal text, prose or poetry or anything of the sort, you are generally reading and interpreting at the same time and you do not have to hold a lot of complex concepts in your head. Let alone reason about them and do calculations or operations on those concepts. This is what it is like to read source code though.

Source code

So we know our brain is very good at grouping things together and also our short term memory is limited but at least it can hold groups as well as singular units. So grouping things seems important. In source code most of us developers use syntax highlighting. This means certain tokens in the syntax are given a special color noting what that specific token is to us. Let us take away the syntax highlighting and apply the theory of readability.

I would argue it is now quite meaningless to discuss this because when reading source code without these colorful indications it becomes exponentially more difficult to reason about code and hold these concepts in your head. Was this a variable or a function, or a boolean, what was the result again, and so on. So the point is moot on saying we need dark text on light background.

Therefore we need the colors to indicate what is what to make it more readable and reason about source code. What contrasts better with color, well a dark background.

Theme

The theme the author likes to use is one called Owl Light theme. I took several random colors from the theme, and plugged them into the calculator. It turns out these colors perform really well on the dark background and horrible on the light background. Also if you like dark text on light background why are you using a theme that is doing except that?

Use the Owl Light theme and just change the background to a dark black or grey and all will be well.

I would argue that in general for normal text under sunlight conditions, a dark text on white paper is good. If you are reading on a kindle, it does not matter as the glare of the sun will blot out everything regardless. In the moon and starlight might be better to have a dark background and lighter text.

For code, I feel nothing compares to a dark background and lighter colorful texts. I plugged in the theme I use, Nord, and checked the results. It fails on one account and scored average on the other three. I could do with a better theme it seems, although I like the aesthetic. Seems 80s neon colors work best on a dark background.

#devlife