Preferences

No, all languages don't need to share the same idioms.

But you've been making arguments like the following:

> Like in the same way you might forget to write pattern matching code?

> No, it's entirely possible to forget. That should be obvious. It is a functional necessity for you to be able to forget as you can only type so much at a time. You cannot possibly write code to call a function and perform pattern matching on the result at the exact same moment in time.

And that is just disingenous. That's not you having a different opinion on something that's a matter of taste. That's you repeatedly trying to suggest that both forms of error handling are equally likely to suffer from somebody accidentally failing to handle the error.

And obviously that's not true, exactly because the returned values are logically separate in Go and aren't in the other lanuages. That is, in typical Go code, if you assign the error to err but omit the if err != nil {} boilerplate, the code will typically compile. (It'll compile, because the error variable is basically always named err, and most functions will have other references to that variable, such that the "unused variable" compiler diagnostics don't trigger.)


> the code will typically compile.

It may compile, but won't pass the test. Are you under the impression that a developer suddenly becomes blind after compilation and somehow magically won't see that the test failed? That doesn't happen. How are you going to forget? In reality, your forgetfulness is going to be made loud and clear. –– We offered a challenge to another account. He failed miserably, as did I, but maybe you can do better? https://www.hackerneue.com/item?id=42865349

And, before you even think it, no, you cannot skip that test in another language with pattern matching. There is nothing pattern matching can do to help you with what it is testing. It should be obvious to you that even if you do successfully pattern match, you might, for example, "forget" to return the right value. The documentation and additional checks and balances are required either way. The type system does not save you here.

And, before you even think it, no, "but what if I am a dummy who doesn't understand his tools or how to program???" doesn't work either as if you are that dummy then you aren't going to use the right types to activate the pattern matching semantics of which we speak, so pattern matching is not going to notice anyway. There is a necessary assumption in this discussion that you understand the tools, idioms, and software engineering in general. We cannot even meaningfully talk about pattern matching alone without that assumption.

So, how are you going to forget, exactly? You won't. This isn't a real thing. Pattern matching is cool, though, with many real benefits. It is funny that someone decided to focus on a made up benefit instead of what makes it actually great. But this is a commonly repeated trope so I'm sure we got here because he blindly repeated it without thinking about it for even a millisecond.

This item has no comments currently.

Keyboard Shortcuts

Story Lists

j
Next story
k
Previous story
Shift+j
Last story
Shift+k
First story
o Enter
Go to story URL
c
Go to comments
u
Go to author

Navigation

Shift+t
Go to top stories
Shift+n
Go to new stories
Shift+b
Go to best stories
Shift+a
Go to Ask HN
Shift+s
Go to Show HN

Miscellaneous

?
Show this modal