News for hackers. Stuff that matters.
Re:Why Go is elegant and makes my code elegant by FiloSottile on Wednesday April 09, 2014 @06:03PM (#7562778)
panic() is awful. Right. But is so much not a pattern.

Sum, Max, Min are pain points that surprised me indeed.

As for error handling I argue that it's a good thing. Really, it forces to decide what you do with your errors, and snippet expanders are there for a reason if you need to handle them all in the same way.

Re:Why Go is elegant and makes my code elegant by anonymoushn on Wednesday April 09, 2014 @06:20PM (#7562884)
Sorry, I don't mean to talk about Sum/Max/Min. I mean to talk about Either<A,B>, which is the appropriate return type for almost every Go function. In the presence of this type, the "40 lines of mostly error handling" can then be reduced most of the way back to 5 lines using some function or control-flow construct that maps over the left half (or whichever half is chosen to not hold the exception) only.

Here's this in a really ugly language I would never recommend to anyone: http://stackoverflow.com/questions/3496304/how-do-i-process-...

And in a reasonable language: http://stackoverflow.com/questions/13503965/mapping-over-eit...

Edit: See also wting's comment below https://news.ycombinator.com/item?id=7562702

Re:Why Go is elegant and makes my code elegant by azth on Wednesday April 09, 2014 @06:18PM (#7562876)
> Sum, Max, Min are pain points that surprised me indeed.

I doubt the parent post meant sum as you used it. Look up "sum type" or "tagged union". Explicit + concise error handling are not mutually exclusive.