Live data from Hacker News

Go 1.18

go.dev

241–250 of 614 posts

Re: Go 1.18

#241

Earlier quoted context omitted.

I see it the other way around, generics reduce complication and allow for code that's a lot more elegant and simple than without. It definitely adds complexity on the compiler side of things, but using them in C#, TypeScript, and Java has been only a plus. Unless you count that time I tried to do stuff with generic interfaces in Entity Framework Core, but that was EF Core's fault as opposed to generics's.

>> generics reduce complication That goes against the definition of the word complication. To complicate something is to combine and intertwine it with other concerns. To fold them together is to complicate them. To generify a function is to complicate it with the ability to accept multiple types rather than just one. There are totally great use cases for generics but all the cases I’ve seen are in library code not i…

As a general rule, if you're referencing the dictionary definition of a word to make your point, you're just playing semantic games.

You know what people also find complicated? Hundreds of lines code being repeated with superficial edits because of golang's lack of ability to abstract higher-level ideas. It's a stupid toy example, but for a very large number of people

    nums.take(20).select(&:odd).reduce(&:+)
is less complicated than

    sum := 0
    for i, v := range nums {
        if i > 20 {
            break;
        }
        if v % 2 == 1 {
            continue;
        }
        sum += v;
    }
The former is less complicated for those people (including me) because it expresses high-level intent rather than low-level implementation. Multiplied over a large code-base, the ability to express intent adds up to an enormous saving in mental overhead rather quickly. You can always drill down and focus on implementation where it matters, but with golang there's almost zero ability to separate a program's detailed implementation from a high-level description of what you're actually trying to accomplish.

The Ruby version of this is also less bug-prone (did you spot the bug in the go example?). And it's also easier to apply to new contexts: the former works automatically for infinite enumerations.

Re: Go 1.18

#242
post #94

Earlier quoted context omitted.

It's not a feature, and it's not a good idea to refer to people with @nicks, because Twitter's @name convention is much stronger and the two don't overlap perfectly (I am not, for instance, @tptacek on Twitter). I use 'nick to refer to people here, in keeping with our lispy ethos, but really anything other than @nick is fine.

I would not assume any "@" is referring to a twitter user, it is common across a number of apps (not to mention, IRC)

On IRC, typical protocol is to just use people's nickname, with a colon after it if you're replying specifically to them. "@" is uncommon for tagging people.

Re: Go 1.18

#243
post #71
post #67

For me the most puzzling aspect of Go is channels. Ada tried CSP (Concurrent Sequential Processes that Go channels are based on) in eighties and people quickly realized that it lead to bad performance and was unsuitable for a lot of useful cases. So Ada got standard mutexes and signals. So why CSP which does not allow to implement priority delivery or multicasting and makes cancelling much harder compared with normal…

I can never seem to understand why a GCed language has pointers, and makes you memorize when to use stack vs heap.

>and makes you memorize when to use stack vs heap

You don't have to think about stack vs. heap allocation in Go unless you're writing performance sensitive code. You could pretend that Go heap allocates everything and still read and write Go code without any problems.

Re: Go 1.18

#244
post #58

Tip: If you've only heard about generics, make sure to check out about fuzzing (*testing.F)!

Any idea why they have such a low byte budget? testing.Fuzz would be so much more readable. I'll accept test.Fuzz if 9 characters is the limit for any compound identifier. Is this sort of single letter class naming common in the standard library?

Re: Go 1.18

#245

Now Go has everything I need in a programming language!

Not for me. There is no ?: ternary operator. Having to write 6 additional lines of code for each tiny conditional sucks. It's not frequent, I think I've only had a single case in a few years where I had difficulty working around, but when it happens - it's not fun. err := h(cond(x) ? f(x) : g(x)) vs var temp T if cond(x) { temp = f(x) } else { temp = g(x) } err := h(temp) Hopefully, this can be improved with generics…

I agree that the latter version is too verbose, but if the alternative is this:

  err := h(cond(x) ? f(x) : g(x))
... then I'd much rather stick with the verbosity. There's way too much going on in a single line here.

I'd rather have if statements be expressions, with gofmt-enforced line breaks:

  err := h(
    if cond(x) {
      f(x)
    } else {
      g(x)
    },
  )
