5 ms·
Safe: Robust programming in Haskell via types, testing, debugging
- Periodic 17y agoI'm glad to see such a rational argument about why Haskell matters. After reading this I wonder why more people aren't using Haskell. Why are the reasons to stick with Java over Haskell in the long run?
- mncaudill 17y agoIn my experience, Haskell takes a bit more to "get." If Java is good enough and managers are able to find multiple, interchangeable developers, Haskell doesn't make a lot of business sense. Though I imagine that if Haskell was given more of a chance in enterprise settings, the level of software quality would go up, though it may cost a bit more to write.
- baguasquirrel 17y agoThe Haskell community shouldn't try to do better than Java. Enterprise is what it is because it has particular motivations. We should play to the strengths of our language and our community. It's easy to agree that there's lots of software floating around, but that not a lot of it is good. That's particularly true about enterprise software (I used to work in the field). It doesn't have to be good. You could have an excessively complicated UI and do your numerics in Python (for the love of God, numerics and statistics in Python?) and people will still use it. The damn app can take 12 seconds to load, and people will still use it. How are you going to sell Haskell to the enterprise community when that's their bar? If people want to write code in Haskell for a living, if they're serious about this freeing-software-from-the-von-Neumann-paradigm thing, they should seek out problem spaces where software quality matters. This is hardly the sole core competency of Haskell, IMO. When one of my friends was introduced to it, he noted that it was a very "scientific" language. Which is to say, he thought it was impractical for regular software. The flip side to this is that we can very easily do things like check for gene sequences in Haskell (Brian O'Sullivan was doing something like this). The fact that things like sets and maps are treated like values means that they are very natural and easy to work with (albeit a little slower than their mutable counterparts in other languages), so why aren't we seeing Haskell used to analyze social networks? Haskell is a powerful language. We just need to see it for what we could do with it, rather than redoing the old things that have already been done.
- Quiark 17y ago(for the love of God, numerics and statistics in Python?) See http://numpy.scipy.org/ http://numpy.scipy.org/ ;) But don't worry (so much), it's actually just a C library exposed to Python.
- jmillikin 17y agoNear the end of the article, the author mentions Literate Haskell (.lhs). In my opinion, LHS is not at all literate -- it's nothing more than verbose commenting. \begin{code} and \end{code} are semantically equivalent to -} and {-. Anybody interested in literate programming with Haskell should look into NoWeb or Leo.
- dons 17y agoTex-style .lhs isn't "classic" .lhs (Bird-style): http://www.haskell.org/haskellwiki/Literate_programming#Bird_Style http://www.haskell.org/haskellwiki/Literate_programming#Bird...
- jmillikin 17y agoThey're just a different syntax for the same purpose. Consider: some comments \begin{code} foo :: Int -> Int \end{code} more comments \begin{code} foo = (+ 1) \end{code} and some comments > foo :: Int -> Int more comments > foo = (+ 1) and -- some comments foo :: Int -> Int -- more comments foo = (+ 1) Now, how would you do this using .lhs? some comments <<Foo.hs>>= <<type of foo>> <<definition of foo>> comments on definition of 'foo' <<definition of foo>>= foo = (+ 1) comments on type of 'foo' <<type of foo>>= foo :: Int -> Int
- scscsc 17y agoNegative; you should look up literate programming (http://en.wikipedia.org/wiki/Literate_programming http://en.wikipedia.org/wiki/Literate_programming). Basically you compile the lhs into a pdf before reading it ;-)
- jmillikin 17y agoI'm quite aware of what literate programming is -- it's more than just writing a lot of comments. If you'd like to see the PDF of a literate library, check out the source code to my Haskell DBus implementation at < http://ianen.org/haskell/dbus/core.pdf http://ianen.org/haskell/dbus/core.pdf >. Just because the source code can be rendered to PDF, or contains a lot of comments, does not make it "literate". Literate programming is designed to abstract the compiler's strict syntactic requirements from the reader. LHS does not do this -- whether you use LaTeX or Bird-style comment markers, they're still just comments. You can't use them to re-arrange or repeat source code.
- tedunangst 17y agoreverse (x:xs) = xs ++ [x] Does that really reverse a list in Haskell?
- dons 17y agoIt's a "buggy" implementation (no recursive call) for the purpose of illustrating code coverage and quickcheck testing...
- tedunangst 17y agoThat's what I guessed, but the text doesn't make that clear at all.
- hristov 17y agoGood catch. I think it has to be: reverse (x:xs) = reverse(xs) ++ [x] But then again this is Haskell so there may be some mind boggling property of the language that is only understood by math postdocs and the more enlightened monks in Shaolin monasteries that makes the original line ok.
- steveklabnik 17y agoNope, your revised code is correct.
- jrockway 17y agoBut then again this is Haskell so there may be some mind boggling property of the language that is only understood by math postdocs and the more enlightened monks in Shaolin monasteries that makes the original line ok. Nope, and there never is. Haskell is just programming!
- deleted 17y ago[deleted]
- nearestneighbor 17y agohttp://www.reddit.com/r/programming/comments/bm1u8/safe_robust_programming_practices_in_haskell_via/c0ng5e6 http://www.reddit.com/r/programming/comments/bm1u8/safe_robu... Ironic, considering the title, if you ask me.
- cageface 17y agoFunctional language advocates have been making these kinds of claims for years but I don't think they have yet produced any hard evidence that languages like Haskell actually do increase programmer productivity in typical real-world scenarios. It may be that they do but I wouldn't be surprised if we find that the kinds of errors they minimize aren't the kind that often impede development in practice and that the strictures of FP languages, particularly lazy ones, make some common programming tasks significantly more difficult. People also like to claim that functional languages are particularly well suited for concurrent programming, but, as Simon Peyton Jones has himself said, just getting rid of mutable state doesn't automatically make your code parallelizable. People used to hold up Darcs as a Haskell success story but as far as I can tell people have hacked together DVCS systems in "inferior" languages like C and Python that are at least as robust and featureful.
- dons 17y agoI believe in advoacy by doing things, and yes, arguments without dollar figures attached are less convincing. Studies on programmer productivity are rare, but a different argument might be found in where Haskell (for example) is used when correctness matters. For example, in hydraulic control of vehicles at Eaton, or secure cryptographic algorithms at Galois. Python isn't going to fly when you need to convince people of correctness, while Haskell (for example) does have tools and approaches that work. I wrote a post last year on the collective experiences of engineers at Galois after using Haskell for the past decade, which has some nice anecdotes, http://www.galois.com/blog/2009/04/27/engineering-large-projects-in-haskell-a-decade-of-fp-at-galois/ http://www.galois.com/blog/2009/04/27/engineering-large-proj... The other data point is the way finance has jumped on functional programming -- often because they can see a (huge) dollar figure in (small?) improvements in productivity or correctness. Jane Street, Barclay's, Credit Suisse, ABN Amro, Standard Chartered, JP Morgan and others (http://cufp.org http://cufp.org) don't use FP because it is a fad.
- cageface 17y agoThe correctness argument is interesting, but certainly plenty of critical-to-be-correct software has been written in imperative languages too. I'd like to see something closer to hard numbers on bug counts, man hours etc on similar projects in Haskell or ML vs C++ or Java, for instance. I realize it's hard to find a truly apples to apples comparison here. The uptake of FP in finance is interesting. I'd like to hear more about exactly how FP is being used in these contexts. Is it used in a narrow, specialized domain or broadly? To what extent are the advantages of FP in this domain realizable in others? Is FP only suitable for small, elite teams or can mainstream programmers pick it up with the right training? To what extent does the less mature or less conventional toolchain offset the advantages of the language itself?