6 ms·
holy hell why are tutorials like this always in haskell. While I am sure there are a lot of people using Haskell, there is a whole lot more people in Java or py
by tonetheman 12y ago
holy hell why are tutorials like this always in haskell. While I am sure there are a lot of people using Haskell, there is a whole lot more people in Java or python.
- Dewie 12y agoThere are a lot of tutorials around monads and monad topics using Haskell because... Haskell is one of the few languages which uses monads in a principled and explicit way.
- pekk 12y agoHaskell introduced monads as a way of solving certain problems Haskell had. So if you want to use Haskell effectively, you have to learn about monads. Monads are useful in Haskell. But that doesn't mean they are as useful in every language. So other languages don't NEED tutorials on monads as much as Haskell does. This isn't because those other languages are worse (less "principled" or "explicit") than Haskell. It's because they aren't structured to make it important to have tutorials on monads. Instead you worry about whatever the specific issues are for those other languages.
- Dewie 12y agoYeah yeah, they are all strong independent languages that don't need no monads. What do I care. EDIT: you don't strictly need something like monad transformers, though. In general, monads are just another type class. A special one since IO is implemented with them, but other than that, they are not essential.
- codygman 12y agoMonads are useful and unknowingly created in other languages all the time [0]. If you aren't quite comfortable enough with monads to follow the first link, I found this implementing monads in python tutorial[1] to be a huge help. For those that want to play with Monads in Python, check out PyMonad[2]. 0: http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html http://blog.sigfpe.com/2006/08/you-could-have-invented-monad... 1: http://www.valuedlessons.com/2008/01/monads-in-python-with-nice-syntax.html http://www.valuedlessons.com/2008/01/monads-in-python-with-n... 2: https://pypi.python.org/pypi/PyMonad/ https://pypi.python.org/pypi/PyMonad/
- jerf 12y agoExpanding on the other replies, monads are not useful in most languages because most languages are not powerful enough to use them. The syntax is too heavy, because you need lots of function closures. The type system is too weak, because using monadic values without higher-kinded types is much more difficult and less useful. The fact that everybody tries to import monadic values into their languages is evidence that they would indeed be useful; the fact that such libraries are always useless in practice and incapable of even transliterating the Haskell, and often fail to even implement the full feature set of monadic values in Haskell even if you're willing to type reams of code, is why you don't use them in other languages. You don't ignore monads in non-Haskell languages because the other languages are too powerful to need them, hurr hurr Haskell is teh weaks... you ignore monads in other languages because those languages are too weak to usefully implement them. If they could, you'd see them, and I am very, very confident over the next 10 years you're going to see more and more languages coming out that really have and really use monadic values, because they will be strong enough to do so, and once you have that, the value proposition is just too good to ignore. They are too darned useful to ignore.
- AnimalMuppet 12y ago> The fact that everybody tries to import monadic values into their languages is evidence that they would indeed be useful... Could you give a bit more detail here? From where I sit, I certainly don't see people trying to import monadic values into the languages I use, and I don't see much evidence that they'd be useful. (I've been trying to get my mind around monads and when and how to use them, and one of the problems I have in learning them is that, as far as I can tell, they don't look like the solution to any problem I've ever actually had.)
- yohanatan 12y agoThe reason you don't discern the presence of any problem is that you happily purr along as an effective 'human compiler' in a language with a [relatively] lower level of abstraction. You cannot detect that you're actually doing compilation from higher-level constructs because those higher-level concepts have not been formed in your mind (and you haven't been exposed to languages which capture those concepts more precisely/succinctly). It's quite likely, in fact, that your [manual] compilation process is not consistent or repeatable and you end up with a lower fidelity translation (i.e., with lots of noise interspersed) than a truly mechanistic compiler would.
- prakashk 12y agoSee "The Marvels of Monads" (http://blogs.msdn.com/b/wesdyer/archive/2008/01/11/the-marvels-of-monads.aspx http://blogs.msdn.com/b/wesdyer/archive/2008/01/11/the-marve...), where the author talks about controlling complexity using composition, and how monads aid in accomplishing it. It's all in C#.
- rrradical 12y agoPeople that use Haskell tend to care more about this sort of thing than people that use those languages. Or alternatively, if someone cared about this sort of thing they would use Haskell.
- lsdafjklsd 12y agoMeh, I don't know or use Haskell and I'm interested in this stuff. I'm a javascript programmer introduced to these concepts via [1]https://www.youtube.com/watch?v=m3svKOdZijA https://www.youtube.com/watch?v=m3svKOdZijA and https://github.com/CrossEye/ramda https://github.com/CrossEye/ramda. Programming in a point free style in javascript is great! 1: Hey Underscore, You're Doing it Wrong!
- rrradical 12y agoFair enough, but you're thinking about checking it out now right? :) Come to the dark side. http://learnyouahaskell.com/chapters http://learnyouahaskell.com/chapters (Rambda looks neat, thanks for the link.)
- tel 12y agoThere are quite a few layers between what's discussed there and this article. In particular, static typing is an important component of monad transformer stacks, though it's possible to express them without it. Without types, however, it's hard to have a conversation about what's actually going on.
- AnimalMuppet 12y agoI might also say, people who are using Haskell have to care about this kind of stuff, because the language more or less forces it on them. Java or Python, not so much.
- codygman 12y agoSo does that mean we should just stop talking about X language that isn't nearly as popular as Java or Python? I don't see the point you are trying to make here.
- wyager 12y agoGood luck writing any sort of useful monad transformers in Java or Python.
- pekk 12y agoGood luck finding real reasons to need them in Java or Python.
- chongli 12y agoWell, you don't need shoes if you don't have feet.
- pekk 12y agoAre you implying that Java cannot be used to make useful software? What does it mean to say that Java does not have feet?
- chongli 12y agoAre you implying that Java cannot be used to make useful software? No, of course not. Are people without feet useless? What does it mean to say that Java does not have feet? It means that it lacks a capability for which it also lacks a need (shoes). This capability is that of expressing purity via the type system. Monads - and by extension, monad transformers - are a tool designed to assist the expression of imperative algorithms in a pure context. The reason I phrase it this way is because people often make the mistake of assuming Haskell is lacking expressive power due to its purity. This is untrue. Haskell is perfectly capable of expressing messy, mutable, imperative algorithms just like any other language. Other languages, on the other hand, struggle to express many of the pure algorithms and data structures used in Haskell; they simply lack the ability to enforce purity within the language and are thus reduced to purity by convention.
- AnimalMuppet 12y agoDoes lack of ability to enforce purity equal lack of ability to express the algorithm/data structure? Or does it just equal lack of ability to prove the purity?
- zak_mc_kracken 12y agoThere are plenty of monad tutorials in languages other than Haskell but Haskell is probably the language where the point of the article is not obscured by the syntactic ceremony of the language. Spend some time learning the basic Haskell syntax (it's really not that hard) and you'll be able to get to the "meat" of such articles much, much faster than if the article were written in any other language.