3 ms·
Because it's hard and non-obvious. Nothing in the real world works this way (including computers). It's mathy, it's hard like math, it's beautiful like a proof,
by brianolson 8y ago
Because it's hard and non-obvious. Nothing in the real world works this way (including computers). It's mathy, it's hard like math, it's beautiful like a proof, but that only works for the small subset of the population who want to be mathematicians. Maybe there's some brain structure thing where this works better for 5% of the population. Maybe their biologically wired implicit grammar processor in their brain is a little different. Maybe in the next century we'll find a gene for 'functional programmer'. But it still just doesn't work for the majority of people. If it works for you, rock on with that for your solo work or find a group of likeminded people and do something with them, but I think it's just not going to have appeal to most people.
- SubMachineGhost 8y ago> Because it's hard and non-obvious. I would argue that for someone who never programmed functional programming will be much easier to learn. Your statement is only correct for people who programmed for years in an imperative style and then tried to pick up FP, because at this point you have a lot of unlearning to do, and a lot of your know how becomes absolute, don't use variables, don't use loops, push your side effects out... and after all this unlearning you'll have to learn new concepts and abstractions like Monads and Applicative...
- gerritsg 8y agoDo you think monads, functors, recursion, and immutability (just to take a few staples of functional programming) are easier for a beginner to wrap their head around than loops, re-using variables, etc? I would be surprised if, using a sample group of say 100 beginner programmers, the majority found Haskell easier to learn and write beginner stuff in than JavaScript, python, or insert-primarily-imperative-language-here.
- didibus 8y agoMost of these are advanced topics though. You don't teach a beginner about OOP design patterns from the get go either. If you start with defining functions, calling them, composing them, and using map/filter/reduce and all the stream like operations filter, remove, select, merge, substract, etc. I think it might be just as simple. Haskell is a bad choice though, because it also forces you to learn about advanced type theory. The truth is, I do believe there is a gap in that there's no FP language that doesn't also introduce another complex paradigm. MLs introduce advanced type theory. Lisps introduce advance meta-programming and homoiconicity. If you take Python, and teach it using only its FP constructs, I think that is probably simpler to learn to a beginner.
- a-saleh 8y agoOn one hand, I agree that there is something about the "biologically wired implicit grammar processor". I would view it more along the lines "if you state your problem in a way we are used to talk abou it, you will find your solution easier." I suspect this is the reason, why even my parents, that are mostly economists, like SQL whith its faux-english, but I wouldn't try to teach them relational algebra :-) On the other hand, I am not sure functional programming is so far out of bounds of normal people. Annecdotaly, when I was learning programming, in an after-school club, when ~12, I remember my teacher (a college student) complaining, how hard was it for me and other students to comprehend a statement like "i = i + 1". I think the language was Basic. I suspect that if we have been taught something more functional, we might not even encounter this :-) I am actually not sure why we had problems with this. Maybe because we already were solving equations in school, and "i = i + i" is looks like "0 = 1" nonsense. Maybe the self-reference tripped us up, and recursion would trip us the same or worse. Maybe the = sign was the problem, where it means sometimes equality check and sometimes value assignment.