60
you are viewing a single comment's thread
view the rest of the comments
[-] BehindTheBarrier@programming.dev 2 points 2 months ago* (last edited 2 months ago)

But nothing is forcing you to check exeptions in most languages, right?

While not checking for exceptions and .unwrap() are pretty much the same, the first one is something you get by not doing anything extra while the latter is entirely a choice that has to be made. I think that is what makes the difference, and in similar ways why for example nullable enabled project in C# is desired over one that is not. You HAVE to check for null, or you can CHOOSE to assume it is not by trying to use the value directly. To me it makes a difference that we can accidentally forget about a possible exception or if we can choose to ignore it. Because problems dealt with early at compile time, are generally better than those that happen at runtime.

[-] kersplomp@programming.dev 1 points 2 months ago

I see your concern, but in practice that's not what happens in languages like Java and Python with exceptions. Not checking for exceptions is a choice because everyone knows you need to check in your top-level functions. Forgetting to catch is a problem that only hits newbies.

[-] OmnipotentEntity@beehaw.org 4 points 2 months ago

A problem that only affects newbies huh?

Let's say that you are writing code intended to be deployed headless in the field, and it should not be allowed to exit in an uncontrolled fashion because there are communications that need to happen with hardware to safely shut them down. You're making a autonomous robot or something.

Using python for this task isn't too out of left field, because one of the major languages of ROS is python, and it's the most common one.

Which of the following python standard library functions can throw, and what do they throw?

bytes, hasattr, len, super, zip

[-] kersplomp@programming.dev 0 points 2 months ago

Too long, didn't read

this post was submitted on 13 Sep 2024
60 points (86.6% liked)

Programming

17314 readers
78 users here now

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



founded 1 year ago
MODERATORS