3 ms·
Monads are fairly easily expressed in mathematics but trying to explain them conversationally appears to be an exercise in futility. There are dozens or hundred
by svachalek 14y ago
Monads are fairly easily expressed in mathematics but trying to explain them conversationally appears to be an exercise in futility. There are dozens or hundreds of these explanations on the Internet and haven't seen one that hasn't been declared so wrong by the ones-who-know. (edit: and I'm not one-who-knows but I'm pretty sure "side effects might happen here" falls in this category). Classes, objects, functions, and so forth don't have these issues. There are nitpicks and minor variances between how different languages conceive these, but all seem to be fairly easy to explain and understand.
- tikhonj 14y agoClasses and objects don't have this issue because there is no underlying formal definition for them. They're also less general. Most descriptions of basic OOP ideas are on the same level as "side effects might happen here"; there's just nobody to correct them and nothing to correct them against. Don't get me started about pointers. They're at least as difficult to grasp for most beginners than monads ever were. Hell, people have days of trouble just with references as in Java! Functions do have this issue, and most of what different languages call "functions" aren't. It's just that unlike monads, functions have entered the common mind and people talking about them informally far outnumber those interested in correctness. And many people have plenty of problems with things like higher-order functions.
- nilkn 14y agoI don't know, my dinner table explanation of monads has always been that they are DSLs. Even the Gentle Introduction offers this viewpoint (it develops a DSL in Haskell, as a monad, for writing resourceful computations, that is, computations which consume some user-definable resource at each step and automatically suspend upon consumption of all available resources). After all, one of the philosophies of software development is that you're essentially building up your application as a layer of languages, each of which uses the constructs of the language beneath it as its own primitives, until at the highest level you have what is nothing more or less than a language built from the ground up to express the actions of your application in the simplest terms. You can write a lot of Haskell software without ever delving much more into monads than what I just wrote. It's really that easy. Monad transformers also tend to scare people, but that is silly. A monad transformer just takes the DSL that you've already made with your current monad and it adds in new language features and functionality for you automatically. That's all.