News for hackers. Stuff that matters.
Re:The Value in Go’s Simplicity by pcwalton on Saturday November 16, 2019 @01:17PM (#21554059)
Really? For loops are a nightmare. Here's one from SPEC 2006:

    for (dd=d[k=0]; k<16; dd=d[++k])
    {
        satd += (dd < 0 ? -dd : dd);
    }
The problem with for loops is that they are too flexible, and so there's more opportunity for misuse. Iterator functions are less flexible, and therefore easier to read.

And this excessive flexibility doesn't even make simple things simple. Try counting down from N to 0 inclusive using unsigned ints.

Re:The Value in Go’s Simplicity by fluffything on Tuesday November 19, 2019 @08:19AM (#21572566)
Can you solve the exact same problem using Python list comprehensions or Rust iterators?

I'd like to see how solving this same problem in those languages is less of a nightmare.

I personally find that C loop quite readable compared with the same iteration being done in Rust.

Re:The Value in Go’s Simplicity by pcwalton on Tuesday November 19, 2019 @03:04PM (#21577638)
This is a sum of absolute differences, so in Rust:

    let satd = d.iter().cloned().map(abs).sum();
As an added bonus, there's no undefined behavior!
Re:The Value in Go’s Simplicity by tfha on Saturday November 16, 2019 @01:21PM (#21554083)
Loops in go are much less flexible than loops in C, you'd never see code like that in go.
Re:The Value in Go’s Simplicity by pcwalton on Saturday November 16, 2019 @01:28PM (#21554121)
In Go that loop could be:

    for k, dd = 0, d[0]; k < 16; k, dd = k + 1, d[k + 1] {
        ...
    }
I don't find that significantly more readable than the C version.
Re:The Value in Go’s Simplicity by bfrog on Saturday November 16, 2019 @06:22PM (#21555563)
Yeah a quick glance and I have no clue whats going on, tl;dr in review for sure