Highlighting My Code Based on How Much I Care

(hank.bond)

40 points | by hankbond 2 days ago

11 comments

  • dainank 2 minutes ago
    Maybe I missed it but has he posted his theme anywhere (I assume for VSCode since he mentioned he is using that)?
  • sph 59 minutes ago
    I am convinced everybody gets syntax highlighting wrong and this article backs me up.

    My pet peeves:

    - I have no idea how people are supposed to be productive with non-semantic rainbow vomit themes that are so popular in modern editors. I'm too ADHD to want to be overly stimulated by useless information.

    - I routinely hate encountering Zig code on Github, where the theme they use turns everything brown. Oh it's because it's a struct member. Dude, everything is a struct member in Zig, it's silly to allocate a vibrant colour for what amounts to 90% of the source code. Random example off my browser history: https://github.com/foxnne/aftersun/blob/main/src/time/enviro...

    - Yesterday I opened some Lisp code in KDE's KWrite text editor, and every single default theme highlights parens with a bold, vibrant colour to make them stand out. Parens in Lisp are supposed to fade in the background, not pop in your face. It was completely unusable, I had to turn off syntax highlighting.

    Always seeking good, minimal, muted colour themes for my editors. I wish we had serious designers to design themes for usability and comfort, and not people that have no business playing with colours.

    I remember a colleague that used to write code with syntax highlighting off, and thought that was an eccentric choice. The older I get, the more I appreciate his wisdom. I'd rather have no syntax highlighting than bad one; at least one would try to make the code easy to parse by its structure alone (shorter lines, comments to delimit sections, etc.)

    • chrismorgan 7 minutes ago
      Maybe a decade ago, I decided to start a theme from scratch, named bland. Initially, it was just black on white, with keywords bold, comments, macro invocations and lifetime tokens (this was all focusing on Rust) italic, and escape sequences bold italic. I decided to wait a week before deciding if I would add any colours at all. As expected, after that week I made strings red, comments green and numbers blue. Since then, I’ve made number type suffixes light blue, macro-related things orange, and delimiters grey (I should try dropping that one again). I also made a dark variant of it for my website’s dark mode and for occasions I want to use an editor in a dark place.

      The colours involved are all high-contrast, using the RGB channels provided rather than trying to be silly with low contrast: #fff, #000, #c00, #090, #00c to begin with.

      But I have no particular interest in publishing this in a form others can consume in whatever editors they use. Plenty of small tweaks that I develop over time, half for my own Vim syntax files.

    • my-next-account 8 minutes ago
      >Always seeking good, minimal, muted colour themes for my editors. I wish we had serious designers to design themes for usability and comfort, and not people that have no business playing with colours.

      I think Prot's Emacs themes are good for this.

    • embedding-shape 43 minutes ago
      > Always seeking good, minimal, muted colour themes for my editors. I wish we had serious designers to design themes for usability and comfort, and not people that have no business playing with colours.

      I want the same as you, but probably also the same as you; I'm too lazy to do it myself. Maybe do all of us an favor, and create that yourself and share it with us? I too prefer no syntax highlight than bad one, and most out there are bad, and you clearly grok a bit more than the typical color scheme creator/maintainer, so you're already 50% there! ;)

  • Valodim 21 minutes ago
    Good article, enjoyed it. I might give this idea a shot!

    > Comments: these contain high level descriptions (faster than reading the code) and external context (the “why” that reading code can’t answer). This is the most scannable thing in any big code file.

    Not sure about that one, depending on comment culture. Comments are prose and not structured, so to understand their meaning is a lot more cognitive load for me than (most) code. I certainly wouldn't have thought to call them "scannable".

  • nelsonfigueroa 40 minutes ago
    I went through a similar journey not too long ago. I also asked myself "Why does highlighting even need to be in color?" when reworking my blog. I wanted a monochromatic look for my entire site, including code blocks. I noticed code blocks are still very readable as long as there's different tones. I still like pretty colors so I compromised by doing normal syntax highlighting when a code block is hovered over (or tapped on mobile).

    Btw the dynamic highlighting by clicking on the code is so cool. I may or may not steal that idea ;)

  • burticlies 1 hour ago
    I like highlighting only the language concepts:

    Reserved words are red

    Strings are green

    Constants/numbers are blue

    Types/meta-language are yellow

    Anything else is white.

    It’s not too colorful but still gives you plenty of anchors for your eyes.

    • weinzierl 9 minutes ago
      What about comments? Do you prefer comments to stand out or stand back?
  • KronisLV 1 hour ago
    Cool article, really cool website (the font could also be a bit smaller, if it didn't mess with the fidelity), but the grayscale setup just doesn’t have enough contrast for my eyes to reliably pick up on it at a glance.
  • cauliflower99 48 minutes ago
    Really enjoyable read - well done! I wonder where else we could use an effective, minimal approach that solves the problem at first principles?
  • WhyIsItAlwaysHN 2 hours ago
    The continue keyword is also important, or alternatively the condition to run it.

    I often fail to notice it on the first look of some snippet of code

  • epolanski 16 minutes ago
    > Why does highlighting even need to be in color?

    I wrote a vscode extension for effect-ts authoring that indeed leverages this concept.

    It adds underlines and/or bolder fonts to emphasize different colors.

  • tefkah 2 hours ago
    i’m surprise by how much i liked that! also: neutrality website, very tasteful
  • applfanboysbgon 1 hour ago
    I will always yap to anyone who will listen that I think syntax highlighting was a mistake that has cost humanity untold millions of productivity hours. I only highlight comments to distinguish code from not-code, I think everything else is a pretty distraction. Note how nobody ever got the idea to apply syntax highlighting to English or any other natural language, whether in books or on forums. I could believe syntax highlighting helps learn to distinguish things when you're new to programming, but for experienced readers syntax parsing happens as automatically as it does in natural language without any need of colors.