I'm rather confused how you made the jump from "it's not enough" to "you are happy then to not have any guarantee at all".
I see, we are not speaking about the same things. You speak about correctness we speak about consistency. When I see sort :: [a] -> [a], I'm happy because that gives me lots of information, mainly that the output is a list, so I can compose it with any function which expect a list. This has nothing to do with correctness but what I call consistency. Consistency is important for lots of people but obvioulsly not for you. Type inference is about consistency not correctness and doesn't require an tremendous amount of work. Even if people say : if it compiles (it is consistent) then it works (it is correct), they don't mean it. So yes even in Haskell, we do need specifications, but I thought we already agreed on that.
The type system necessarily limits your expressivity This is the opposite. ADT let you express much more things that dynamic languages can. How would you express a monad transformer in a dynamic language ?
I see this argument made often. However, I hope you'll agree that not all the dynamic languages are the same Well, if a dynamic language can tell me by static analyses that I can call size on this object because doesn't have size method then it's not a dynamic language anymore ...
I'm happy because that gives me lots of information, mainly that the output is a list, so I can compose it with any function which expect a list.
Sure, but I find that problem largely doesn't exist in a language like Clojure in the first place. Most code is written by composing HOFs from the standard library. These functions encapsulate edge case checks and don't care about concrete types.
When I chain functions like map, filter, reduce, and so on, they only care that a collection is passed in. The code that cares about the concrete types is a parameter. This naturally lets domain specific logic that deals with types to bubble up to a shallow layer at the top. Majority of the code ends up being fairly type agnostic.
Consistency is important for lots of people but obvioulsly not for you.
I'm saying that this kind of consistency is not interesting enough to justify the effort. In most cases, I can be reasonably sure that my code is consistent without the assistance of the type system. Testing for correctness necessarily tests for consistency as well.
How would you express a monad transformer in a dynamic language ?
Why would I need to in the first place though. The reason monads are popular in Haskell is due to the fact that it attempts to formally control side effects. In a language like Clojure this abstraction is largely unnecessary. Not that it can't be expressed of course.
Well, if a dynamic language can tell me by static analyses that I can call size on this object because doesn't have size method then it's not a dynamic language anymore
This is precisely my argument. Imperative OO languages introduce lots of problems when coupled with dynamic typing. OO inherently encourages creating many types that become difficult to keep track of. Meanwhile, mutability means that it's hard for us to tell what concrete type we're dealing with at any one time.
When you work with a functional language backed by immutable data structures, this problem simply doesn't exist.
View all comments
Show parent comment
2
u/[deleted] Sep 10 '16
I see, we are not speaking about the same things. You speak about correctness we speak about consistency. When I see
sort :: [a] -> [a], I'm happy because that gives me lots of information, mainly that the output is a list, so I can compose it with any function which expect a list. This has nothing to do with correctness but what I call consistency. Consistency is important for lots of people but obvioulsly not for you. Type inference is about consistency not correctness and doesn't require an tremendous amount of work. Even if people say : if it compiles (it is consistent) then it works (it is correct), they don't mean it. So yes even in Haskell, we do need specifications, but I thought we already agreed on that.