an observation about Haskell vs. Python

As a somewhat-newbie haskell user and longtime Python user, what I have observed is this. Haskell creates compile-time error messages that are somewhat hard to understand for beginners. Python (or any scripting language) creates run-time bugs that are hard to understand. One reason for the weird (to a beginner) compile errors in Haskell is its expressivity -- almost any sequence of identifiers could potentially mean something, and if you make a mistake, the compiler is sure to find some "weird" way to interpret it. But Python suffers from a similar problem -- it's not as expressive a language, but it is very permissive, not insisting on type correctness, order of arguments, or any of a number of things so that the programmer can write a program that compiles with no errors -- but has strange run-time bugs. I'll take Haskell. I'm a bit OCD about getting the bugs out of my programs, and Python just opens up too many holes for me to relax with it. Dennis

With python (and any other non-compiled language for that matter) the unit
testing is very important. I almost think of the unit tests as the
compiler (does that make sense to anyone but me?).
On Wed, Sep 19, 2012 at 3:15 PM, Dennis Raddle
As a somewhat-newbie haskell user and longtime Python user, what I have observed is this.
Haskell creates compile-time error messages that are somewhat hard to understand for beginners.
Python (or any scripting language) creates run-time bugs that are hard to understand.
One reason for the weird (to a beginner) compile errors in Haskell is its expressivity -- almost any sequence of identifiers could potentially mean something, and if you make a mistake, the compiler is sure to find some "weird" way to interpret it.
But Python suffers from a similar problem -- it's not as expressive a language, but it is very permissive, not insisting on type correctness, order of arguments, or any of a number of things so that the programmer can write a program that compiles with no errors -- but has strange run-time bugs.
I'll take Haskell. I'm a bit OCD about getting the bugs out of my programs, and Python just opens up too many holes for me to relax with it.
Dennis
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- David Hinkes

On Wed, Sep 19, 2012 at 06:24:35PM -0700, David Hinkes wrote:
With python (and any other non-compiled language for that matter) the unit testing is very important. I almost think of the unit tests as the compiler (does that make sense to anyone but me?).
IMO this doesn't make sense for several reasons: 1) Just because a Haskell program compiles it is not magically correct with respect to what it is _supposed_ to do. So you still need unit testing in Haskell [1,2,3,4] - but you can focus more on functionality rather than typos, lapses and structures. 2) Covering all "type errors" with Python unit testing is hard and cummbersome. In the OP's words this means that you write your dedicated "compiler" for every single project. 3) Concluding the "type error" from a failed Python unit test is not trivial, especially because the reported error points to the location of the failure as opposed to the location of the fault. 4) Setting up unit tests for non-pure functions is quite an effert because the environment has to be brought into the right state first. Also, the environment's state has to be checked afterwards (i.e. mocking, virtual environments, etc.) 5) Running all unit tests usually takes _much_ longer than running the type checker (especially due to 4) I did quite some Python hacking in the past and although I still like the language, I love Haskell's type inference. Feels almost like scripting but allows for even faster development in the end, because you save time writing unit tests (2,4), "type errors" are detected faster (5) and finding the fault is quicker (3). Not to mention refactoring. Greetings Alex PS: For this post, I am calling "type errors" the set of bugs that the Haskell type checker can detect. Not a very precise definition, but I hope you get the idea. [1] http://hackage.haskell.org/package/HUnit-1.2.5.1 [2] http://hackage.haskell.org/package/QuickCheck-2.5 [3] http://hackage.haskell.org/package/test-framework-0.6.1 [4] http://book.realworldhaskell.org/read/testing-and-quality-assurance.html

This kind of thing is hard to prove or even explain, but I feel that Haskell error messages tend to point me to the cognitive mistakes, the ways I'm thinking wrongly about the problem. Whereas scripting language errors just point me to superficial brain farts. By the time I get Haskell code to compile, I already understand that code an order of magnitude deeper. That makes haskell VALUABLE. (to me)

