ndmitchell / hlint

Haskell source code suggestions
Other
1.45k stars 194 forks source link

Consider using less morally-loaded language in hints. #1584

Open NorfairKing opened 3 months ago

NorfairKing commented 3 months ago

I know I stand a good chance of being ridiculed for this, so please hear me out, but feel free to ignore this issue entirely.

Hints are sometimes phrased as "Perhaps you should remove it." which seems to imply that "a person who does remove it is a better person". https://github.com/ndmitchell/hlint/blob/6898b4322b1b3c010b9e61b72cad273f5ca3d650/src/Idea.hs#L82

This issue exists just to suggest replacing "should" by "could". Or even: "You may be able to remove it."

ndmitchell commented 2 months ago

I'm happy either way. No intention to make a moral judgement. Maybe even simplify further to "Perhaps remove it." ? Only concern is breaking people who match on it with regexes or what not, but hopefully that's fairly rare.

googleson78 commented 2 months ago

I'm all for being more sensitive and non-hurtful, but I believe changing "should" to "you may" or "you could" is changing the semantics of the sentence from a "this might be an improvement" to "it's unclear whether this is better, but you could do it".

In the first place, I believe that hlint aims to give some hints about improving code - if the suggestion was not an improvement, at least in some scenarios, then why not remove it entirely from the hlint suggestions set?

Perhaps I'm just misunderstanding your grievance, though.

In the sentence

Hints are sometimes phrased as "Perhaps you should remove it." which seems to imply that "a person who does remove it is a better person".

what makes you feel that "Perhaps you should remove it." implies some personal fault in the person reading the message? I feel that language is fairly gently phrased, and it seems like the same language people use in code review all the time (IME), to make suggestions to other people, with no intent (or effect, I assume) of being hurtful.

Or to put it differently, how would you phrase a suggestion to change something that another person implemented, in the case where that change would be a justifiably objective improvement? For example, how would you suggest to someone that they should use foldl' instead of foldl in a scenario where they explicitly want their fold to run in constant stack space?

NorfairKing commented 2 months ago

@googleson78

I'm all for being more sensitive and non-hurtful, but I believe changing "should" to "you may" or "you could" is changing the semantics of the sentence from a "this might be an improvement" to "it's unclear whether this is better, but you could do it".

That's the entire point. Using words like "better" when it comes to a subject that isn't a moral one is dangerous. You aren't a good programmer. You're a skilled programmer. Being skilled doesn't make you any better of a person.

Code isn't better or worse either. It's more effective/efficient/easier to maintain/...

In the first place, I believe that hlint aims to give some hints about improving code - if the suggestion was not an improvement, at least in some scenarios, then why not remove it entirely from the hlint suggestions set?

There are plenty of cases in which hlint cannot be sure that the code it suggests is preferable, but I still want to read its feedback. For example: redundant parentheses or duplicated code.

with no intent (or effect, I assume) of being hurtful.

To be clear; I don't intend to suggest that this language was used with harmful intent. I'm just pointing out that we can use more accurate (amoral) language to discuss an amoral subject.

For example, how would you suggest to someone that they should use foldl' instead of foldl in a scenario where they explicitly want their fold to run in constant stack space?

"This fold does not run in constant stack space, see this comment. I think you will want to use foldl' instead."

@ndmitchell: I think the regex use-case can safely be ignored because there is a --json flag AFAICT.