Beehaw
  • Communities
  • Create Post
  • search
    Search
  • Login
  • Sign Up
AlexIT ( AlexKochetkova@programming.dev )  to Programming@programming.devEnglish · 2 years ago

Why I Prefer Exceptions to Error Values

cedardb.com

external-link
message-square
32
link
fedilink
45
external-link

Why I Prefer Exceptions to Error Values

cedardb.com

AlexIT ( AlexKochetkova@programming.dev )  to Programming@programming.devEnglish · 2 years ago
message-square
32
link
fedilink
Exceptions are often a better way to handle errors than returning them as values. We argue that traditional exceptions provide better user and developer experience, and show that they even result in faster execution.
  • BatmanAoD ( BatmanAoD@programming.dev ) 
    link
    fedilink
    arrow-up
    1
    ·
    2 years ago

    There’s also a massive tradeoff for when the error condition actually occurs. If an exception does get thrown and caught, that is comparatively slowwww.

    • UndercoverUlrikHD 🇳🇴 ( UndercoverUlrikHD@programming.dev ) 
      link
      fedilink
      arrow-up
      1
      ·
      2 years ago

      The author pointed out how exceptions are often faster than checking every value. If your functions throws an error often enough that Exception handling noticeably slow down your program, surely you got to take a second look at what you’re doing.

      • BatmanAoD ( BatmanAoD@programming.dev ) 
        link
        fedilink
        arrow-up
        1
        ·
        2 years ago

        It depends what kind of errors you’re talking about. Suppose you’re implementing retries in a network protocol. You can get errors pretty regularly, and the error handling will be a nontrivial amount of your runtime.

Programming@programming.dev

programming@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programming@programming.dev

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 134 users / day
  • 705 users / week
  • 1.74K users / month
  • 4.19K users / 6 months
  • 449 local subscribers
  • 28.8K subscribers
  • 2.95K Posts
  • 23K Comments
  • Modlog
  • mods:
  • snowe ( snowe@programming.dev ) 
  • Ategon ( Ategon@programming.dev ) 
  • UlrikHD ( UlrikHD@programming.dev ) 
  • bugsmith ( bugsmith@programming.dev ) 
  • Spyro ( Spyro@programming.dev ) 
  • BE: 0.19.15
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code