Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
Mawr
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
46 ms
·
691.
▲
by
Mawr
2y ago
> One point to consider with exceptions: It is "impossible" to ignore an exception. The function implementation is telling (nay: dictating[!] to) the caller: You cannot ignore this error code. At the very least, you must catch,
692.
▲
by
Mawr
2y ago
You can get pretty close with generics: func Must[Value any](v Value, err error) Value { if err != nil { panic(err) } return v } Must(strconv.Atoi("not a number")) ( https:
693.
▲
by
Mawr
2y ago
Well we are in a discussion thread about a language that does just that :) I see two issues with the `?` operator: 1. Most Go code doesn't actually do return nil, err but rather return nil, fmt.Errorf("opening file
694.
▲
by
Mawr
2y ago
I don't see how it's possible to do it blindly unless the code gets autogenerated. If you're typing the `if err != nil` then you've clearly understood that an error path is there. There's no requirement for the call
695.
▲
by
Mawr
2y ago
It's better because you do not need to remember to check for nil, the compiler will remind you every time by erroring out until you handle the second return value of `option.Get()`. > Of course, this is often left out, but you can j
696.
▲
by
Mawr
2y ago
I'm not sure what exactly you mean by acknowledgement, but here are some counterexamples: - A proposal for sum types by a Go team member: https://github.com/golang/go/issues/57644 - The community proposa
697.
▲
by
Mawr
2y ago
Perhaps, but there have been several proposals along those lines and nobody seems capable of figuring out a sensible implementation. A funny drawback of the current Go design that a Result type would solve is the need to return zero values
698.
▲
by
Mawr
2y ago
Using an Option instead of a pointer buys you the inability to forget to check for nil. Just need to make sure the Option exposes the internal value only through: func (o Option[Value]) Get() (Value, bool) { return o.value, o.
699.
▲
by
Mawr
2y ago
Sure, I just don't think it's that significant. Humans don't read/parse code character-by character, we do it by recognizing visual patterns. Blocks of `if err != nil { }` are easy to skip over when reading if needed.
700.
▲
by
Mawr
2y ago
The difference is that all code paths are explicitly spelled out and crucially that the programmer had to consider each path at the time of writing the code. The resulting code is much more reliable than what you end up with exceptions.
701.
▲
by
Mawr
2y ago
See the example with the `?` operator: https://github.com/borgo-lang/borgo?tab=readme-ov-file#error... The main benefits of a Result type are brevity and the inability to accidentally not handle an error.
702.
▲
by
Mawr
2y ago
Yes but the impression is largely superficial. The error handling gets the job done well enough, if crudely.
703.
▲
by
Mawr
2y ago
> Is there any good reason for wanting try/catch other than being lazy? It's the best strategy for short running programs, or scripts if you will. You just write code without thinking about error handling at all. If anything go
704.
▲
by
Mawr
2y ago
FSD only drives in a subset of conditions humans drive in so the comparison is invalid.
705.
▲
by
Mawr
2y ago
You're absolutely technically correct, in the "spherical cow in a vacuum" sense. In reality though, essentially all Go code out there handles errors through the pattern of checking if the error in a `(value, error)` tuple ret
706.
▲
by
Mawr
2y ago
Go doesn't use exceptions as a primary way of handling errors, which is what we're talking about here. Pedantry is not welcome.
707.
▲
by
Mawr
2y ago
You're reading way too much into what the parent poster said. He just correctly stated the overall sentiment of the community. That said, suggesting adding exceptions to Go is about as reasonable as adding a GC to Zig. How much effort
708.
▲
by
Mawr
2y ago
Good question. It's probably to be able to continue using the Go ecosystem. You could not incrementally switch a Go codebase to a Rust-based Borgo, but you can when it's Go-based.
709.
▲
by
Mawr
2y ago
> In biking heavy European cities, average trips are well less than a mile. The average in the Netherlands in 2016 was ~3.5km (~2.2 miles) for ordinary bikes and ~5km (~3.1 miles) for ebikes. [1] "For trips of up to 7.5 km (65% of a
710.
▲
by
Mawr
3y ago
Cars aren't sustainable transportation in the first place.
711.
▲
by
Mawr
3y ago
Can see them here: https://youtu.be/52O3cYsyZMo?t=482
712.
▲
by
Mawr
3y ago
> This distance must be fairly short. Not really a factor in dense urban environments. Everything within 5km is easily reachable within ~15 mins. Especially so once you factor in ebikes. > You must be relatively young/fit/he
713.
▲
by
Mawr
3y ago
With FSD being tested on public roads you're his guinea pig whether you want to or not.
714.
▲
by
Mawr
3y ago
https://xkcd.com/1530/
715.
▲
by
Mawr
3y ago
The numbers you bring up are insignificant at the scales involved. > Case in point: almost 40 years later, the Chernobyl Absolute Exclusion Zone is still quite literally 1000 square miles. Whole 1000 square miles? Looks like the habitabl
716.
▲
by
Mawr
3y ago
> An example of something that for sure saves lives and lowers public costs is mandating adults wear helms on bicycles. For sure huh :) See my older post: https://news.ycombinator.com/item?id=39658466 TL;DR: "Cyclin
717.
▲
by
Mawr
3y ago
Well that's a lame video. Watch this: https://youtu.be/SYLAi4jwXcs?t=139
718.
▲
by
Mawr
3y ago
https://news.ycombinator.com/item?id=38146676 "I bought a Model 3, taking delivery in July 2019 and paying £5800 for the FSD extra. My view was that Tesla had failed to deliver on the contract with how they described F
719.
▲
by
Mawr
3y ago
Or even simpler - build more green spaces with grass, shrubbery and trees. Peeing on those is harmless and they provide other significant benefits as well.
720.
▲
by
Mawr
3y ago
Fun fact: The equivalent concept in CS terms is "backpressure".
More ›