Hacker News new | comments | show | ask | jobs | submit login

> The choice of a pure functional language like Haskell to do lots of IO seems like a strange choice

Can you tell me what a program which does no I/O actually does?

I can tell you what it does in Haskell: nothing. Without IO, there would be no reason for a computation to ever run in Haskell (or in any other language, but Haskell will actually NOT run it). Every Haskell program does I/O.

I know when I first heard about functional programming and Haskell in particular, that ideas like purity, no side-effects and immutability seemed absurd. "But, but - the programs I write always do I/O and manage state!?" So do Haskell programs, they simply do it differently. If a program had no side effects it would have no purpose. Please do not assume that the tool used by an entire community is not well suited to building programs that have a purpose.




I remember a quote by SPJ but am unable to find a reference to it right now. It goes something like: "a program without I/O is merely heating space."

Pure Haskell programs have no side effects, where "side effect" is defined as an effect that occurs implicitly outside of the function's signature. They can definitely have non-side effects; they just have to be explicit about it (the same with IO). For some reason, "side effect" have come to mean effects in general...

Parent's observation probably relates to the fact that doing IO in Haskell is "harder" than say in Python. There is some truth to that.


I think you are missing the parents point. Since everything is lazy in Haskell, a program without IO will literally do nothing. It will not evaluate a single line of code.

To expound, Haskell pure functions do not run code. They produce code to be run at a future date. The infamous IO monad is essentially a wrapper around this code which contains information on when the runtime is supposed to actually execute the code. The execution is always dependent on IO.

So, as the parent said, a Haskell program without IO is literally nothing.


Yes, but grandparent wasn't complaining about the inability of doing IO in Haskell:

> The choice of a pure functional language like Haskell to do lots of IO seems like a strange choice given that Haskell makes side effects like IO more difficult than other languages.

The argument was that doing IO in Haskell was difficult. So if you take programming as pure code intertwined with IO, the benefits of using Haskell would go down as the fraction of IO increased if the premise that "doing IO was more difficult in Haskell" was true.

So parent said something true, but I'm not sure how it relates to grandparent's comment.





Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: