News for hackers. Stuff that matters.
Re:Featherweight Go by hombre_fatal on Sunday May 31, 2020 @07:39PM (#23374069)
Lack of generics just means you have to copy and paste everything, like any time you want to reverse a slice.

    for i := len(a)/2 - 1; i >= 0; i-- {
        opp := len(a) - 1 - i
        a[i], a[opp] = a[opp], a[i]
    }
Actively hurts reading code as you have to credentialize in a code base to begin to be able to file entire code blocks into copy and pasted "idioms".

Without generics you have to hope the stdlib gets a blessed generic function like reverse() one day since you can't build one without rolling your own monomorphization code-gen or a goofball interface{}+cast hack.

For people who supposedly prefer the lack of generics (which seems more like cargo culting or Stockholm Syndrome), no problem. We can just add a config option to golint that prohibits you from using generics. That way you don't need to hold up the rest of us. win-win.

Re:Featherweight Go by psanford on Sunday May 31, 2020 @08:42PM (#23374503)
Weird. While you could copy that from the SliceTricks Go wiki page, you could also just use `sort.Sort(sort.Reverse())` which seems to address all of your complaints.
Re:Featherweight Go by littlestymaar on Monday June 01, 2020 @05:10AM (#23376604)
But it uses an interface, which means dynamic dispatch and an allocation most of the time (because IIRC it tends to break the escape analysis).

That's a recurrent issue with Go: you can either have ergonomic tools (with interface and reflection), or performant code (with no allocation) but you generally can't have both at the same time. Sure it's better than scripting language where you need to use another language when you need performance, but it's still kind of sad.