benrazdev | 1 month ago | on: I now assume that all ads on Apple news are scams
benrazdev's comments
benrazdev | 2 months ago | on: Dell admits consumers don't care about AI PCs
benrazdev | 2 months ago | on: An Honest Review of Go (2025)
benrazdev | 2 months ago | on: An Honest Review of Go (2025)
benrazdev | 2 months ago | on: An Honest Review of Go (2025)
Writing `pub` is personally more annoying to me than writing `if err != nil`. I understand that most people don't like how capitalization determines visibility, but I think it actually makes sense when you think about it.
benrazdev | 2 months ago | on: An Honest Review of Go (2025)
I obviously enjoy programming Rust and I like many of the choices it made, but I am well aware of the tradeoffs Rust has made and I understand why other languages chose not to make them. Nor do I think Rust functions equally as well in every single use case.
I imagine most Rust users think like this, but unfortunately there seems to be a vocal minority who hold very dogmatic views of programming who have shaped how most people view the Rust community.
benrazdev | 2 months ago | on: An Honest Review of Go (2025)
type Result[T, E any] struct {
Val T
Err E
IsErr bool
}
type Payload string
type ProgError struct {
Prog string
Code int
Reason string
}
func DoStuff(x int) Result[Payload, ProgError] {
if x > 8 {
return Result[Payload, ProgError]{Err: ProgError{Prog: "ls", code: 1, "no directory"}}
}
return Result[Payload, ProgError]{Val: "hello"}
}benrazdev | 2 months ago | on: An Honest Review of Go (2025)
it's only present when you downcast though?
benrazdev | 2 months ago | on: An Honest Review of Go (2025)
benrazdev | 2 months ago | on: An Honest Review of Go (2025)
In go you don't strictly need magic numbers because you can define constants:
type Status int
const (
IoProblem Status = iota // we start at zero and go down from there
JsonParse
...
)
The problem is that there is no exhaustiveness with these constant groups. The type Number is not a closed set of just IoProblem and JsonParse like an enum in C. It is just an int.benrazdev | 2 months ago | on: An Honest Review of Go (2025)
If I have
struct S { X int }
func (s *S) Error() string { ... }
but I return it as an error: func DoStuff() error
Then all the caller gets is an error interface. Without downcasting (`.(T)`/`errors.As`), you can only compare it to other instances (if the library author provided them) or see the string representation.benrazdev | 2 months ago | on: An Honest Review of Go (2025)
It's mostly false.
Technically, if you use `fmt.Errorf`, then the caller can't get anything useful out of your errors.
Types are promises. All the `error` interface promises is a string representation. I acknowledge that most of the time there is more information available. However, from the function signature _alone_, you wouldn't know. I understand that this is more of a theoretical problem then a practical problem but it still holds (in my opinion).
benrazdev | 2 months ago | on: An Honest Review of Go (2025)
I agree with you. I don't have problems with the `if err!=nil` syntax.
From my post: > It’s become something of a meme to bemoan the supposed difficulty of writing if err != nil. I actually won’t make that point because I think it is a very surface level point that has been talked about to death and *I don’t think the ‘verbosity’ of this code snippet is such an issue.*
I apologize if my language was ambiguous on whether or whether not I had a problem with that syntax.
>In his example author could easily use his `progError` type instead.
I agree, but it was my impression that type erasure was more idiomatic. I should have made it clear that I was criticizing that idiom, not the language.
>Well, no. See for wrap/unwrap functionality https://go.dev/blog/go1.13-errors
You are right. I should have done my research on that before writing that point. I still think that downcasting isn't the most elegant solution because it defeats the point of using the opaque return type but I agree that it is nowhere near as much of a problem as I thought it was.
benrazdev | 2 months ago | on: An Honest Review of Go (2025)
benrazdev | 2 months ago | on: An Honest Review of Go (2025)
I want to clarify that I think very highly of Go as a language. I think it gets most things right. It's hard to introduce an abstraction into a language while still making sure that it's not abused. Rust's trait and type system, while powerful have been abused to create some absolutely incomprehensible and long types. Go, on the other hand, doesn't suffer from this issue. If I was too harsh against Go, that was certainly a mistake.
I think that the criticisms of my section on error handling are, for the most part, spot on. My impression was that type erasure for errors was the idiomatic solution, which is patently untrue. When writing the blog post, I was unaware of the functions in the `errors` module as well as the syntactic sugar and general acceptance of downcasting errors. While I would still maintain that Rust errors are more convenient to work with, I must admit that there really isn't any good excuse for my ignorance on this.
When it comes to enums, I stand by my statements on them.
I still believe that it is useful to restrict the values a type might have. And no, I am not using the term enum to mean a rust-style "enum" (tagged union). I am talking about classical enums, more or less as they appear in C.
As an aside, I am not terribly surprised that my website doesn't work well on some browsers. I hacked together the website including the HTML and CSS a couple of years ago and some of the hacks I used I ought to be ashamed of.