4 ms·
Kudos to the piece for being well written, readable, and clear. But I'm worried about a "for the rest of us" that starts off with first Plato and then lambda c
by rauljara 15y ago
Kudos to the piece for being well written, readable, and clear. But I'm worried about a "for the rest of us" that starts off with first Plato and then lambda calculus.
The problem with "the rest of us" is that these concepts aren't inherently neat. Disclaimer: I'm not one of "rest of us". I'm learning Haskell, just because I enjoy having to think in a new way.
A lot of FP explanations start off with immutability. After plato and lambda calc, that's where this one goes, too. I think because it's a relatively simple concept, and kind of mind blowing that you could do something useful without incrementing i in a for loop. And then the follow up example is normally how you can replicate a for loop in functional programming. Which is again neat.
But if you aren't into neat things for their own sakes, you've got to ask why? Why replicate a for loop when you could just use one? (answer: you don't really replicate for loops in FP) They aren't asking why, in the sense that they're curious. They're asking why in the sense of "Why would anyone do that? That's stupid."
If you aren't into having your mind blown for no apparent reason (some aren't) the only really compelling thing about the first several pages of the piece is the "Benefits of FP". That's the motivation to learn these crazy new concepts. It should really come first. I think it should come first in any discussion of FP for people who aren't familiar with it.
Because for most people to learn, they need a motivation. Your programs will be faster because you can do concurrency super easy is pretty good motivation. Sadly, "because it's neat," is generally not.
- tomp 15y agoThis article is another one of those that confuses functional programming with pure programming (which is, I believe, by definition also functional). You can do a lot of functional programming in a language where values are mutable. I use it all the time in python: the map and filter functions, list comprehensions, zip, ... For me, functional programming means having first-class functions that can be passed to/from other functions. A standard library of common functional combinators help, but you can always write your own. Funny, but some of the most often mentioned functional languages, such as OCaml and Scala, allow liberal use of mutable variables. They just make it a bit harder/more explicit, so the programmer has to give more consideration into it.
- jshen 15y agoYou must have read a different article than the one I read. "Functional programming is a practical implementation of Alonzo Church's ideas. Not all lambda calculus ideas transform to practice because lambda calculus was not designed to work under physical limitations. Therefore, like object oriented programming, functional programming is a set of ideas, not a set of strict guidelines. There are many functional programming languages, and most of them do many things very differently. In this article I will explain the most widely used ideas from functional languages" No where does he say that functional programming is pure programming.
- sharmajai 15y agoYou can do a lot of functional programming in a language where values are mutable. Sure you can do whatever you want, but if the language does not support things like tail call optimization, non-imperative function definition, writing code in functional style turns out to be a lot slower (due to non-tail-optimized function call overhead) and less safe (due to potential side effects in function definition) than if you are writing it in a functional language with explicit support for these facilities.
- JadeNB 15y agoThat's true, but this functionality is perfectly compatible with mutability. Various flavours of Lisp have been in the forefront (CMA: among 'popular' languages) in making this functionality available, but I don't know of any (CMA: 'popular') pure flavour of Lisp. (Maybe Clojure --but its preference for 'immutable by default' is quite different from not having mutable values at all!)
- zby 15y agoOK - I checked wikipedia: In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. Sounds exactly what I was thinking - map is not mathematical function - because it can interact with the global state (you can apply map twice to the same data and get different results - for example if in the function you are mapping you use 'time') - and thus using it is not 'functional programming'. If your first-class functions were mathematical functions - then we could agree - but map is not one.
- evincarofautumn 15y agoI agree. It’s fun for someone like me who likes learning new stuff for its own sake, but I think the “Rest of Us” might feel a bit left out without more practical examples. But hey, that’s the same mistake I made when I last wrote about concatenative programming. Hindsight’s 20/20.
- ImprovedSilence 15y agoI think by "rest of us", he meant nerdy, curious programmers. And not academic PHD mathematicians. I don't know your background, maybe you are deep in the academic world, but if not, it's likely you are the "rest of us" he is addressing.
- iron_ball 15y agoWith that in mind, I recently wrote a series of posts about integrating functional programming concepts into everyday Javascript programming (and AS3, which is nearly identical). The last two, in particular, might be interesting even for programmers who already understand the basics. http://www.alanmacdougall.com/functional-series/ http://www.alanmacdougall.com/functional-series/ I'd really like to see these techniques emerge into the spotlight, instead of just being voodoo magic hidden deep in the guts of frameworks.
- novalis 15y agoVery interisting posts in there from an interesting point of view.