4 ms·
> Rarely do they notice these two are not the same thing. Types enable better tooling. That's why people mention tooling when types come up.
by naasking 8y ago
> Rarely do they notice these two are not the same thing.
Types enable better tooling. That's why people mention tooling when types come up.
- munificent 8y agoStatic types enable better static tooling. Dynamic types enable better dynamic tooling. :) These days, most programmers are very familiar with high quality static tooling (IDEs) but less familiar with high quality dynamic tooling.
- ridiculous_fish 8y agoRight on. Here's an amazing example. Pharo Smalltalk has a feature where you can find methods by giving an example of the input and output you expect. Forget how to uppercase a string? Just write: 'eureka' . 'EUREKA' and the IDE will suggest the method asUppercase. It does this by dynamically invoking all of string's methods until it finds one whose output matches!
- naasking 8y agoNeat, but not generalizable because methods often have side effects. You could easily know when this search is safe in a language that types side-effects, like Haskell. So types can enhance this feature too.
- deleted 8y ago[deleted]
- marcosdumay 8y agoThis actually exploits a static component of the type. This would not work on a fully dynamic type system.
- ridiculous_fish 8y agoI don't get it, why not?
- marcosdumay 8y agoOn a fully dynamic type system, static analysis can't know what functions accept strings. It would have to try every single function, what is not viable, because many have side effects.
- zaphirplane 8y agoDoes the language have rm -fr method ? ;) Still. nice
- naasking 8y agoMaybe! But you have to admit that having static types with an AST available provides considerably more program synthesis and intellisense possibilities than only having an AST.
- ridiculous_fish 8y agoThe dynamically typed case is not "only an AST," it's a living and breathing program. It made this HTTP request and performed some computation and read that file, and you can talk to it and learn all about its state!
- naasking 8y agoDon't confuse dynamic typing with metaprogramming or fexpr. These are all orthogonal. Tooling for dynamically typed languages as a whole only have access to the AST, although some with the above features may have access to more.
- xigency 8y agoExactly. I think the dynamic tooling are things like macros. It seems that JavaScript is being used as the dynamically typed foil, where a better example would be Scheme.
- ergothus 8y agoMy point being that when I ask why static is better (from people arguing that), they'll talk about compile-time checks, they won't talk about the tooling. When I ask them to show me examples, they don't point to bugs that were prevented by compile-time checks, they'll point to how they find it easier to write code because the IDE suggests things.
- naasking 8y agoNo dynamic type system can achieve the same safety properties as type systems like TyPiCal: http://www-kb.is.s.u-tokyo.ac.jp/~koba/typical/ http://www-kb.is.s.u-tokyo.ac.jp/~koba/typical/
- revvx 8y agoI think it's hard to point to "bugs prevented by compile-time checks" because of the nature of type-checking. I could just say that every time the compiler refuses to compile my code due to a type error a bug is averted. Typos, wrong method signatures, interfaces not implemented correctly. All those things had the potential to be bugs. Small, detectable and perhaps even non-breaking, but it's still good to catch them early on. And of course, most of the time a good enough test suite would catch them. But having the compiler warning you is so much faster! And much more reliable too, because I'm not perfect and sometimes I make mistakes in my tests.
- zbentley 8y ago> When I ask them to show me examples, they don't point to bugs that were prevented by compile-time checks Similarly, if you ask a writer who uses a pencil about the benefits of their approach versus a pen, they likely won't reference any specific times when they would have made un-erasable mistakes.
- Gibbon1 8y agoTooling in this case replaces a lot of boiler plate unit tests. The stronger and more rigorous the typing the fewer ad hoc tests that need to be hand written. I think the cost is the tooling becomes more finicky about what you feed it. C weakly typed -> compile -> run-> crash -> WTF?!!! Rust strongly typed -> WTF? Why no compile!!