On Thu, Sep 20, 2012 at 8:24 AM, David Hinkes
I almost think of the unit tests as the compiler (does that make sense to anyone but me?).
Absolutely! There's also quickcheck, which is semi-automated fuzz testing.
All this contributes to greater awesomeness in every line of code.
-- Kim-Ee
On Thu, Sep 20, 2012 at 8:24 AM, David Hinkes
With python (and any other non-compiled language for that matter) the unit testing is very important. I almost think of the unit tests as the compiler (does that make sense to anyone but me?).
On Wed, Sep 19, 2012 at 3:15 PM, Dennis Raddle
wrote: As a somewhat-newbie haskell user and longtime Python user, what I have observed is this.
Haskell creates compile-time error messages that are somewhat hard to understand for beginners.
Python (or any scripting language) creates run-time bugs that are hard to understand.
One reason for the weird (to a beginner) compile errors in Haskell is its expressivity -- almost any sequence of identifiers could potentially mean something, and if you make a mistake, the compiler is sure to find some "weird" way to interpret it.
But Python suffers from a similar problem -- it's not as expressive a language, but it is very permissive, not insisting on type correctness, order of arguments, or any of a number of things so that the programmer can write a program that compiles with no errors -- but has strange run-time bugs.
I'll take Haskell. I'm a bit OCD about getting the bugs out of my programs, and Python just opens up too many holes for me to relax with it.
Dennis
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- David Hinkes
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

Dennis Raddle
Haskell creates compile-time error messages that are somewhat hard to understand for beginners.
[...]
One reason for the weird (to a beginner) compile errors in Haskell is its expressivity -- almost any sequence of identifiers could potentially mean something, and if you make a mistake, the compiler is sure to find some "weird" way to interpret it.
I think the main source of weird error messages is Haskell's support for type classes. Remember all those compiler's complaints about missing instances? Those are probably the most confusing ones for beginners: main = print (sin + 3) You just forgot the argument to sin, for which an appropriate error message would be something like "missing argument" or "first argument of (+) is not a number". Of course the former is impossible in Haskell because of currying. The latter would be possible, if Haskell wouldn't have type classes (you would get a regular type mismatch). Instead you get two missing instance errors: No instance for (Show (a0 -> a0)) arising from a use of `print' No instance for (Num (a0 -> a0)) arising from a use of `+' I think that this problem cannot be solved, but one possible improvement is for the compiler to print suggestions taken from a database. Something along the lines of: Notice: You probably forgot to apply `sin' to an argument. However, I think that no work is done on that, and there is another possible path: An average Haskell tutorial should always include a section on understanding error messages. In fact the latest issue of The Monad Reader [1] has an article on that by Jan Stolarek. [1]: http://themonadreader.files.wordpress.com/2012/08/issue20.pdf Greets, Ertugrul -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad.

Hi Dennis,
Haskell creates compile-time error messages that are somewhat hard to understand for beginners.
I don't think that it's possible to have intuitive understandable error messages for something as complex as a programming language like Haskell. There even isn't something like intuitive unterstanding, because it's alwasy based on knowledge and familiarity. You have to learn the meaning of the error messages or what the possible reasons for some kind of error might be. I'm now even able to decode C++ template error messages, which might be the most horrible error messages on earth ;). Greetings, Daniel

Daniel Trstenjak
I don't think that it's possible to have intuitive understandable error messages for something as complex as a programming language like Haskell.
It isn't related to complexity, but just to certain type system features, in particular type classes and rank-n types. Confusing error message in the context of the former are the most common ones as explained in my answer. The latter can be even more confusing, when the compiler starts complaining about types that aren't polymorphic enough or even about "escaping type variables". But I'd say most people observe those messages only when they try to use ST in an unsafe way. Greets, Ertugrul -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad.
participants (6)
-
Alexander Bernauer
-
Daniel Trstenjak
-
David Hinkes
-
Dennis Raddle
-
Ertugrul Söylemez
-
Kim-Ee Yeoh