News for hackers. Stuff that matters.
Re:Haskell for Web Developers by nightski on Friday July 26, 2013 @04:35PM (#6110418)
No offense but you failed miserably. If you were trying to reproduce the python code in Haskell, the example is not what you would write. This is a 1 liner in Haskell. The two examples do not represent the same thing.
Re:Haskell for Web Developers by Chris_Newton on Friday July 26, 2013 @05:33PM (#6110727)
The two examples do not represent the same thing.

This is a claim I don’t understand. They are both simple examples of representing an algorithm that maintains state in their respective languages. Of course you could write it as a one-liner using a different style in Haskell, and in various imperative languages for that matter. However, my point was that making these monadic abstractions explicit everywhere in Haskell does add weight to the code. That continues to be true for more complicated stateful code that can’t be rewritten as a one-liner or expressed more elegantly using recursion anyway.

Re:Haskell for Web Developers by nightski on Friday July 26, 2013 @09:04PM (#6111413)
I simply do not agree that the abstractions add weight to the code. If anything I think that they make it more concise. It scales much better than constructs given to you in Python. But don't take my word for it, try writing a complicated Haskell program with lots of effects. I think you will find the capability Haskell provides to compose and abstract a huge boon.
Re:Haskell for Web Developers by Chris_Newton on Friday July 26, 2013 @09:26PM (#6111472)
But don't take my word for it, try writing a complicated Haskell program with lots of effects.

Unfortunately it’s late and I don’t have time to spend the next few weeks writing Haskell code to try your experiment. I’m guessing no-one else reading this does either. Perhaps you could instead direct us all to some existing projects that demonstrate the advantages you’re describing, so we could see the kind of code you’re thinking of and make up our own minds?

Re:Haskell for Web Developers by nightski on Saturday July 27, 2013 @12:57AM (#6111924)
The thing is I could throw a bunch of Haskell at you but in the end it wouldn't really mean anything. When I embarked on learning the language there were many times I almost threw in the towel. It was hard to see beyond the initial frustrations. Haskell code looked confusing, verbose, ugly, and so on. It was only by taking the time of going through this process that I came to an understanding - followed by appreciation.

But I don't claim to be incredibly intelligent. It is very possible you or someone else here could look at a heap of Haskell code and just immediately understand the advantages/disadvantages without having gone through learning all of the "why".

Your time is yours. Don't let me try to tell you what to do with it. Heck you can make a fortune just writing PHP so is there any reason to learn anything else? I'd say anyone who loves their craft would want to at least give all new things a shot and invest some time into learning what is out there.

The project I took on initially to learn Haskell was translating a real time sparse 3D reconstruction computer vision algorithm. It was incredibly daunting and challenging. But in the end very worth it!

Re:Haskell for Web Developers by Chris_Newton on Saturday July 27, 2013 @09:30AM (#6112807)
The thing is I could throw a bunch of Haskell at you but in the end it wouldn't really mean anything.

It is odd that you seem to be assuming I’ve never written anything in Haskell and that the concerns I’ve expressed are based on a sceptical reading of one article. I’m quite sure I’ve never written anything to that effect here.

I make no claim to special expertise or authority. Indeed, I’m almost entirely self-taught, so it’s certainly possible that I have completely missed some key point. However, I’ve been following Haskell’s development for years and written enough small/medium projects in it to have formed my own opinions. My experience has been that for mostly pure code where it’s a natural fit, Haskell has a lot to like, but for more interactive systems, it often does become rather awkward for exactly the reasons we’ve been discussing. (Edit: There’s a good example of this in the article: the chat room using WebSockets.)

In the real world, people do sometimes just dump half of their program into IO to be done with it. In the real world, you do wind up repeating essentially the same logic multiple times to cope with monadic and non-monadic cases (or the authors of libraries you use did, but sometimes you are that author) and at times you do need things like explicit lifts. In the real world, sometimes you do want to be in the same monad twice. In the real world, there are awkward corner cases in the language, and you do wind up relying on GHC extensions to help clean them up. In the real world, people do write elegant code like the popular not-quicksort example despite its dubious performance characteristics.

None of this takes away from the power and usefulness of Haskell’s type system, or neat ideas like STM if concurrency is relevant to your application. But this isn’t some kind of either/or world, where having some good points automatically means a language can’t have any bad ones.

Re:Haskell for Web Developers by asdasf on Friday July 26, 2013 @08:42PM (#6111367)
It is made explicit and verbose in that contrived example because it specifically an example of those things. I am having a really hard time believing that you genuinely don't understand this obvious fact.
Re:Haskell for Web Developers by Chris_Newton on Friday July 26, 2013 @09:22PM (#6111464)
Of course I understand that this is a contrived example.

What I don’t accept — without evidence to the contrary — is that it is unrepresentative. Would more “serious” examples of implementing stateful algorithms using monads and similar tools not be similarly verbose, given the explicit nature of such details in Haskell? Maybe that really is true for experts, in which case I would be happy to learn about it and update my views. Examples are welcome.

For now, I have never personally seen it, and it’s not immediately obvious to me how Haskell code would beat a dedicated imperative language at its own game in terms of conciseness. Correctness guarantees, sure. Performance, maybe, if we reach the point where powerful optimisations are possible in Haskell because of the extra information available. And for conciseness, I’m not suggesting it’s orders of magnitude worse or anything silly like that. But when, by design, your effects and sequencing have to be singled out and specified explicitly every time, you’re starting at a disadvantage compared to systems that incorporate that behaviour implicitly.

Please also see my comments on quicksort elsewhere in this thread.