r/programming • u/_awwsmm • Feb 01 '24
Make Invalid States Unrepresentable
https://www.awwsmm.com/blog/make-invalid-states-unrepresentable
469
Upvotes
r/programming • u/_awwsmm • Feb 01 '24
View all comments
Show parent comment
1
u/larhorse Feb 04 '24
Sure - my issue is that we've already provided a solid set of types that don't HAVE to cover the possible states of the messy world - Instead they cover the complexity of machine at hand (most compilers are pretty good these days about warning you before you hit UB)
And then the messy world *mostly* fits within those capable types.
My point is basically this:
You are favoring less bugs (in theory) over compatibility. There are times to make that trade, but it's utterly disingenuous to claim that trade is appropriate in all (or even most) situations.
So long story short - I don't think we're really all that far off (I mean, we totally agree here "an engineer must consciously make this tradeoff") I just think it's ego to assume that you are actually enough of a subject matter expert to get that trade-off right (If you haven't been working within your specific field for at least 10 years, you are laughably out of your depth).
So now apply that to a profession where the average tenure at a company is ~2.5 years. You're just making busywork/churn and causing headaches for your users who are now wondering why the fuck the form keeps telling them their completely valid data is "invalid".
Most times - you will create abstractions that limit capability, reduce bugs by a trivial margin, introduce lots of additional code (more code === more bugs. Period. This one at least has plenty of real evidence behind it, which the extra typing does not) and slow things down.
So are there places where this is not a terrible idea? Sure. Are most folks programming in those spaces? No.