3 ms·
Static types don't tell you if you broke something when you changed the code.
by D13Fd 6y ago
Static types don't tell you if you broke something when you changed the code.
- nightowl_games 6y agoThat's a very broad statement. There are classes of bugs that can be detected by the compiler, and there are classes of bugs that cannot. Both of these statements are also true for Unit Tests.
- mhh__ 6y agoThat depends on the type system, although in practice encoding this information isn't easy I readily admit.
- rovolo 6y agoThey tell you if you broke a class of things, and I think that class of issues is pretty broad: * when you remove a method from a class, no user of that class calls that method * when you change the return type of a method, all users of that method are updated to handling the new type * in type systems with nullability, they make sure all users handle null values, and they make sure methods with non-null return types never return a null value There are functional changes which can break your code which won't be caught by the type system, but there are a lot of details which the type system will make sure you check when you make changes.
- gherkinnn 6y agoNot entirely. Types let me know whenever I try to connect a water pipe to the electricity. Or when I forget to wire up the grounding. What it can't tell me is that the lights go on when I flip the switch.
- orwin 6y ago-Warning -Werror -Wall -Wextra will tell you plenty. And you can add -Wconversion if you want to be clear on int conversion, and maybe -WShadow if you want to be sure you code is easily understandable. I did TDD five time. Twice with python, one with Go, onw with Rust and once with Common lisp. It was usefull with python, not great with Go and especially Common lisp (i mean, debugging while the code is held is better than debugging with tests, and Common lisp is a really good language to prototype, and TDD takes that out). And Miserable with Rust. With rust i'll test functionality and unsafe code, but i won't ever do TDD again, even if you paid me FU money.