News for hackers. Stuff that matters.
Re:Please do not attempt to simplify this code by zoogeny on Tuesday August 06, 2024 @09:01PM (#41177196)

    // CSINameTranslator can get the CSI Driver name based on the in-tree plugin name
    type CSINameTranslator interface {
        GetCSINameFromInTreeName(pluginName string) (string, error)
    }
Do people actually find comments like the above useful?
Re:Please do not attempt to simplify this code by jakevoytko on Tuesday August 06, 2024 @09:38PM (#41177413)
On a big open-source project like Kubernetes, they're probably happy with the tradeoff between "some exported names have inane and obvious comments" and "our linter requires open-source contributors to document their exported names in a consistent way."
Re:Please do not attempt to simplify this code by sollniss on Tuesday August 06, 2024 @09:41PM (#41177433)
With the official linter (golint), exported types must be commented, so sometimes you get Captain Obvious comments like this.
Re:Please do not attempt to simplify this code by kmoser on Wednesday August 07, 2024 @12:29AM (#41178252)
Yes, if it's your first day on the job and you don't know that CSI is a driver. Yes, if GetCSINameFromInTreeName ever gets renamed to something less obvious.
Re:Please do not attempt to simplify this code by rk06 on Wednesday August 07, 2024 @03:37AM (#41179088)
yep, they are useful.

I consider comments to live at "conceptual" level while code lives at "physical" level.

With this way,when you are debugging, your mind can read code at conceptual level and easily disregard irrelevant blocks of code. without comments, i will need to mentally drop down at physical level and implement a compiler in my brain for the same results

Re:Please do not attempt to simplify this code by akvadrako on Wednesday August 07, 2024 @04:41AM (#41179437)
In this example it's faster for me to understand what the code does by reading the comment than to parse the code itself. If you're just scanning over a lot of code and looking for what you care about it could be helpful.