4 ms·
In the end, static typing is just a means for the reasoning you do in your head about why your program is correct to be checkable by the compiler. Arguably, if
by layer8 4y ago
In the end, static typing is just a means for the reasoning you do in your head about why your program is correct to be checkable by the compiler. Arguably, if you’re unable to explain that reasoning to a compiler-like checker, then you shouldn’t trust your reasoning. Of course, static type systems aren’t quite there yet in practice, but that’s the ideal. And runtime metaprogramming is no different. You have some reasoning in your head why your metaprogramming code is doing the correct thing, and it should be possible to have a type/theorem checker that validates your reasoning.
So static typing vs. dynamic typing isn’t about what you can or cannot do, it’s about having a mechanism to verify the soundness of your reasoning vs. having no such mechanism.
- ReflectedImage 4y agoUnless you are using Haskell or Rust then static typing is a terrible way to check if your program is correct. You need unit tests to confirm the correctness of your program. And unit tests check most of the types for free. So you don't need static typing after all.
- kaashif 4y agoThe person you're replying to didn't mention this, but I find the main utility of static typing to be that all variables and functions either have explicit types or their types can be inferred by the IDE. Great for readability when I'm wondering what type this parameter is supposed to be and what I can do with it. You can obviously have documentation of types without static types, but static typing means you have ever-present compiler-verified documentation of types. Not always enough, but it's a lot more helpful than just having nothing. Having exhaustive unit tests doesn't necessarily help with this.
- ReflectedImage 4y agoMost types can be inferred via your IDE, you generally get what you are talking about anyway for free.