3 ms·
Typing is almost a no-loss addition though. If your function takes an integer argument and someone might pass it a string, that is a bug. It is quite hard to ar
by roenxi 5y ago
Typing is almost a no-loss addition though. If your function takes an integer argument and someone might pass it a string, that is a bug. It is quite hard to argue that a typing mechanism won't improve code quality, and it is very lopsided in the amount of time it takes to type a function vs. debug something that would have been caught by a type system.
There are edge cases that can be argued all day, but if some large codebase is going to be maintained long term it is difficult for me to see how types could be a handicap. Even if a coder doesn't really engage with the type system "properly", as little as capturing information that was already obvious anyway will reduce the bug count.
There are good reasons to expect typed languages to do well.
- teddyh 5y agoWhat you’re describing is optional typing. What is usually derided as cumbersome is mandatory and exhaustive typing.
- DaiPlusPlus 5y agoWhat if... we had the "best" parts of PHP or JavaScript development but for any traditionally statically-typed and precompiled language? (sorry, I can't say that with a straight-face) It could work though! And I don't just mean like Visual Studio's Edit-and-Continue feature... Consider a language feature that lets you annotate a local/parameter/field's ("thing") type as "Hindley–Milner-esque" which tells the compiler to invert the thing's typing rules from prescriptive to descriptive (i.e. to mostly stop complaining and make the thing behave more like a JavaScript `object`, so the compiler only complains about 100% provably wrong usage of that thing). Another "feature" of PHP/JS dev that I want to see in compiled projects is a way to run a project-with--build-errors by adding a toggle that instructs the compiler to stub-out all functions/members that contain build errors (even syntax errors!), this way we can do quick ad-hoc testing without needing the entire project to build. Think about the times when you your boss asks you to make 1 or 2 "minor" alterations for an unrelated feature and you don't think it's worth making a whole new git branch-andworktree for, but you can't test it right-away because of unrelated breaking changes you've already made. Just some ideas... --------------- Unrelated additional comment: I'm looking forward to when all programming languages fully support generalized ADTs. So many issues with data-modelling can be solved with ADTs and GADTs, but yet thanks to OOP's legacy from the 1990s we still have to shoehorn simple and clear models into inappropriate applications of inheritance. I want my intersection-types, damnit.
- tshaddox 5y ago“Mandatory and exhaustive” typing is also good and usually not particularly difficult if you have a decent type system. With OCaml, for instance, you rarely even need to go out of your way to have 100% type coverage.
- ReleaseCandidat 5y ago> If your function takes an integer argument and someone might pass it a string, that is a bug. What if you pass it a float and that's converted to an integer?