3 ms·
I don't understand this. Dart is a dynamic language that gives you the option of adding types that help with tooling, documentation and some type checking at de
by discreteevent 13y ago
I don't understand this. Dart is a dynamic language that gives you the option of adding types that help with tooling, documentation and some type checking at design time. At run time you can run it in checked mode and it will always tell the truth. This means that if you cover your code at all, manually or automatically then it will inform you of type errors. If you don't cover your code before releasing it then you probably are not writing anything very serious anyway. How is this worse than a dynamic language that offers you no optional typing with full checking at runtime?
- pcwalton 13y ago> Dart is a dynamic language that gives you the option of adding types that help with tooling, documentation and some type checking at design time. But the tooling and documentation aren't telling you what will happen at runtime. > At run time you can run it in checked mode and it will always tell the truth. It doesn't tell you the truth. A static type system is designed to rule out errors are compile time. That's what makes a static type system different from type assertions or guards. Besides, I don't really know what "telling you the truth" means if, for example, function arguments unify under covariance instead of contravariance like they should. Whether that happens at runtime or at compile time makes no difference—it's equally wrong either way. > This means that if you cover your code at all, manually or automatically then it will inform you of type errors. This is always true in any dynamic language. > How is this worse than a dynamic language that offers you no optional typing with full checking at runtime? In JS's case we can still add a static type system that's actually sound, whereas Dart has already crossed the bridge into unsoundness.
- discreteevent 13y ago>That's what makes a static type system different from type assertions or guards. This system is different from type assertions or guards in that you do not have to write any assertions but will still be informed of most type errors at compile time and virtually all type errors at runtime (Its been a while since I have written some Dart so I'm not 100% sure and don't have time to check if its exactly 100% of scenarios) > This means that if you cover your code at all, manually or automatically then it will inform you of type errors. >> This is always true in any dynamic language. No, there's a difference. I will get the error in dart as soon as I try to use the object in any way. In a dynamic language I could call a few methods on it before calling a method it does not support. i.e. it behaves like a compiler would except at run-time. This makes a big difference in how quickly you can debug it and again this is only for the minority of scenarios that are not covered at compile time.