Re:Green vs. Brown Programming Languages
by adkadskhj on Thursday April 22, 2021 @05:20PM
(#26908364)
> You may not like Go's convention (indeed, I don't love it although I think it works fine in practice), but the only error handling mechanism in Go is `if err != nil { ... }`. On the other hand Rust has many. This is not incompatible with your observation of "a standardized Result type". Here is a survey of the error handling landscape circa 2019: https://blog.yoshuawuyts.com/error-handling-survey/
By this definition, Go has many too. Go has lots of libraries to wrap error types, combine errors, preserve error data, etcetc.
Errors are one of the more similar things between Rust and Go, honestly.
Re:Green vs. Brown Programming Languages
by throwaway894345 on Thursday April 22, 2021 @06:07PM
(#26908757)
That’s a fair point. I forgot about the various errors packages in Go. I’ve been writing more Rust lately.
Re:Green vs. Brown Programming Languages
by steveklabnik on Thursday April 22, 2021 @01:50PM
(#26905683)
> Here is a survey of the error handling landscape circa 2019
All of this is helper functions built on the same identical core that your parent was talking about.
Not that that isn't its own kind of thing, but I think that the problems are different than "standard" vs "not standard"; this problem is only possible because there is a standard, and they all interoperate well with each other.
Re:Green vs. Brown Programming Languages
by throwaway894345 on Thursday April 22, 2021 @02:22PM
(#26906106)
Indeed, Rust has a very well thought-out core which enables variability (read: "complexity") of all kinds. Variability is a fine thing, but it is at odds with onboarding users from one project to another. I wasn't trying to overstate error handling in particular--I mentioned it briefly in a longer list of examples which in-aggregate affect one's ability to onboard to a new project. I also don't mean to convey that going between Rust projects is harder than in other languages on average--I don't think this is the case at all, only moreso than Go in particular.
You may not like Go's convention (indeed, I don't love it although I think it works fine in practice), but the only error handling mechanism in Go is `if err != nil { ... }`. On the other hand Rust has many. This is not incompatible with your observation of "a standardized Result type". Here is a survey of the error handling landscape circa 2019: https://blog.yoshuawuyts.com/error-handling-survey/
> Not really sure what this means either... the owner of a value generally falls out naturally from how you're trying to use it. It's not really an either/or option
Or you have code which clones gratuitously out of convenience, often because some API unnecessarily asks for ownership of its arguments. Cloning is often just easier than battling the borrow checker, so in the real world with its deadlines, we tend to see a lot of clones because it's more convenient and performance is rarely a concern.
> I've seen generics make TypeScript codebases impenetrable, and I think there's a decent case to be made for not having them at all.
In fairness to TypeScript, I suspect much of this 'impenetrability' is because type annotations were added to existing JavaScript. I suspect the gratuitously complex types were already present in the original JavaScript, but the type annotations brought the pain to the surface. Similarly, I suspect TypeScript has a massive amount of developers who have only ever developed in JavaScript, many of whom are trying to shoehorn their bad JS habits into a statically typed language. You see this in other statically typed languages as well, but never on a scale that leaves a mark on the overall ecosystem.
That said, I think everyone should learn pre-generics Go if only to experience the value of an ecosystem that doesn't value egregious abstraction (again, I say this as someone who personally values egregious abstraction). And no, I don't think Java 1.0 counts (wherein people tried to shoehorn everything into implementation inheritance rather than generics).