5 ms·
I remember people being so excited to use error values instead of exceptions in mainstream languages. But this libraries plus error values combo looks even more
by nromiun 1y ago
I remember people being so excited to use error values instead of exceptions in mainstream languages. But this libraries plus error values combo looks even more complex to me.
- csomar 1y agoIt is not more complex. It is a complex problem and raising exceptions is akin to just giving up (vs. properly handling and reporting the errors).
- nromiun 1y agoThat is akin to saying using a GC is giving up on safe memory allocation, and the borrow checker is the only solution to a complex problem. Exceptions are handled gracefully in real world projects as well, otherwise Python, Java etc would have died a long time ago.
- csullivannet 1y agoMaybe this is my Golang dev leaking, but I intuitively thought that `try: / except:` in Python is essentially the same thing as `if err != nil`, just my IDE doesn't scream at me if I don't catch them.
- tcfhgj 1y agoMaybe you are not giving that up, but you are giving up doing memory management "properly", i.e. use more memory and CPU time than necessary for convenience.
- nromiun 1y agoLike writing only in assembly is "proper" programming? Using more memory and CPU time than necessary for convenience?
- tcfhgj 1y agosystems programming languages compile right down to machine code
- nromiun 1y agoBoth borrow checker and GC use malloc/free internally as well. According to you there is no difference between the two.
- tcfhgj 1y agoyes, there is: GC will not use stack allocation and it will add another layer of memory management resulting in significant memory overhead (runtime overhead)
- nromiun 1y agoOf course they do. For example C#, D, Nim etc all use stack allocation with their GC. Not to mention Rust also allocates dynamic objects on the heap. So not sure what is your point.
- tcfhgj 1y agoThe language may allow it, but it's not GC managed then. My point is runtime overhead. In C# structs and their refs (including a simple borrow checker to detect invalid ref use) were introduced to escape GC management und reduce it's runtime impact on the programs
- photon_garden 1y agoTheir code is more complex in some ways (for example, it’s verbose). But in languages with exceptions, if you want to know how a function can fail, you have two options: - Hope the documentation is correct (it isn’t) - Read the body of the function and every function it calls Reasonable people can disagree on the right approach here, but I know which I prefer.
- nromiun 1y agoOr catch the top level function and see every exception in your project? Tell me which language does not have a top level main function?
- zaphar 1y agoThis is the "I don't care what fails nor do I wish to handle them" option. Which for some use cases may be fine. It does mean that you don't know what kinds of failures are happening nor what the proper response to them is, though. Like it or not errors are part of your domain and properly modeling them as best you can is a part of the job. Catching at the top level still means some percentage of you users are experiencing a really bad day because you didn't know that error could happen. Error modeling reduces that at the expense of developer time.
- nromiun 1y ago"I don't care what fails" means not catching any exception/error. My comment was the exact opposite of the idea. Top level function will bubble up every exception, no matter how deep or from which module.
- _flux 1y agoBut the case when you actually learn what errors can happen is when your users start complain about them, not because you somehow knew about it beforehand. Or maybe you have 100% path coverage in your test..