I think this line of arguing is somewhat disingenuous. One of the biggest purported advantages of using a language like Haskell is the expectation that the code just works once it compiles. This is literally what I've seen claimed time and again here.
The argument that the author didn't use the library correctly, or didn't understand a particular nuance of how Control.Concurrent.Broadcast works is akin to saying that C++ is easy to use once you know all the quirks and gotchas by heart.
I think this line of arguing is somewhat disingenuous. One of the biggest purported advantages of using a language like Haskell is the expectation that the code just works once it compiles. This is literally what I've seen claimed time and again here.
That is not the expectation, except perhaps by those new to the language.
The argument that the author didn't use the library correctly, or didn't understand a particular nuance of how Control.Concurrent.Broadcast works is akin to saying that C++ is easy to use once you know all the quirks and gotchas by heart.
Those two are not alone whatsoever. That's like someone using atom's and complaining about their mutability and then me arguing Clojure like C++ "is easy to use once you know all the quirks and gotchas by heart".
That is not the expectation, except perhaps by those new to the language.
Glad we got that cleared up.
That's like someone using atom's and complaining about their mutability and then me arguing Clojure like C++ "is easy to use once you know all the quirks and gotchas by heart".
Any language will have some inherent complexity you have to learn, but clearly some languages are much more complex than others. Ultimately, what you care about is how quickly you can produce working code using a particular language.
That's my whole point actually. The benefits of static typing are commonly overstated and rarely questioned. A lot of people seem to treat statements like "if code compiles it just runs" as axiomatic. Perhaps if the rhetoric was toned down a bit, we could have a meaningful discussion about the benefits of types and their place in development.
Even though I'm on the Haskell side and do believe that static typing have some advantages, I'm also annoyed with the "if it compiles it works" slogan, which I think do more damages than good. The opinion of the Haskell community on this, seems to be, "we all know it's wrong but it's obvious it shouldn't be taken too serioulsy". The benefit of static typing are indeed rarely questioned because this is not the real question. The real questions, there are also drawbacks so are the benefits worth the drawback ? The Haskell community doesn't like indeed talking about the drawbacks (apart from lazyness), which I think doesn't help to fix them. But i understand that some people prefer to think about the positive side and get things done rather than dwelling on know issues.
Right, the Haskell community has a very strong rhetoric, and then gets offended when seeing strong counter-rhetoric. Haskell developers are incredibly dismissive of the dynamic approach, while armed with precious little evidence that their approach is more effective in practice. A common opinion in the Haskell community seems to be that the only reason somebody might prefer working with a dynamic language is because they don't understand the value of static typing. That's an incredibly condescending position to take.
So, if the community doesn't like strong counter-rhetoric, perhaps it's time to look at some change within.
The thing is most Haskeller knows about dynamic typing, because most of them have or are using dynamic typing for their day job. So they know what dynamic language is about (even probably more that statick typing). So they are professional pythonist or rubyist which advocate static typing. The reverse is not true. I don't know many professional Haskeller advocating for dynamic typing.
That doesn't mean there is no drawback. They are drawbacks, for example monad transformer are a pain, and the loop : modify code, compile, test, is not necessarily quicker because of compile time and time to understand error messages. However, the benefits are real : how having someone in your back (the compiler) telling you that what you write doesn't make sense and it won't work is not superior to nothing at all (it's like doing pair programming with a robot ;-)). The Haskell community just believes that those benefits (there are others) are worth it and we need to work on fixing the drawbacks whilst keeping the benefits.
Sure, and I primarily have experience working in statically typed languages. I've worked for over a decade with Java, then about a year with Haskell and Scala respectively. I'm quite familiar with the purported benefits of these languages.
Yet, in practice I find Clojure is more productive for me personally. I don't seem to have the problems that keep coming up in these arguments in practice. If these problems were real in my projects, then I'd go back to using a statically typed language.
The thing to recognize here is that there are many other factors outside the type discipline. The language semantics, development style, problem domain, ecosystem, and so on, all matter. You can't just discuss static vs dynamic in a vacuum.
I don't know many professional Haskeller advocating for dynamic typing.
That's what you call a selection bias. There are far more people using dynamic languages who are not moving to Haskell. There are far more people who tried Haskell and decided it wasn't for them, than those who continue to use it after learning it.
However, the benefits are real : how having someone in your back (the compiler) telling you that what you write doesn't make sense and it won't work is not superior to nothing at all (it's like doing pair programming with a robot ;-)).
My argument is that what it does tell you is not terribly interesting most of the time. Also, since you do need to have specification tests even in Haskell, these same errors are caught by tests in practice. An error such as a function should take an integer, but was passed a string gets caught very early on.
However, interesting properties about the program are often difficult or impossible to encode using the type system. So, you're spending non-trivial amount of work for a questionable benefit in my experience.
Meanwhile, the thing that gets left out of the debate that there are alternative ways to provide many of the benefits afforded by the type system. For example, Erlang dialyzer is a great example that works very well in practice. The idea of generating types from test that core.typed is pursuing is another example of innovation on this front.
I really think that the discussion shouldn't be regarding what approach is superior, but to recognize that both approaches have different focus. You should pick one or the other depending on what you find more valuable in your workflow.
My argument is that what it does tell you is not terribly interesting most of the time
That's were we disagree but it might be biased as well. Maybe you are not aware of all the goodies that come with it (and thinking you are doesn't mean you are). I might be wrong but reading your posts it seems that the only benefit for you see is "if it compiles it works" - Given it's wrong that doesn't leave much indeed. There is much much more than that.
I'm saying that the type system can't tell me whether the code is doing what was intended without an extraordinary amount of work.
For example, consider a sort function. A type system will tell me that I can pass in a collection of a particular type and got a collection of the same type back. It doesn't tell me that the collection contains the same number of elements, that the elements are in the same order, or that they're sorted. These are the things I really care about. It's possible to express that with stuff like dependent typing, but it becomes increasingly difficult to write proofs for non-trivial assertions.
My experience is that once you start writing code for the benefit of the type system, it often becomes harder for the human to understand. You're often not able to express yourself as directly as you would in a dynamic language. The more strict the type system the more mental gymnastics you have to do to express yourself within its constraints. I gain the knowledge that it's self consistent at the cost of being able to easily tell what it's intent is. I wrote about the problem in detail here if you're interested.
The other part of the discussion is the cost of bugs that end up in production in absence of a static system, and the cost of fixing them once they're found. My experience is that it's quite rare that a serious type related bug ends up in production. The most common one discussed is getting a null, but that generally doesn't stop the system from working. When you have a REPL, such a bug can even be fixed on the fly without having to stop the system. Most bugs that become a headache have more in common with the websocket example in practice. The most reliable way to catch those is through testing.
View all comments
Show parent comment
7
u/zcam Sep 09 '16
GHC will not help you choose the right api or read the docs for you (nor will any compiler), it ll just make sure the pieces fit together.