3 ms·
Nope, static typing triples the average bug count of a piece of software. Using static typing add complexity to your code and complexity leads to more bugs. St
by ReflectedImage 3y ago
Nope, static typing triples the average bug count of a piece of software. Using static typing add complexity to your code and complexity leads to more bugs.
Static typing is where you significantly decrease your development speed and significantly increase your bug count in order to increase the performance of your software.
- therealdrag0 3y agoCan you elaborate on why complexity increases?
- ReflectedImage 3y agoYou fill your codebase with additional information for the compilers' benefit and not the benefit of the software developer. In any large statically typed program, 2 out of the 3 lines exist to make the compiler happy rather than the software developer. Static typing is a terrible terrible way to develop code once you start measuring it objectively.
- therealdrag0 3y agoI’m misunderstanding or that’s just not true. Maybe you’re imagining classic Java? I use Scala and the syntax is pretty slim to get very rich typing. Love it compared to non-static typing.
- ReflectedImage 3y agoWell Java syntax is very verbose, but I'm referring to the effects of static typing on the program structure. Dynamically typed programs have much simpler structures and are much easier to reason about and test than their static typed counterparts. The larger the program you write with static typing, the worse it becomes compared to it's dynamically typed counterpart. The internal complexity of statically typed programs grows at a much higher rate. This increases development times and decreases program correctness. Through I don't think I can really do a fair comparsion with a functional language like Scala. I've only used Scala for 2 weeks on a single project. Functional languages tend to increase code correctness by trading away performance.
- therealdrag0 3y agoSorry for being a pain, but I’m still not seeing it. You gave an example of LOC but now have stepped back again into speaking in generalities. What structures and what complexities are you talking about? Give me examples. Tbh I have no idea what you’re talking about. ELI5.
- ReflectedImage 3y agoRoughly stuff like templating, abstract base classes, generics and non-trivial user defined types. Consider a simple program that adds 2 numbers: a & b together. In a dynamically typed language, this would be a + b. In a statically typed language, once you consider overflow and underflow, you will likely have a hundred lines of code. This creeps up again in JSON parsing where the types really are defined at runtime. But the most general case is people creating complex and hard to understand types in their code, which they then export to unsuspecting developers to use. e.g. The type of stuff that forced C++ to introduce the auto keyword.
- paulmd 3y ago> In a dynamically typed language, this would be a + b. In a statically typed language, once you consider overflow and underflow, you will likely have a hundred lines of code. https://stackoverflow.com/questions/52376716/c-overloading-of-the-plus-operator https://stackoverflow.com/questions/52376716/c-overloading-o... literally a single line of code to overload an operator. anyway, if you don't consider error states in your dynamic implementation and you do this in static then yes, it could be simpler. But static doesn't force you to consider error conditions - just like this C++ example does not. and yes, if you fall back on javascript notions of default cross-type arithmetic (1 + "1" = ?) then you will get something, and if you take great care to structure your code you may get something useful as a side-effect, but, this is not meaningfully different from the error-state for most people. Getting [] or "11" isn't the expected outcome unless you've come to expect that quirk of javascript, and is something that a static compiler would rightfully complain about - because a user asking for an undefined operation computed across incompatible types seems like a classic type error. If it's not, then just define the operators that are meaningful to you - and you could define it as an interface if you wanted it to work with a bunch of classes etc. Again though, the complaint elsewhere that "a lot of this debate just ends up being dynamic programmers who are unaccustomed to using static types at all and think it must be so super burdensome all the time" seems pretty accurate. Defining custom operators is not something that occupies even 1% of my time in any static language.
- deterministic 3y agoIt might be true for you. But it is most certainly not true for me. I am way more productive using typed languages. (30+ years of experience here working on million+ lines systems).
- fennecfoxy 3y agoStatic typing only increases bug count when devs who can't be bothered writing proper code cast stuff willy nilly/hack the code into working rather than put the effort in to growing and pruning the type system as needed. At least from what I've seen. But even then that's only as bad as not using any types at all, the statement that statically typed languages create more bugs is just plain ridiculous - there's a reason that space-faring agencies and defence contractors exclusively use statically typed languages with very strong rulesets on how code is written.