News for hackers. Stuff that matters.
Re:Show HN: Penumbra, a perceptually optimized color palette... by Sharlin on Friday August 05, 2022 @08:43AM (#32355261)
"Semantic highlighting" might be an interesting concept to study further. As in, annotated or (semi)automatic highlighting of "pay extra attention while reading" parts of code – tricky, nonobvious, mem/thread-safety critical sections, code that assumes invariants or is responsible for their maintenance, and so on.

Some existing examples are "warning squiggles" added by IDE integrated linters, as well as language-level syntactic markers for "here be dragons" parts like Rust’s `unsafe {}` that can be highlighted by standard syntax highlighters (as an aside, it occurs to me that for simplicity’s sake most syntax coloring is in fact merely lexical coloring, but I digress…)

It seems to me that many color schemes these days choose to render comments in grayed-out, low-contrast colors. I find this to defeat the purpose of comments and maintain the unfortunate notion that they are something nearly redundant. A properly written comment tells me something nonobvious and should be displayed prominently rather than faded into obscurity!

Re:Show HN: Penumbra, a perceptually optimized color palette... by siraben on Friday August 05, 2022 @06:41PM (#32362812)
Tree-sitter[0] can provide semantic highlighting and I've been using it with all the languages I program in, including writing my own grammar[1] for a language that didn't have syntax highlighting. The improvement in readability is a quantum leap, because colors actually have semantic meaning rather than just being eye candy.

With the situations you describe, you can write tree-sitter queries to make unsafe code highlighted in a different color, for instance, or highlight specific anti-patterns.

[0] https://tree-sitter.github.io/tree-sitter

[1] https://github.com/siraben/tree-sitter-formula

Re:Show HN: Penumbra, a perceptually optimized color palette... by solasluaith on Friday August 05, 2022 @09:32AM (#32355880)
I absolutely agree that intelligent highlighting or added emphasis to at least some part of the code is very worth investigating. I would argue it should probably be used more sparingly than colouring, but could be complementary. By combining the colours from the base and the contrast++ palette this would even be possible with Penumbra while maintaining the clean separation between colour properties.

In this area, as a novice coder, I am absolutely out of my depth though, so I’d have to defer to actual experts for the implementation.

Someone else brought up a similar point on comment emphasis but I’ve seen the opposing opinion too.