I've seen a lot of new developers shocked by this approach, which surprises me a little. They seem to think that it's up to the application to handle all errors, even those of the programmer(s). This, of course, is unreasonable since it would essentially require knowing all the bugs in advance. :-)
I was on a team for a short while (Java programmers) and their frontend code was really overly "careful". For example, they would always check if a method existed, before calling it. var o = new SomeObject(); if (o.computeSomething != null && o.computeSomething != undefined) { o.computeSomething(...); } Their reasoning was that in JavaScript (with the old syntax) you just add functions to the prototype, so you could…
How “let it fail” leads to simpler code
51–60 of 165 posts
Re: How “let it fail” leads to simpler code
#52Earlier quoted context omitted.
>Solutions and suggestions would be appreciated! Use a language with strong typing?
Yeah, that one is indeed obvious. That's what everyone advocating for static typing (which you mean, somebody commented already) has been shouting all the time. The problems coming from dynamic typing are just unnecessary, and the only thing that made python palpable for me again was mypy, which introduces static typing into python. But it's not the default, so it still only really works for small things.
Re: How “let it fail” leads to simpler code
#53I learned from working on aviation systems is that when a system enters an unknown state, it must be disabled and locked out. In software, this is known as an assertion failure. When the assert trips, the program is, by definition, in an unknown state. A program cannot reasonably be allowed to continue in an unknown state - it may launch nuclear missiles. The only thing to be done is exit directly, do not pass Go, do…
Re: How “let it fail” leads to simpler code
#54I don't agree with this approach. Say you have a network service that relies on other network services. It is not difficult to write those such that they know to back off / retry when something disappears. It's extremely useful in a lot of situations: if you do work on a laptop that gets regularly unplugged, having running test services that know to reconnect makes your life easier. In production, having things autom…
What you're describing are "known" states; the idea behind "let it fail" is that you shouldn't write code that exhaustively handles every single potential outcome, just the ones that are part of your code's path in general use. Definitely write code to handle network issues. Don't write code to handle random bitflips, ways to handle garbage coming back from the service you're connecting to, or try to handle OOM error…
When my email went down last week, I wasn't worried. Eventually all messages would arrive.
I like that system.
Re: How “let it fail” leads to simpler code
#55In pure code, an exception could essentially be passed up, and transformed into an error return value at the point where it's called by non-pure code.
Re: How “let it fail” leads to simpler code
#56For our liveview project, a lot of the bugs we find are edge cases in the pattern match. We find the bug in appsignal, build another arity match and go on with our day. It's pretty cool. I've been working in Elixir exclusively since 2016. I do think a lot of the Let It Fail is just marketing from Elixir (and BEAM) but there is a lot of truth in it. In reality you will most definitely not write everything under an exp…
That's the point of the supervisor _tree_. Certainly not every process will have its own supervisor, but all processes should be linked to other processes, which are linked to other processors, and at some point you have a process that is quite fundamental to the application and has a supervisor.
As long as there's a supervisor somewhere on that tree, the whole subtree will be restarted, hopefully in a non-erroneous state, and the application will continue on its merry way.
Re: How “let it fail” leads to simpler code
#57Earlier quoted context omitted.
>Solutions and suggestions would be appreciated! Use a language with strong typing?
Python is strongly typed. You want statically typed. (Instead of duck typed / dynamically typed)
class foo:
pass
obj = foo()
obj.bar = "I thought Python was strongly typed?"
print(obj.bar)
And even better: class foo:
a = 42
obj = foo()
print(obj.a)
del foo.a
print(obj.a)
Whatever your opinion on what the imprecise sentence "strongly typed language" should mean, these are definitely not features of one.Re: How “let it fail” leads to simpler code
#58I learned from working on aviation systems is that when a system enters an unknown state, it must be disabled and locked out. In software, this is known as an assertion failure. When the assert trips, the program is, by definition, in an unknown state. A program cannot reasonably be allowed to continue in an unknown state - it may launch nuclear missiles. The only thing to be done is exit directly, do not pass Go, do…
What if the plane is mid flight?
Re: How “let it fail” leads to simpler code
#59I've seen a lot of new developers shocked by this approach, which surprises me a little. They seem to think that it's up to the application to handle all errors, even those of the programmer(s). This, of course, is unreasonable since it would essentially require knowing all the bugs in advance. :-)
I was on a team for a short while (Java programmers) and their frontend code was really overly "careful". For example, they would always check if a method existed, before calling it. var o = new SomeObject(); if (o.computeSomething != null && o.computeSomething != undefined) { o.computeSomething(...); } Their reasoning was that in JavaScript (with the old syntax) you just add functions to the prototype, so you could…
It also helped when tutoring new python students -- when they mixed space-indented code they copied from the internet with tab-indented code they copied from the internet, they'd get all sorts of fun errors. Setting the tabwidth to an even number sometimes allows them to hide. 3, though, really makes them stick out.
Re: How “let it fail” leads to simpler code
#60Earlier quoted context omitted.
>Solutions and suggestions would be appreciated! Use a language with strong typing?
Python is strongly typed. You want statically typed. (Instead of duck typed / dynamically typed)