News for hackers. Stuff that matters.
Re:A minimal blog engine written in Go, compatible with Ghos... by vezzy-fnord on Saturday April 25, 2015 @08:26PM (#9440044)
Option types are nice. The fourth way (and I think the best) is supervision trees, though this is more applicable when you have multiple units of execution... which Go does, so not having something similar out of the box seems strange.

That said, even something as simple as errors being literal values that you can pattern match on is surprisingly versatile. Exceptions don't necessarily have to be awful weights that spill down all over the call stack, either. They can be distilled to a more basic catch/throw mechanism for shuffling around error properties and states.

Re:A minimal blog engine written in Go, compatible with Ghos... by threeseed on Saturday April 25, 2015 @08:46PM (#9440082)
Personally I love option types but working on a large Scala project at the moment it sometimes results in non ideal behaviour from developers especially those coming from the Java world.

What I've seen a lot of is swallowing of errors. For example readFromFile().orElse("") where there is no indication from an outsider that anything wrong happened. A cool feature would be logging any instance of when orElse was the result.

Would be curious how these work in other languages.

Re:A minimal blog engine written in Go, compatible with Ghos... by Jweb_Guru on Sunday April 26, 2015 @12:54PM (#9442353)
The trick is to make it very ergonomic to return the error. I thought Scala had do notation to make this the case. In Rust, the try! macro (which returns on error) is shorter than almost any other way to handle an error, so people usually use that.