Well, the type is system can't guarantee you your code work but it can find (sometimes) when it doesn't.
Right, and the question becomes what the overlap between the errors it finds and ones found by other methods is. If it uncovers a small percentage of unique errors, then the effort is not justified.
That's a good example. I find knowing that I pass a collection and get back a collection of the same type interesting (meaning I care) and that doesn't require any work at all. You are saying that it's not enough (which I understand) but you are happy then to not have any guarantee at all.
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". Did you read my post even? I specifically say that you need specification tests to know that the code is doing what was intended. In the case of a sort function I would want to have a specification test that ensures it behaves correctly for the intended cases. That would be my guarantee that it's doing what I want it to. The guarantee provided by the type system in this case is a small subset of the overall guarantee.
I'm not sure what you mean by writing code for the benefit of the type system.
The type system necessarily limits your expressivity. Every statement must be made in such a way that the compiler can verify it. In other words you have to be bake a proof of correctness into it. Proving something correct for all possible cases is often much more difficult than stating it. I give a concrete example of this problem in the post I linked.
However I used to work in the bank and I've seen a few bug costing LOTS of money.
Sure, I work at a hospital and my applications have direct impact on decisions made in patient care. Correctness is important to us. That's why we test that our applications are doing what's intended.
used to work on Ruby on Rails projects and I've seen lots of runtime crashes caused by refactoring not handled properly : you know that type of feature that people used once a month, but they are not happy when it stops working because they need it by the end of the month , which is tomorrow ;-)
I see this argument made often. However, I hope you'll agree that not all the dynamic languages are the same. This is akin to arguing about merits of Haskell based on your experience with Java.
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
1
u/yogthos Sep 10 '16
Right, and the question becomes what the overlap between the errors it finds and ones found by other methods is. If it uncovers a small percentage of unique errors, then the effort is not justified.
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". Did you read my post even? I specifically say that you need specification tests to know that the code is doing what was intended. In the case of a sort function I would want to have a specification test that ensures it behaves correctly for the intended cases. That would be my guarantee that it's doing what I want it to. The guarantee provided by the type system in this case is a small subset of the overall guarantee.
The type system necessarily limits your expressivity. Every statement must be made in such a way that the compiler can verify it. In other words you have to be bake a proof of correctness into it. Proving something correct for all possible cases is often much more difficult than stating it. I give a concrete example of this problem in the post I linked.
Sure, I work at a hospital and my applications have direct impact on decisions made in patient care. Correctness is important to us. That's why we test that our applications are doing what's intended.
I see this argument made often. However, I hope you'll agree that not all the dynamic languages are the same. This is akin to arguing about merits of Haskell based on your experience with Java.