News for hackers. Stuff that matters.
Re:Errors in Go: From denial to acceptance by aikah on Monday November 26, 2018 @02:29PM (#18536101)
> these are purposeful trade-offs that the Go team makes.

Trade-offs for whom or with what in mind? the compiler or the programmer?

That's the "philosophical" difference between the Rust team and the Go team.

Re:Errors in Go: From denial to acceptance by TylerE on Monday November 26, 2018 @10:45PM (#18539157)
The cynic in me says it's optimizing to hire lots of low-skill programmers at Google for cheap.
Re:Errors in Go: From denial to acceptance by Skunkleton on Monday November 26, 2018 @03:39PM (#18536597)
Exactly. That is why Rust does so many more things, but Go compiles so fast.

Even with two wildly different approaches to language design, each has their place, and their own set of drawbacks.

Re:Errors in Go: From denial to acceptance by repolfx on Monday November 26, 2018 @06:03PM (#18537661)
It's a false dichotomy. Languages like Java or Kotlin compile fast and have exceptions too.
Re:Errors in Go: From denial to acceptance by mmirate on Monday November 26, 2018 @11:01PM (#18539227)
Because the JVM takes another tradeoff against Go and Rust: it has a runtime interpreter+JIT, which causes even more performance overhead than Go's GC let alone Rust which - at runtime - is effectively a zero-cost abstraction over C and jemalloc.
Re:Errors in Go: From denial to acceptance by repolfx on Tuesday November 27, 2018 @02:24PM (#18545764)
The JVM GCs generally have much lower overhead than Go's does. Go imposes enormous collection costs on apps to try and drive latency so low. This is widely acknowledged in discussions of the various GC tradeoffs.
Re:Errors in Go: From denial to acceptance by mmirate on Tuesday November 27, 2018 @10:34PM (#18549095)
The GCs alone? Yes. The rest of their respective runtime architectures? Highly doubtful. As GC-dependent as Go may be, it still does end up as native code.

But frankly, comparing Go to Java when things like Rust exist ... seems analogous to comparing the z80 to the AVR when 32-bit ARM cores exist.

Re:Errors in Go: From denial to acceptance by repolfx on Friday November 30, 2018 @04:18PM (#18572710)
Offtopic/meta: for some reason your post was dead. The comment at the end is kind of pointless and flamey, Rust isn't that good, but doesn't seem to justify a post kill. I vouched for you to bring it back.
Re:Errors in Go: From denial to acceptance by hactually on Monday November 26, 2018 @07:28PM (#18538170)
Not quite - Java is faster than Kotlin [0] but I've never seen a Golang app take more than 10 seconds (and that's something huge like Kubernetes or Docker components)

[0] https://medium.com/keepsafe-engineering/kotlin-vs-java-compi...

Re:Errors in Go: From denial to acceptance by rhencke on Monday November 26, 2018 @07:51PM (#18538309)
The article you link comes to a different conclusion:

> With the Gradle daemon running and incremental compilation turned on, Kotlin compiles as fast or slightly faster than Java.

Re:Errors in Go: From denial to acceptance by yawboakye on Monday November 26, 2018 @05:27PM (#18537426)
Go optimizes for fast compilation, as such the language has fewer internal checks for only the absolutely necessary. In my opinion, to be able to continue execution when an error happened earlier could be a blessing or a curse, and it depends on the programmer. I've been writing Go for 2 years now and I don't have a single case where I accidentally ignored an error. I have ignored errors, but usually for operations whose end result I don't care about or doesn't affect what happens next in the program.

There's also a recommended way of dealing with errors. I may not state it correctly but basically you build a pipeline of operations for a data type that represents the arguments (or data) of the operations. For example, to compress an image given a URL:

  type Image struct {
    src string
    bytes []byte
    width uint
    height uint
    err error
  }
  
  func NewImage(src string) Image {
    return Image{src: src}
  }

  func (img Image) Get() {
    if err != nil {
      return
    }
    ...
    // Set error value if this operation fails
  }
  
  func (img Image) Compress {
    if err != nil {
      return
    }
    ...
    // Set error value if this operation fails
  }
  
  func (img Image) Err() error { return img.err }
  
  img := NewImage("https://image.src/random-image.png")
  img.Get()
  img.Compress()
  if img.Err() != nil {
    // handle error just once
  }
Re:Errors in Go: From denial to acceptance by Groxx on Monday November 26, 2018 @07:57PM (#18538344)
this does work... but it also requires two very significant points.

1: you must do this wrapping yourself, for everything you wish to simplify, as few libs do it.

2: you now have non-standard error handling and your tools will not warn you if you handle it wrong.

the second one, to me, is borderline fatal for this pattern. You can't look at this code and realize it's missing error handling (or doing it incorrectly), and you can't run `errcheck` to tell you that e.g. you're missing `err := img.Get()`.

Re:Errors in Go: From denial to acceptance by geodel on Monday November 26, 2018 @04:28PM (#18536946)
And all the code to satisfy borrow checker in Rust, is it for compiler or programmer?
Re:Errors in Go: From denial to acceptance by steveklabnik on Monday November 26, 2018 @05:07PM (#18537267)
That’s like asking “are type signatures for the compiler, or the programmer?” The answer is a bit of both: for the programmer to express intent, and for the compiler to check that intent is correct.
Re:Errors in Go: From denial to acceptance by spenrose on Monday November 26, 2018 @06:18PM (#18537741)
Why would a programmer have an intent about types to express unless s/he had been trained to think of programming in terms of static typing?
Re:Errors in Go: From denial to acceptance by oleganza on Monday November 26, 2018 @06:57PM (#18537949)
If your type system is powerful enough (like in Rust), then you can use it to express relations in your problem domain and have compiler enforce them for you before the code even runs.

Example: https://blog.chain.com/bulletproof-multi-party-computation-i...

Re:Errors in Go: From denial to acceptance by spenrose on Monday November 26, 2018 @08:38PM (#18538582)
I think you missed the "unless" in my question. I am well aware that having chosen to treat types as a first class problem, a coder can leverage that intent. My point is simply that there is a populous, productive world of software development in which typing is a humdrum issue for the coders. C.f. the last 30 years of Javascript and Python
Re:Errors in Go: From denial to acceptance by steveklabnik on Monday November 26, 2018 @07:46PM (#18538274)
What makes that an interesting question? That’s like saying “how would someone have an idea to tests their code unless they were trained to think about testing?” It feels like a tautology, and not particularly relevant.

(I love both dynamic and static typing. I think dynamic type systems are more useful than basic static type systems, but also really enjoy more expressive static type systems.)

Re:Errors in Go: From denial to acceptance by spenrose on Monday November 26, 2018 @08:36PM (#18538570)
Perhaps the programmer should be focused on the purpose the code serves, rather than the code as code object. Mental cycles devoted to thinking about types are, for most programs, overhead. It's perfectly reasonable to be a strong static-typing believer, though I am not. But it's also perfectly reasonable not to think about types when coding, as millions of useful programs have demonstrated.
Re:Errors in Go: From denial to acceptance by steveklabnik on Tuesday November 27, 2018 @09:36AM (#18542561)
FWIW, I've found many people new to programming expect something like types, even though they don't have the vocabulary for it yet. It really just depends on the individual.
Re:Errors in Go: From denial to acceptance by spenrose on Tuesday November 27, 2018 @03:12PM (#18546220)
Sure. And many people new to skiing expect something like gussets to keep the snow out of their underwear when they fall. Issue is whether skiing is about clothing or moving over the landscape. Some focus on your clothes is appropriate, and more in certain circumstances. Rust, which I see you are a proselytizer for (I was at Mozilla during Rust's ramp-up, FWIW), is a tool for writing code that is closely integrated with the operating system. In that context, a type-centric mindset is necessary and valuable. If you are writing code in other contexts: exploratory data analysis, a simple Android app, and on and on, then types are there, but programming is not type management
Re:Errors in Go: From denial to acceptance by steveklabnik on Tuesday November 27, 2018 @06:12PM (#18547763)
Sure, that's why both kinds are useful. I don't disagree at all.
Re:Errors in Go: From denial to acceptance by Skunkleton on Tuesday November 27, 2018 @01:25AM (#18539975)
What do you mean by types? Most modern languages have fairly extensive type systems.
Re:Errors in Go: From denial to acceptance by andreareina on Monday November 26, 2018 @11:31PM (#18539386)
Typing doesn't have to be static (or strong) to be there. When I write `a + b`, I intend `a` and `b` to be things such that the `+` operator makes sense for them. Might be two numbers, might be two strings, might be a string and a number if I'm using js/php, the point is that I always have an intention, implicit or explicit.
Re:Errors in Go: From denial to acceptance by spenrose on Tuesday November 27, 2018 @01:09PM (#18544884)
"When I walk to the store, I intend for the ground to hold me up. My intention might be implicit, but it is always there."