5 ms·
For those you want to learn the functional programming I'd suggest to immedeately commence looking at Ocaml/Haskell instead to see the real big picture. Because
by lelf 12y ago
For those you want to learn the functional programming I'd suggest to immedeately commence looking at Ocaml/Haskell instead to see the real big picture. Because it's of course adorable that you can write map and compose in JS (it's 2014, it can do it everywhere), but FP = many more serious things.
- KurtMueller 12y agoEdx has a course in functional programming using Haskell. I haven't taken it yet but I'm going over Christmas.
- atrilumen 12y agoIntroduction to Functional Programming https://www.edx.org/node/2126#.VGrvnnVGh5Q https://www.edx.org/node/2126#.VGrvnnVGh5Q
- tel 12y agoStrong agreement. "Adorable" is exactly how I describe it. Even if it's already producing practical advantage in Javascript, it's mostly a cute toy given how it stacks up against "normal" usage. Learn Haskell/OCaml and you'll see how to really take this kind of reasoning many, many orders of magnitude upward. Learn Coq/Agda to see yet another meteoric jump.
- CrossEye 12y agoWhile I'm not upset that this has been posted here and has been garnering some attention, this talk wasn't designed for this kind of consumption. I have given this talk to two kinds of audiences: * In a large corporate office with heterogeneous skill-sets among developers, but where almost all had some experience with Javascript. * Javascript Users Groups In each case, the idea was to make the case that FP could offer them practical advantages. The goal was definitely not to teach them FP or to suggest the best FP tool. There are definitely better languages in which to do FP. But if for whatever reasons you're working in Javascript, I would suggest that a functional style could be useful.
- tel 12y agoFor that audience I agree with dipping toes. I just want to place hedges and guards against making "FP" (whatever that means) out to being better syntax for some kinds of streaming operations when it has much, much more to offer.
- sagischwarz 12y agoI'm currently in one of the last chapters of Learn You a Haskell for Great Good (http://learnyouahaskell.com/ http://learnyouahaskell.com/), which is a really nice introduction into functional programming in general and the kind of thought process behind it. It also really helped me thinking recursively and out of the procedural/OOP box (and also learning Haskell, of course). Learning about FP has been the most eye-opening thing I have done since I'm programming.
- kbeaty 12y agoWhile I am currently trying to teach myself Haskell for exactly this reason (understand the "real big picture" in FP), I don't know if there is much harm in starting the journey by exploring some FP concepts in languages one is already familiar with, despite how lacking the language is in that regard. This presentation does point out many features that JavaScript lacks from "true FP" languages. I, for one, don't know if I would have ever tried to start learning Haskell if I didn't discover some of the benefits of FP first hand through a familiar language.
- zackmorris 12y agoI've been wondering lately, if we skip performance as a consideration (for example lazy evaluation), what is the difference between functional programming and imperative programming without globals, pointers, mutable variables or shared memory? In other words, would an imperative language without side effects (that could do static code analysis) be any different in practice than FP? I'm very serious about this, because as far as I can tell, the next best aspect of FP might be first class functions, but those are starting to be used more in mainstream languages (at least the technique of applying transformations on generic data rather than writing special classes everywhere or using templates). I'm beginning to feel that the real advantages of FP are being obfuscated by unusual syntax. There should be no reason why we can't go from some of the FP notations to the plain old algebra style (x=y) of C-style languages like Javascript. With better references and immutable variables, we should be able to split calculations up over several lines and have the compiler figure out how to optimize it into basically FP code. P.S. I do know lisp, so I'm asking for a rather more enlightened answer than just to research it further.
- dustingetz 12y agoIt's different in practice because languages have built-in "opinions" (often codified by syntax, or the standard library, or other ways) that heavily influence their ecosystem. Functional javascript, or python, is not awesome because the default datastructures are mutable, and the ecosystem of libraries are written in an OOP style using mutable data structures. There is some small value in writing the code you control in as FP a way as possible, but you aren't going to have a ton of success in that unless you are willing to rewrite your dependencies to also be more functional. ReactJS may be a killer app that can influence javascript's "opinions" at the ecosystem scale, but that is going to take more time. I've been using ReactJS since it came out as tech lead on small teams, and it was not without challenges to get an OOP trained team to use React well, and to avoid the OO parts of React. Edit: In theory, yes, if you could somehow statically enforce that your C code (and dependencies, including the OS) have no side effects, then some hypothetical compiler could combine your imperative C statements into functional expressions, though I don't know what advantage that would give you. Maybe I have misunderstood your post.
- tel 12y ago
- samspot 12y agoI hate to be this guy, but learning FP techniques that aren't available in my day to day language isn't terribly exciting. I want to see a short term benefit, so JS or Java focused articles and books are golden for me.
- xwowsersx 12y agoThe issue is that if you're going to be doing FP, you'll want to use a language in which it's not just possible, but natural and happens without an uphill battle. Similarly, if you're just trying to learn the concepts, you're going to have a lot of noise distracting you if you use a language like JS, etc in which FP concepts are quite unnatural to express.
- coldtea 12y ago>The issue is that if you're going to be doing FP, you'll want to use a language in which it's not just possible, but natural and happens without an uphill battle. Most FP paradigms are natural and quite easy in JS. And learning Haskell can also be described as an "uphill battle".
- cheepin 12y agoI think he was referring to Java
- jbergens 12y agoOr, you want to use it in your day-to-day job where it might exist thousands upon thousands of lines of code in a not-so-FP language. I think just learning the concepts is great start. If you could rewrite your whole app, please do so. If not, see if you can write some parts with more FP style code. Like using LINQ in C# instead of rewriting everything to F#, or with Java 8 start using streams and other concepts.
- coldtea 12y ago>Because it's of course adorable that you can write map and compose in JS (it's 2014, it can do it everywhere), but FP = many more serious things. Or you know, stick to JS, because it's of course adorable that you can do functional programming in a functional language (we could do that since the 60s), but having access to the most prevalent language in the web and being employable is even better.
- codygman 12y agoWhile I love and use Haskell a lot I would recommend Purescript [0] over Haskell or Ocaml. Even if the only reason (hint: it's not) were that Purescript uses familiar tooling such as NPM, node, CommonJS modules, bower, etc and would allow users to focus on learning functional programming faster. For those that wasn't more than the examples, there is the wonderfully comprehensive, practical, and just plain fun Purescript book[1]. 0: http://www.purescript.org/ http://www.purescript.org/ 1: https://leanpub.com/purescript/read https://leanpub.com/purescript/read