No unnecessary temp variables and no stuffing everything into one line.

Re: Go 1.18

#246

My favorite feature is a tiny, couple line bug fix that I pushed hard to get included during the feature freeze. Full details here, but a summary is below: https://github.com/golang/go/issues/51127 For the past ~8 years, many hundreds of people reported on GitHub - and likely many multiples more have encountered and not reported - a program that didn't work with the error "cannot unmarshal DNS..." This error seems to…

I wish I had your time and effort to be able to fix the issues of split DNS in macOS being broken unless using cgo.

https://github.com/golang/go/issues/12524

This has been an open issue since 2015. It's a pain because every single last tool using go cross compilation fails to use the proper DNS resolver and thereby doesn't work when using work VPN's.

This is tools like: kubectl, vault, concourse (fly), and many other binaries that get built on CI, and unless the company builds on macOS builders and uses CGO_ENABLED=1 DNS resolution is just broken.

And it is increasingly frustrating.

Re: Go 1.18

#247
post #28

Earlier quoted context omitted.

> However the creators of Go responded to critiques of the language in a patronizing manner and talked down to their own programming community at Google as being unable to handle complex languages. Can you provide examples of that? Because the closest thing I can remember is Go creators saying that C++ had too many features interacting in weird ways, and that they wanted to avoid that. Which is a perfectly normal des…

Sorry can't find any since google results seem to get worse year over year. Basically I gleaned this impression from the go message groups more than 5 years ago. Go is pretty nice, but IMHO, it's no masterpiece. There's a reason we keep copying C like syntax, and it's not just familiarity. C could be criticized on many points, but in my opinion it was a brilliant case of language design: Only 30 keywords, the stdllib…

> I got the sense that the Go people wanted to be taken seriously on the same level as great achievements like C and UNIX, but the creators quickly saw through the incoming critiques that they hadn't pulled this off.

One of the creators of Go is Ken Thompson.

"I did the first of two or three versions of UNIX all alone. And Dennis became an evangelist. Then there was a rewrite in a higher-level language that would come to be called C. He worked mostly on the language and on the I/O system, and I worked on all the rest of the operating system."

Re: Go 1.18

#248
post #21

Generics!!! I can't wait for all the different data structure libraries to embrace it. It will make Go adoption in Data Science use-case easier.

I don’t see Go ever making headway in data science. For one, it’s not fast enough to implement algorithms directly but lacks a decent FFI; it would be burdensome to create the metric ton of new libraries that would have to be put into place. And there are Python libraries for basically everything already, from numeric computing to Bayesian time series to Spark to Torch and TensorFlow.

Plus Go’s kind of weird, relative to the languages that many data scientists have experience with.

Maybe I’m being unfair, though.

Re: Go 1.18

#249
post #213
post #67

For me the most puzzling aspect of Go is channels. Ada tried CSP (Concurrent Sequential Processes that Go channels are based on) in eighties and people quickly realized that it lead to bad performance and was unsuitable for a lot of useful cases. So Ada got standard mutexes and signals. So why CSP which does not allow to implement priority delivery or multicasting and makes cancelling much harder compared with normal…

Avoid channels except for straight forward, producer-consumer workflows. Use mutexes and other traditional concurrency primitives for other stuff. Channels are a huge shotgun with caveats.

I agree, with the addition that closing an unbuffered `As evidence that channels should be used rarely, and only in small scopes, consider the number of places chan is used in the standard library.

Re: Go 1.18

#250
post #216
post #143

Aaaand now watch every projects abstraction increase tenfold under the weight of generics

Or an expectation of competence from developers and expecting them to consider tradeoffs of their design- in other words doing their damn jobs as opposed to the language baby sitting them away from tools they might use incorrectly.

There’s nothing wrong with a language being strict with what you can do to force good programming styles. An expectation of competence is nice if you can afford it, but it’s also nice to have languages that mean you don’t have to take that risk. It’s why I liked Go and why I disliked working in Haskell. Look at Lisp - large teams get tied in knots because of the freedom. Go was nice because it just stopped you doing ‘smart’ things. Now it has generics you may as well use Rust or something else.
Post reply on HN