4 ms·
With the exception of channels, Go doesn't add much when compared to other languages. It doesn't add things, it takes them away, notably exceptions, inheritanc
by grey-area 9y ago
With the exception of channels, Go doesn't add much when compared to other languages.
It doesn't add things, it takes them away, notably exceptions, inheritance, generics. I disagree that's short sighted, it's precisely for long term maintenance that it becomes important to have less ways to do things. You may not agree with the choices, but they are not only about being easy to learn, more about being easy to read.
- wasted_intel 9y agoPeople just end up inventing idioms to handle those, anyway. Go's nil-check error handling is a prime example. That's a beautifully solved problem with ADTs, but it's impossible without generic support, for starters. Runtime errors, abound!
- warent 9y agoGo can handle errors in a very deterministic way, and it can easily recover from a weird panicked state. If someone's Go code has "runtime errors abound" then they probably didn't RTFM ;)
- wasted_intel 9y agoAh, so when I think of deterministic error handling, I think of compile-time enforcement, like that provided by a Result or Option type. Those can be ignored too, though, although the effort to do so is a little bit more explicit. :)
- dozzie 9y ago> It doesn't add things, it takes them away, notably exceptions, inheritance, generics. s/exceptions/error handling/ What Go proposes is awful for a modern language.
- weberc2 9y agoGo has error handling, it doesn't have exceptions for non-exceptional error cases.
- wasted_intel 9y agoGo has functions with multiple return values. That's not at all the same.
- weberc2 9y agoI didn't talk about multiple return values, did I? Every language has error handling support, some languages hijack an exception mechanism as a control flow path for non-exceptional error states. Returning error values is more ergonomic than exceptions, but Go's lack of sum types makes this slightly tedious (still better than exceptions).
- wasted_intel 9y agoRight, I jumped ahead; multiple return values is the how Go returns error values, it's not error handling itself. I don't like exceptions much either, but sum types / ADTs are just so nice for this sort of thing.
- weberc2 9y agoI agree that sum types are nicer, but I don't see how they constitute error handling in a way other return mechanisms do not. The difference isn't categorical, it's ergonomic.
- hasenj 9y agoI'm starting to find it weird that things like "error while passing string as int" trigger an exception rather than return an error. There are always error cases to check when handling user input. It's a natural part of the program flow, not really an exception. I would expect an 'exception' to be something like out of memory or disk corruption.
- deleted 9y ago[deleted]