4 ms·
That's just a less likely case of giving a function the wrong input values, which is also undefined. So no it's not much worse than usual.
by ReflectedImage 4y ago
That's just a less likely case of giving a function the wrong input values, which is also undefined.
So no it's not much worse than usual.
- twblalock 4y agoNo, it's actually different, because in a statically typed language it would not even be possible to write code that would pass the wrong types of inputs, because it would not compile! Also, if there are input values of the right type that cannot be handled properly, that should also be tested! That is the kind of thing tests are for! Example: you write a function that divides two numbers. It's not possible to divide by zero. You should absolutely have a test that passes in a divisor of zero and asserts that some kind of custom DivideByZeroException is thrown. If you know that certain inputs are out of range, you should test them explicitly -- otherwise you're being sloppy. If there is a large number of inputs out of range, you should test all of them, and you can use a `for` loop if you have to. The difference is, if you have a valid input out of range, that is all you need to test -- the language itself takes care of all the "wrong type" tests for you. Otherwise you have to write them yourselves, and if you don't, you don't actually have good coverage. I understand that it is customary in dynamic languages to not write those tests, but that is merely another argument for the superiority of static typing.
- ReflectedImage 4y agoIf you pass the wrong input values to a function, it will in 99% of all cases give you the wrong result, throw an exception, etc. Passing the wrong type is considerably rarer than the wrong value so need not be considered. Well one programmer using dynamic typing can deliver the output of three programmers who use static typing. That why people use dynamic typing, from a business perspective it's a far more compelling argument than the one you are making.
- twblalock 4y agoWhat you are saying all breaks down with larger codebases. A codebase with 1000 people working on it benefits dramatically from static typing. Everyone who has tried to do the same thing with dynamic typing has learned that. And quite a few companies that started off with Python had to rewrite everything in Java. If you honestly think that nobody ever passes the wrong type, you've never worked on a complex dynamic codebase with a lot of people. It happens all the time.
- ReflectedImage 4y agoThe more modern solution is to break the large codebases into self contained microservices. In which case dynamic typing scales indefinitely. I've worked on dynamically typed codebases for a long time. Passing the wrong type is very rare. I mean how would the code pass the unit tests if it was passing the wrong type?
- gruffle 4y agoHow are the interfaces between these microservices defined? Without types? Lol
- ReflectedImage 4y agoThe interfaces do have types (and also proper versioning) but the internal code to the microservices does not.
- gruffle 4y agoThink about that for another second and see if you can spot the obvious huge flaw there.
- ReflectedImage 4y agoI think you will be disappointed with the basic types: int, str, bool being used in one line per 1000 lines of code.
- gruffle 4y ago> Passing the wrong type is considerably rarer than the wrong value so need not be considered. Passing the wrong value doesn't just happen randomly. It happens because of errors in logic many of which can be caught with a strong static type system.
- ReflectedImage 4y agoBut most can not.
- gruffle 4y agoK, I'll take your word for it.