Re:Tests aren’t enough: Case study after adding type hints t...
by freemint on Monday October 18, 2021 @01:57PM
(#28908557)
Sounds like a brilliant case for multiple-dispatch.
[ Parent
| on HN ]
Re:Tests aren’t enough: Case study after adding type hints t...
by kennywinker on Monday October 18, 2021 @07:21PM
(#28913101)
Right so we have:
function find_user(person: string)
and also: function find_user(person: Object)
how long before someone writes this: find_user(person: { name: "dave" })
meanwhile, someone else, not suspecting that they'll be handed a weird half-formed `User` object adds `person.id` somewhere in the body of the Object version of `find_user` and now we have a weird edge-case where very rarely `find_user` panics because the user object we're handed doesn't have an id??? Great, I just lost an hour trying to dig that out of the logs, and the users are starting to think of the product as flakey because the bug has been in prod for over a month before we finally believed them enough to look into it.Just. Use. Types. Multiple dispatch won't save you on its own. You NEED compile-time types.
Re:Tests aren’t enough: Case study after adding type hints t...
by david422 on Tuesday October 19, 2021 @09:24AM
(#28917795)
Somebody downvoted you, I'm guessing because they think this is a silly example and have never actually seen something like this. I have, in a production code base.
Re:Tests aren’t enough: Case study after adding type hints t...
by freemint on Wednesday October 20, 2021 @06:53AM
(#28929196)
Multiple dispatch and compile time times are not exclusive at all.
Re:Tests aren’t enough: Case study after adding type hints t...
by kennywinker on Thursday October 21, 2021 @03:32PM
(#28949766)
I'm saying the problem isn't solved by multiple dispatch alone, but it is solved by compile time types alone. You can use both together, of course.
Re:Tests aren’t enough: Case study after adding type hints t...
by freemint on Friday October 22, 2021 @06:41PM
(#28963642)
The issue whether the language is interpreted or compildd (which would distinguish compile time types from strong types) is in my opinion completely orthogonal to the issue of how dispatch works. Strong types and multiple dispatch fix the issues I see even in an interpreted language.