logoalt Hacker News

saghmlast Friday at 11:43 AM1 replyview on HN

I assume with "Java-style exception handlers" you're referring to panics? If this were sufficient, then people would be using it more for error handling. I'd argue that a large part of why people don't write code using them as error handling more often is because of the syntax, and that's ultimately what this whole discussion is for me. This is probably another area where we just fundamentally disagree, because I don't really consider there to be a necessity to fully solve the "real problem" instead of providing something smaller that alleviates specific minor warts.

What's strange to me is that the main reason this seems like the best path forward to me is because it doesn't require large fundamental changes to the language, and I'm skeptical that there's any fix to the underlying issues that you're concerned about that wouldn't require those sorts of changes, but somehow your objections seem to mostly be on the grounds that you also don't want those types of changes. To me, the insistence the entire real problem needs to be solved for anything to be worth doing is in practice incompatible with the requirement not to change the language fundamentally, so the question becomes whether its worth considering changes that don't fully solve what you consider to be the real issue. I think that's where the disconnect is; I'm not really trying to argue for a solution to the problem you're concerned about because I don't consider it to be realistic that it will ever get solved, so I'm arguing that making smaller changes to reduce the impact of the problem without solving it fully would be worthwhile compared only to the status quo rather than some ideal solution that I don't think exists. I'm not trying to say that it's an absolute certainty that there's no way to fix the issues you're concerned about without fundamentally changing the language, and I'd be just as happy as you if I turn out to be wrong! It doesn't really feel like you're rebutting the actual suggestion I'm making though because you're interpreting my claim that there isn't any way to solve the problem generally without changing the language fundamentally as my advocating for those fundamental changes, which is not what I actually think, and from my perspective isn't what I've been saying at all.


Replies

9rxlast Friday at 2:46 PM

> I'd argue that a large part of why people don't write code using them as error handling more often is because of the syntax

I don't see meaningful difference in the syntax as compared to other languages with a similar feature: https://go.dev/play/p/RrO1OrzIPNe How deep are we really going to split hairs here?

If it were commonly used you could clean it up a little, like how the somewhat recently added iterators feature cleaned up what people were already doing with iteration, but in this case since it is so rarely used in the first place, why bother? "If you build it, they will come" is Hollywood fantasy. Unlike this, the use of iterators was already prevalent before the iterators feature was added.

Let's be honest: If it were useful, people would already put up with the above being slightly less than perfect. People will actually put up with a lot of shit when something is useful at its core! But that they are doing this almost never is quite telling.

> What's strange to me is that the main reason this seems like the best path forward to me is because it doesn't require large fundamental changes to the language

Or maybe no changes at all. Would using the above really be so bad from a syntactical point of view? The much bigger problem, and why pretty much all modern languages have moved to returning errors as the defacto solution, is that it exhibits all the same fundamental problems as errors under Java exception handling. That is something syntax cannot fix.

And, well, for the exceptional (pun intended?) cases where Java-style exception handling really its the best option to suit your circumstances: It's there to use already!