4 ms·
As an OOP afficionado, I am embarrassed by how mushy our discipline is compared to the crystal clarity of our functional bretheren. How I wish I lived in a worl
by munificent 12y ago
As an OOP afficionado, I am embarrassed by how mushy our discipline is compared to the crystal clarity of our functional bretheren. How I wish I lived in a world of such well-defined boundaries.
After all, everyone knows that FP was started with Lisp with the insight that the heart of FP is homoiconicty. Except where it isn't, as in ML and others.
Likewise, functional programming introduced a higher level way of expressing our intention without being bound to the low level machine representation of values. Unlike Fortran and Cobol, all functional languages use dynamically typed variables (except for ML and its derivatives) and operate at a level of abstraction above the primitive underlying machine (except for nil punning, car, cdr, etc.).
While OOP languages endlessly fiddle with syntax, functional languages all agree that only way to represent code is with s-exprs. Or not, as in ML. And that function arguments should be lists. Or is it tuples? Or curried?
Either way, syntax is just window dressing. What really matters is semantics, and here functional programming has always stood for a very firmly defined set of behaviors. Functions should be pure, as in Haskell. Except when they are not as in Scheme, Lisp, and ML. Evaluation should be by name. Or by need. Or eager.
There must be macros. Or not. They should not require hygiene since that is an artificial limitation, except that they should require hygiene because unhygienic macros are evil.
Let's not forget one of the key contributions that functional languages have given us: lexical scope. All functional languages use it strictly. Except for Emacs Lisp which does not, and Common Lisp and Clojure which have options to not use it.
OK, fine, I'm side-stepping the most important facet that all functional languages agree on: first class functions. This is the defining feature of FP languages: all functional languages have them, and all other languages do not. Except for Lua, C#, Java, C++, JavaScript, Self, SmallTalk, and others. But, functional languages certainly have first-class functions more thoroughly integrated into the rest of the language than non-FP languages do. Except for Common Lisp, which relegates them to a separate namespace.
In conclusion, I think we can all agree that object-oriented languages could learn a lot from FP about how to keep your terminology precise.
- seanmcdirmid 12y agoSlow clap :) The main problem with the OOP community is that it has basically gone incognito. There are no edgy new ideological OO languages being pushed for mass adoption (like Scala, Clojure, Rust, or even Haskell); instead we have Dart and TypeScript as very pragmatic plays. Time to wake up. And, as the article suggests, we all have completely different ideas of what OOP really is. It is all about the messages, or polymorphism, or classes/prototypes. Or maybe it is all about the nouns and object thinking. But as you suggest, the FP people have similar problems.
- minikomi 12y agoI'd love to see a pragmatic play in the FP space.
- seanmcdirmid 12y agoThere are plenty of mature pragmatic FP languages out there, like OCaml, ML, F#, or even a disciplined subset of Scala.
- codygman 12y agoHaskell is pragmatic.
- Dewie 12y agoThe article is silly, and so is your response. Functional programming most usually, the vast amount of time, refers to a declarative style of programming which involves using functions in the more mathematical sense, which means that one tries to avoid state and side effects. Not necessarily as a compiler-mandated thing, but as a convention. Does one still make "functions" from time to time which are really about mutating state and/or side effects? Yes, but then you would say that they are doing a more procedural/imperative style at that point in time. Like java can be procedural, if you try hard enough. "[...], and all other languages do not." - Demanding that other languages - which might not self-identify as 'functional' - not have something seems like a futile demand. Are those languages just gonna be banned by the almighty FP wizards? :) I've never seen things like the syntax of lisp, the homoiconicity of lisp, the lazy evaluation of Haskell, be equated with functional programming as a whole.
- munificent 12y ago> The article is silly, and so is your response. Guilty as charged, though I fear the original article doesn't realize it's silly too. > Functional programming most usually, the vast amount of time, refers to a declarative style of programming which involves using functions in the more mathematical sense, which means that one tries to avoid state and side effects. Maybe it's just me, but I've never found most functional code I've seen to be particularly declarative. I certainly like purity and immutability, but much of it still reads imperatively to me, just in a slightly more abstract style. But, then, that's true of OOP code that I like too. I find method calls (in good APIs) just as declarative because there I'm describing what I want the object to do and not how to do it. > Are those languages just gonna be banned by the almighty FP wizards? :) I think they prefer the term "smug Lisp weenies", but they probably wouldn't turn down that title either. :) I think arguments like this are silly because I don't really like any single-paradigm languages. I think functional, object-oriented, imperative, declarative, etc. are all styles and each of those styles has its place, often all within the same program. People (like the author of this post I suspect) like FP because it rejects OOP, but I like OOP because it doesn't reject other styles. Mainstream OOP languages have no qualms about adopting higher-order functions, closures, immutability, and all sorts of different concurrency models. I like simplicity, of course, but I also like having a lot of tools at my disposal and not rejecting some for religious reasons.
- sklogic 12y agoWhat? FP has absolutely nothing to do with homoiconicity. And it was not started with Lisp. It started in 1930s, long before any programming languages existed. Lisp was never a real FP language and never intended to become one. FP is perfectly well defined. Most people would agree that most "functional" languages are not really functional but only employing some elements of the functional programming. There is no such a wide disagreement as with the vague, useless, pathetic notion of OOP/OOD.
- boomlinde 12y agoCongratulations on defeating all those straw men!