6

I wonder why I rarely see any IDEs or other developers that use background colors for syntaxhighlighting.

One of the first things when installing and configuring a new IDE is adjusting the colors so that for example comments have a decent light-grey background. This really helps me seeing where documentation is and where code is when scrolling down fast.

The only time i saw something like that was in the Greenfoot Editor but that didn't look so well at least if you are doing some more complex work and there are more nested conditions and stuff.

So why is it that background colors are rarely used; or does anyone have some good examples where they are used and how?

closed as primarily opinion-based by GrandmasterB, GlenH7, user40980, Bart van Ingen Schenau, amon May 4 '14 at 10:17

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • If that post better belongs to ux.stackexchange.com please move it there. Thanks. =) – valenterry May 2 '14 at 22:18
  • The obvious answer would seem to be contrast. You said it yourself; it didn't look so great in the Greenfoot Editor. – Robert Harvey May 2 '14 at 22:22
  • Frankly, I can't think of any case where it would look good. If that is not just a limitation of my imagination, it might be the reason you're looking for. – user7043 May 2 '14 at 22:26
9

Text color is enough for that purpose. In most editors I've used, I can clearly see the comments, the keywords, the strings, etc. There is simply no need to visually complicate stuff with background color.

Another element is that backgrounds are used, but for the purposes other than syntax highlighting. For example, in Visual Studio:

  • Background colors are used to highlight the current line (not the configuration by default) as well as the matching brackets or every use within the file of a currently selected variable.

    This alone is a good reason not to use backgrounds for syntax highlighting. Changing background to highlight the occurrences is a very powerful visual way to show information if and only if the background stays uniform elsewhere.

  • Yellow background is used for quick search.

    This is another good example. You can see in practice how difficult such search becomes in a browser when the webpage uses too much background colors. You simply can't see where the search occurrences are.

  • Dark red background and yellow background are used when debugging.

  • Light yellow, light blue and light red are used to show the results of code coverage.

  • Other colors are used during a diff in TFS to highlight added and removed text.

    enter image description here

Not using background colors for syntax highlighting makes it possible to keep background colors for something special. If you already use backgrounds for syntax highlighting, you'll end up with a visual mess.

Your example of Greenfoot Editor is a different illustration. They use background for nesting, so using it also for syntax highlighting would create a mess too. Note that their case is problematic too; not, like you said, "if you are doing some more complex work and there are more nested conditions"—if your code has five nested levels, you're screwed anyway and your first concern should not be the IDE, but the code itself, but rather because if the code is formatted correctly, nesting is visually clear, and there is no need to add colors.

Not the answer you're looking for? Browse other questions tagged or ask your own question.