Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #64818

Re: Highlighting program variables instead of keywords?

From Ben Finney <ben+python@benfinney.id.au>
Subject Re: Highlighting program variables instead of keywords?
Date 2014-01-27 13:08 +1100
References <CANc-5UwcZT18RgLqzHq0oMPA4sxfbfu0ZQhGPJBYZ0KEUJ6m2g@mail.gmail.com> <CANc-5UwkLjmwA5LCAKRGjDZaf5EiHXCfU4_Hm2e9yXsDmApR=g@mail.gmail.com> <mailman.6008.1390782718.18130.python-list@python.org> <52e5b66d$0$29999$c3e8da3$5496439d@news.astraweb.com>
Newsgroups comp.lang.python
Message-ID <mailman.6016.1390788505.18130.python-list@python.org> (permalink)

Show all headers | View raw


Steven D'Aprano <steve+comp.lang.python@pearwood.info> writes:

> Hmmm, I'm not convinced, but then I wasn't convinced by syntax
> highlighting either until I had used it for a while. (I still think
> it's a nice-to-have rather than a must-have.)

I wouldn't rate syntax highlighting a must-have. But I do think it's
significantly more difficult to work with an editor that doesn't
highlight the syntax of the code.

> Seems to me that beyond a dozen or so variables, the colours won't be 
> distinctive enough to get much benefit.

A more severe problem with the suggestion is that human cognition is
only capable of attending to a limited number of differences at once,
and so this kind of attention-drawing is a limited resource. Drawing
attention to some aspects is at the expense of reduced attention to
other aspects.

The significant benefit of syntax highlighting is that it reduces the
difficulty to read the text and see what will be obvious to the
compiler: the structure of each statement and block. So spending the
limited resource of differential attention to colours is valuable to
help with this difficult aspect of reading code.

So I strongly disagree with the statement “But as it stands, we
highlight the obvious (like the word function) and leave most of the
content in black.”

Once you have attention on it, the word “function” is obvious. But the
whole motivation of highlighting syntax using different colours is to
get that differential attention in the first place. The difference
between tokens *isn't* so obvious when glancing at the code without
those colours.

That said, the motivation in highlighting different names differently is
a good one, too. I would like to have the benefit described in the
article: having different names easily distinguished in the code. But I
don't think that should come at the expense of significantly reducing
the ease of quickly distinguishing the syntactical structure.

-- 
 \       “We must find our way to a time when faith, without evidence, |
  `\    disgraces anyone who would claim it.” —Sam Harris, _The End of |
_o__)                                                     Faith_, 2004 |
Ben Finney

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Highlighting program variables instead of keywords? Skip Montanaro <skip@pobox.com> - 2014-01-26 18:31 -0600
  Re: Highlighting program variables instead of keywords? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-27 01:29 +0000
    Re: Highlighting program variables instead of keywords? Chris Angelico <rosuav@gmail.com> - 2014-01-27 12:51 +1100
    Re: Highlighting program variables instead of keywords? Ben Finney <ben+python@benfinney.id.au> - 2014-01-27 13:08 +1100
    Re: Highlighting program variables instead of keywords? Terry Reedy <tjreedy@udel.edu> - 2014-01-27 01:30 -0500

csiph-web