Hacker News new | past | comments | ask | show | jobs | submit | more zgk7iqea's comments login

go is step by step reinventing exceptions


Exceptions typically unwind the stack, producing a stack trace similar to what certain Go error types already do. Go's panic does actually unwind the stack. In a sense, Go has had Java/Python style exceptions, from the beginning, through panic and recover. This project distinguishes itself from that pattern in the README.

As far as error handling is concerned, errors as values is the modern thinking. Go is not behind the times here. If you squint, the `(T, error)` return type is very similar to Rust's `Result`, and the `if err != nil` idiom is basically Monadic control flow.


> If you squint, the `(T, error)` return type is very similar to Rust's `Result`

This requires the kind of squinting where 9 x 9 = 81 is basically the same as 9 + 9 = 18 right? I mean, they're roughly the same symbols, albeit one at slightly different angle, and in a different order...

Result is a sum type, as are a lot of key things in Rust. Take the Rust type Result<bool,()> - this has three possible values, Ok(true), Ok(false), Err. The analogous Go product type has four possible values, (false,false) (false, true), (true, false) and (true, true).


the go type has the implicit restriction that if error is true, then the result is meaningless. So really it has 3 meaningfully distinct values.


That depends on perspective.

An idiomatic Go function will ensure that T is always useful, regardless of the error state. At very least it will return the zero value for T, to which the Go maxim states: Make the zero value useful. From the perspective of writing the function returning (T, error), there will always be four states, with T and error being independent of each other. Anything else is faulty design.

Unfortunately, some early Go code written before things were well understood left T to be undefined given certain error states, so one cannot assume that T will be valid in all cases for all functions. This does mean that the caller's perspective can only reliably consider three states absent of diving deeper (e.g. reading the documentation).


> implicit restriction that if error is true, then the result is meaningless

By 'implicit' I assume you mean 'by convention'? I say this because unless I've misread the go spec (and that's a distinct possibility), function returns are either a single value or a tuple and there is no specification on tuple returns and mutually exclusive values.

FWIW, I mostly like go and work with it practically every day. I absolutely loathe it's ideas on error handling. I have quite strong feelings on the subject that aren't fit for polite discussion.


> I absolutely loathe it's ideas on error handling.

Its idea is simply that error is just state like any other. I find that to be quite reasonable – and something I miss dearly when I work in other languages which try to get overly fancy to try and hide that fact. There is nothing special about errors. The machine certainly has no concept of errors. Why does it need special constructs?

Bad practices like assuming T and error are dependent do break the ideas, but a language can only hold the hands of poor developers so much. Someone determined enough to write bad code will do so in any language.

Realistically, if there is a handling problem, it is a problem for all values of all kinds. Every single problem one can point to about handling errors is also a problem when handing names, email addresses, random numbers, etc. To single it out as an error handling problem specifically is flawed.

> I have quite strong feelings on the subject that aren't fit for polite discussion.

I'd love to hear more. You won't hurt my feelings. Getting worked up about a programming language discussion is illogical.


> To single it out as an error handling problem specifically is flawed.

Sure, product types are the wrong shape for several different problems, not just error handling. Go doesn't have any other shape of user defined types so... too bad you're just stuck with something the wrong shape. Errors are an example where it's more obvious to more people.

Also the machine actually does know about errors, for example the x86-64 architecture defines several kinds of faults, for which provided handlers will be executed, Linux actually deliberately makes it impossible to run such fault handlers after any other way to reboot has proved ineffective, then trips a fault, because it knows an x86 CPU which can't run the fault handlers despite a fault will give up and reboot, which is what Linux was trying to achieve anyway. ARM has error interrupts, POWER has layers of nested error handling.


> product types are the wrong shape for several different problems

While that is true, the shape has no bearing on the handling problem. Go could have every type shape-defining feature ever conceived and it would still have the very same handling problem – for errors and everything else.

> Errors are an example where it's more obvious to more people.

In my experience, the vast majority of bugs I encounter in the real world are related to the handling problem of non-error values. That is where it is most obvious, and not just in Go. I expect errors only get talked about because it is fashionable to repeat what someone else said, not because anyone put any thought into it.

> Also the machine actually does know about error

Only within the confines of one human interpretation of how the machine functions, just as is the case for code. The machine itself has no such concept. It doesn't have awareness that a given state is an error or a rainbow.


go basically has exceptions with panic & recover. and it’s perfectly simple to add stack traces to errors, should you want it.


That completely misses the fact that you need the providers of the code several layers away from you to make those choices and they frequently don't.

I can add stack traces and raise panics all day long in my code and it will never help me trace a deep error in my system. The collective blindness to that in the go world is staggering.


At that point, why not use Home-Manager (nix pm) to configure your shell? Should be easier to manage


Actually I'm running NixOS on an old ThinkPad I have lying around here. Home Manager works great! But Ubuntu currently has the popularity network effect going for it, so.


No wonder people use GitHub even if it scans your repos. If a service is unreliable, why bother?


https://www.githubstatus.com/history

Don't praise GitHub too much. They've averaged an issue every 2 days for the past 3 months.


Issues don't mean downtime though, and GitHub has lots more features. For example an issue noted here was stale commits of up to 7 minutes in 9% of new pull requests... I'm willing to bet such issues aren't acknowledged by most platforms


Because GitHub is never down...

I'm not sure which one has a better uptime, but GitHub seems to on HN at least once a month

https://hn.algolia.com/?dateRange=all&page=0&prefix=false&qu...


Without actual numbers, how does this make any sense.


The reality I think is, the average user probably doesn't care about snappyness as long as it is not too bothersome. The path of least resistance is opening the webmail (no setup required).


I wonder if the EU is going to use Matrix for messenger interop. Hopefully not


you can disable stage manager. i believe it is off by default


IIRC apple significantly improved safari performance in the last year or so. It’s even faster than chrome in a lot of cases


Hey did that in the past with the amazon integration


Apps can circumvent these ”firewalls” quite easily via IPC/Intents.

For example, if you block facebook with a firewall, it can still send an intent to the download manager to make network connections.

(see https://madaidans-insecurities.github.io/android.html#firewa...)


GrapheneOS is working on a permission to block that too


GrapheneOS alreasy has such a permission. I use it for Apps that shouldn't require internet access, like my keyboard.


The current network permission does not block IPC


Unfortunately, Firefox‘s security on Android is .. not the best

(https://madaidans-insecurities.github.io/firefox-chromium.ht...)


Wow that article that completely misses the point, yes, Chrome has better sandboxing, which offers it marginally better security, but that has nothing to do with Firefox's far better privacy features.

For people who are not spies or hoarding millions worth of cryptocurrencies on their desktop PCs, they're not likely running across zero day exploits on the regular. They are however running across trackers galore and Firefox's tracking protection and anti-fingerprinting features are likely to make a larger difference in practice for all but the most targeted of individuals.


It's not just Android.

Unfortunately.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: