4 ms·
Simple /= easy. Complex /= hard. Monads are very simple. They just aren't easy because most people don't have the base of terminology. When you grok them you'l
by chongli 10y ago
Simple /= easy. Complex /= hard.
Monads are very simple. They just aren't easy because most people don't have the base of terminology. When you grok them you'll laugh because you'll realize how simple and powerful and obvious they seem in hindsight.
This is the reason so many people write monad tutorials after they learn them. It's actually really weird. Does anyone else have some examples of things they learned which seemed really difficult but turned out to be really simple in hindsight?
- smallnamespace 10y ago> They just aren't easy because most people don't have the base of terminology That's like saying a giant, complex library with a nice, tight API is 'simple'. It's not, the complexity is just hidden. Same thing with monads. Once you understand some of the machinery of category theory, or really grok functional programming, then yes, monads are 'simple', but all the complexity lies in getting there.
- kccqzy 10y agoI think you're confusing complexity with learning curve. Complex things can be made easy to learn, if, for example, you have "a nice, tight API." Monads are the opposite. They are simple things that are difficult to learn.
- smallnamespace 10y agoWhy would something be difficult to learn if there wasn't complexity underneath it? There are lots of things that are simple to state, like the fundamental theorem of algebra, but the machinery behind it is complex.
- chousuke 10y agoA simple thing can be difficult because understanding why it works may be nontrivial. However, it remains simple (by definition) if understanding is not affected by complecting factors such as side-effects or the global state of the system. A pure function is always simple, even if it implements a difficult algorithm. I hold the opinion that complicated things can never be truly easy: they can only have the appearance of ease until there comes a time that you must understand all the complexity.
- kazagistar 10y agoBecause it is far away from what you already know. Haskell is a fairly simple language, but it very difficult to learn compared to a language I would consider much more complex like Java, because you cannot reuse as much of what you have learned from other languages. All the monad implementations are just a few simple lines of code, and understanding monad is just a matter of reading a few, reading the rules, and doing enough with them until their utility clicks. However, the type of abstraction they are and the way they are used are very different from the programming you are used to that they seem harder to learn.
- kccqzy 10y agoI'll provide an example in math. Linear algebra is much simpler than calculus. Yet we teach high school students calculus but not linear algebra. Why? Because a lot of the complexity in calculus can be hidden away behind some hand-wavy definition of a limit and consider basically only smooth functions. That way, we have engineered our math classes to avoid the complexity underneath, and we have high school students finding calculus to be easy to learn.
- ves 10y agothe latter phenomenon occurs at least three or four times over in good (rigorous, proof-based) math classes. I've had this happen for - everything from linear algebra (at least 20 things) - all kinds of stuff from mathematical optimization - inequalities, which are really difficult until something "clicks" and then when to apply them becomes obvious, cauchy-schwartz and jensen's in particular - induction (this was a long time ago / early in my math career) - diagram chases - the entire typeclass stack from FP (functor applicative monad, then all the monad interfaces) - huge chunks of axiomatic probability and measure theory (what do sigma algebras really mean, what is a good definition for integration, what is continuity of measure, dinkin's pi-lambda theorem) - and so it goes on I am still waiting on some of the following things to click so that I may abuse them productively as well: - LLL - yaos min-max theorem - lots of results from logic I surmise this happens for monads and freaks developers out because it's one of the few pieces of serious math (i.e. no handwaving, given as a rigorous construction, etc) most people come across, so the phenomenon catches people off-guard. If you like this thing, do more math!
- chongli 10y agoI do like this thing! I love math. I tutor young people in math at a local school. I've applied to an undergrad math program at Toronto and Waterloo as well. Hopefully I can get in...
- alok-g 10y ago>> Simple /= easy. Complex /= hard. Beautiful insight. I now realize that simple and complex are about the concept being learnt, and easy and and hard likely to be about the process of learning. There would be correlation in general, however, not always. :-) I have seen many examples of things which are easy at the end, but the process of reaching there was hard, sometimes because of initial ignorance of my own or of mankind overall.
- chongli 10y agoBeautiful insight I wish I could take credit for this one! I learned the distinction from a (rather famous) Rich Hickey talk. [0] [0] https://www.infoq.com/presentations/Simple-Made-Easy https://www.infoq.com/presentations/Simple-Made-Easy
- disconcision 10y agocontinuations? closures? things that are very similar to other things when expressed concretely, but actually exist at different levels of abstraction? things that are counter-intuitively awkward to express by way of examples, because too many things are examples, sometimes in multiple subtly different ways? adjunctions (etc.) in category theory seem like 'above paragraph : the movie', but i can't claim to understand them in full generality so i'm unsure.
- hota_mazi 10y ago> Does anyone else have some examples of things they learned which seemed really difficult but turned out to be really simple in hindsight? Sure: everything. Everything is complicated until you learn it, and then it looks simple in hindsight. You're just confirming what OP said: it's not easy to come across an article explaining monads or Haskell that doesn't implicitly rely on the fact that the reader already understands monads or Haskell.
- coldtea 10y ago>Monads are very simple. They just aren't easy Yeah, we don't care for simple. Can you explain them in an EASY way?
- chongli 10y agoLots of people already have. The problem is that those who try to read up on it haven't built the conceptual bridge to get there. Monads are a simple piece but they sit atop a tower of simple pieces, none of which can be skipped. People who hear about Haskell try to jump in and learn them without having the foundation they need. They see the superficial similarities between Haskell and other languages but fail to grasp the more significant differences: higher-kinded types and type classes.
- coldtea 10y ago>Lots of people already have. The problem is that those who try to read up on it haven't built the conceptual bridge to get there. No, as someone who understands monads (and not thanks to the explanations usually given) the real problem is that most explanations are crap and needlessly complicate the matter. Including every one I've read thus far (well, up to when I made my comment) in this thread. It's as if they can't lay off Haskell notation and concepts for a moment to give people the overall picture. People, stop mentioning "functors", "monoids", ">>=", "bind" etc in your Monad explanations. Also drop the Haskell function definitions. Even fmap shouldn't be taken for granted (as something already known) in a Monads explanation. Just describe what it does, giving a simple example. And when talking to Javascript programers use types and names of types that they already know, such as "array", not List. Even such simple terminology distinctions like those matter. >They see the superficial similarities between Haskell and other languages but fail to grasp the more significant differences: higher-kinded types and type classes. The whole magic of explaining is to give an idea of the "significant differences" without requiring any foundation beyond what an average blub programmer already has.
- jnordwick 10y agoThe condescension bugs me a little: I must not have enough background, Haskell is too high-level for me, etc... I'm a pretty good developer, and my language skills are all over the place. I did a lot of Scheme and Lisp early on. I used to try all the turing tarpit languages. I do mostly C++ and Java systems work now. And my current learning is Go and Rust. I've literally written my resume in PostScript years ago, and I still use APL-derived languages. I read and learned lambda calculus over a cross country business trip even. And even with this background I find Haskell at times inscrutable, more often than not because somebody is trying to give me a description filled with unknown terminoligy and lines of Haskell itself I have no idea what it means. There concepts aren't foreign to every other languages. Show them to me in pseudo-lisp, and I'm sure I'll do a pretty good job of picking them up. It looks like you could even describe monads in C by passing around opaque pointers, with some caveats.