3 ms·
I can definitely understand the sentiment if you haven't tried it. I knew optional typing existed in AS3 (which I use for prototyping certain ideas) for a long
by dougk16 13y ago
I can definitely understand the sentiment if you haven't tried it. I knew optional typing existed in AS3 (which I use for prototyping certain ideas) for a long time before finally taking the plunge and using it here and there. It lets you blast through experimental code and remain nimble until such time as you want/need to add typing. Also a nice way to avoid long chains of method overloads, including overloading methods that only differ by return type, which is impossible to do in some (many?) languages.
- roryokane 13y agoSorry, accidentally downvoted when I meant to upvote.
- tikhonj 13y agoSee, this is where the philosophy of languages like Dart and Java differs significantly from Haskell and friends. In the former, it makes sense to write code first and then try to get it to typecheck afterwards. In Haskell, this does not really happen: the types are at the very core of your code. When I write a Haskell program, I start with the types and the code grows from there. The types are really the foundation for everything else. It doesn't really make sense to view the code without also thinking about types: after all, Haskell code is centered around functions, and functions are defined by their domain and codomain. Among other things, this means that the types actually help me to prototype. Iterating on different types and seeing how that changes the sort of functions I can write is a very powerful technique. This is going to become even more apparent in the near future with features like type holes. The basic idea there is that you can leave parts of your code blank, and the compiler will tell you which type goes there! The type system can actually help you write the code. Honestly, I think the difference between types in Java and Haskell is at least as large as the difference between types in Java and dynamically typed languages.
- dougk16 13y agoYea, as always, depends on what you're doing. I agree 100% with your points for when I'm writing mission-critical code from the start. But when I'm busting out UI at 2:00AM, it's all fast and loose. A lot of code I write is somewhere in the middle.
- tikhonj 13y agoNo, you didn't quite see my point. In Haskell, types aren't only about correctness--they're also about expressiveness. They help you program beyond correctness--they even help if you're just hacking around. Moreover, they're sufficiently central to practical code (even, at the risk of repeating myself too much, hacky code) that it wouldn't really make sense to write untyped Haskell and try to stick types on afterwards. Basically, in Haskell, the types go well beyond correctness. I hope this clarifies what I mean.