4 ms·
As with a lot of things, this is ultimately a matter of personal preferences, and the compiler could not care less about how your code is displayed in your edit
by lgeorget 7y ago
As with a lot of things, this is ultimately a matter of personal preferences, and the compiler could not care less about how your code is displayed in your editor. So, the question is not whether is's "backwards" or not, it's only a matter a finding the highlighting theme that subjectively suits you.
In my case, I prefer having the keywords highlighted and comments less visible than the code. Why? Because code is not something I read linearly. Having the syntactic markers highlighted helps me visually navigate from blocks to blocks. And it makes it much easier to spot missing curly braces, parentheses, etc.
- jeltz 7y agoSame preference here. I use highlighted keywords to navigate and find stuff quickly in files. Especially important is highlight of some keywords like "return" so I do not miss any early returns.
- SlowRobotAhead 7y agoThis is a good counter argument to the article. I know instantly what a switch statement does, but if I have big bold markers for where a switch and it’s cases are, that helps me jump to the block I’m looking for. In the case of faint comments, I may need to slow down and actually read them if they’re a little less visible. I also know instantly that comments aren’t code and I don’t want all my code faint so just them being different from each other is enough for me. Article makes good points but doesn’t seem like it’s for me.
- dr_zoidberg 7y agoI've seen a few editors[0] highlight certain words in comments like "TODO", "BUG", "FIXME", etc. It depends on the parser that the higlighter uses (some regex based may have limitations here), but it does exist. [0] pycharm and vscode come to mind because I use them the most, but other that I don't recall also do it edit: a couple of typos
- SPBS 7y agoVim highlights those by default too. I had no idea that was a default in vscode as well
- noir_lord 7y agoYep and you can create custom ones and color them however you like. I have BENFIXME and a git hook to prevent ever commiting it, handy for when I want to not forget to come back to something.
- spockz 7y agoCould 3D work here by having comments on a different focal plane than the actual code and then by switching the focus plane? This way one either looks at the comments sharply or at the code itself.
- Mirioron 7y agoSo, essentially layers in image editing? One layer for code and another for comments?
- jobigoud 7y agoWe could think of each collapsible region as going down one dimension.
- SlowRobotAhead 7y agoScrolling “into” a function by depth should take you to its code then, I mean, I’m sure someone has tried this already but that seems like the next logical step.
- Finnucane 7y agoMaybe what would work is some sort of show/hide comments. That is, at a keystroke be able to flip the contrast on comments to read them, then reverse it to look at the code.
- gregmac 7y agoI was just looking across the various editors/languages I use and though I have some variations, my main environments both have comments as green (on a dark background), and -- I suspect this is key -- nothing else uses green. The contrast between hues has the enormous benefit of being both obvious and ignorable at the same time, depending on your frame of mind -- comments stand out, but it's also easy to think "brain: ignore anything green". I suspect this would work with any (primary?) color (though it will change what other colors are available for everything else) I do have one environment (which I barely use) that has comments as a dull gray like the article has, and now that my attention has been drawn to it I realize I actually kind of hate it, and I'll probably end up changing the color scheme.
- bebna 7y agoIntellij allows switching of theme with a keycombo, just clone your regular theme and edit it for focusing on comments. Same goes for other editors like vim where changing colours can be done fast.
- simion314 7y agoI also use red color for global variables, helps me to detect if I forget a var or I made a typo, also I use different colors for local variables and method parameters.
- jobigoud 7y agoShouldn't the undefined globals be underlined by the linter already? Sorry I haven't done JS in forever, in Lua it will point out the unknown globals for me.
- evan_ 7y agoYes if you have your editor and linter configured to do so.
- simion314 7y agoNot on my configuration, maybe it is done by default but I heavily modified my settings a long time ago, though in JS globals are valid, I get a lot of underlined for spelling, unused variables, possible uninitialized variables , I am trying to fix all the warnings but with JS dynamic ways I gave up, on PHP side I mostly fix all of them by defining the types in PHP Docs, handling all exceptions etc.
- markbnj 7y ago> Having the syntactic markers highlighted helps me visually navigate from blocks to blocks. Exactly, and I second the personal preference point. It's not so much about highlighting specific things to call attention to them as it is about breaking up a homogeneous block of mixed text and whitespace into something structured and horizontally navigable.
- drinchev 7y agoSadly this won't work when you read code online. GitHub shows comments gray, as well as StackOverflow. This makes one step in the right direction - movement to highlight the important things, rather than everything.
- zzo38computer 7y agoIt seems that GitHub at least has CSS classes for many things (including the quotation marks around a string literal, it look like), so this allows customization.