45 points · by Rickasaurus · 14y ago · 46 comments
(Also, mocking Haskell and/or its community for being too theoretical is really missing the point. It's one of the few places where progress is being made on the topic of practical compositional programming. No, the work's not done yet, but, then, that's sort of my point, work is in fact being done. Almost everybody else is just shuffling the same handful of 25-year-old primitives around.)
Computers are imperative by nature. They have state. That Haskell has the capability to shield us from that is really, really cool, but that doesn't mean it's necessary to write good software.
Programming is a young endeavour, and advancements will be made in languages for a long time to come. We should continually reevaluate our tools so that we can make the best software we can.
(A lisp advocate once told me tail recursion was great because it let you write an event loop without getting a stack overflow. The example code they gave would have been much clearer as a "while" loop, but I guess lisp doesn't have those. It seems like the same thing to me)
The presence of a separate, non-computational storage in computers based on the von Neumann architecture implies the representation of state (at some level or another) is possible by those same machines. Consequently, we are tempted to utilize that capacity for state as storage for intermediate data within program execution itself, rather than just as a place to store the executed program itself.
I could be totally missing the mark on it having to do with the von Neumann model of storing, fetching and executing programs. But from my limited reading about computers such as ENIAC, which required the circuit to be altered to route signals prior to execution, and then run through the program all at once. Someone please correct me if I'm wrong, because this stuff fascinates me and I'd love to be told straight.
TL;DR: Storage implies state, so we wrote tools (languages) to leverage that.
Guido adds first class functions and functools to the standard library and people suddenly start calling Python "functional." The same is probably going to start happening to Java once λ expressions get added.
I think functional programming has been most clearly defined as those languages whose base model of computation is the λ-calculus (or F_ω, etc.). Python is not functional because, despite having functional features, the idiomatic way of writing Python mirrors Turing machine computation.
If you restricted yourself to only the functional features of Python, well, that would be Python in name, but is that really how people write Python?
The point is terminology matters, especially in how those who can't be bothered to dig deeply come to understand things.
Calling it Expression Oriented programming is something I've taken to recently and it get people on the right track off the bat. They're focusing on the expressions and not just trying to understand how everything relates to functions.
To the author's point, supporting functional programming is not hard and most languages do it. Basically all languages, except Java and maybe like Pascal or something. I'm ok with that, though. I'm fine that I can write my own JavaScript functionally, even though other people may not. (Though it's annoying when I interface with less-than-functional third-party libraries.) After all, part of the reason to learn Lisp or Haskell is to make you better at Blub, right? Merely supporting functional programming means that I can still put those lessons to decent use.
What's forcing you to stay in Blub to begin with? There's great same-platform alternatives to everything except for Javascript.
www.cs.cmu.edu/~crary/819-f09/Backus78.pdf
http://en.wikipedia.org/wiki/Function-level_programming
Most languages nowadays are value-level. The difference between the two is that function-level programs combine "sub-programs" into one giant new program. Value-level takes primitive types and transforms them into more complex types (I believe this is the same sort of complexity that Rich Hickey disparages).
Things are often called what they are called for continuity and for legacy reasons. What does it matter if we call it "Functional" vs. "Expression-Oriented"? Will Haskell, ML, Clojure, etc. or their impression on people change overnight because we have a new cool name? I guess a bunch of new/experimental library now claim to be Functional, but so what if they do?
Maybe it's a bit too late here, but I don't see the point in this kind of sentiment.
etc, and the entire construct can be assigned to a variable because it is an expression.
As an aside, ruby 1.9 also supports generic predicates for case statements through lambdas, which is very concise and powerful. Example: https://gist.github.com/838163, source: http://flazz.me/predicates-in-ruby-case-statements
The term "functional" really evokes "first class" invokable function symbols that can be passed around in a higher-order kind of way. Everything else is secondary.
I'm planning on writing about that next time around because my tracking shows barely anyone gets to the end of an article beyond a certain length.
Erlang, Haskell, and Scala all want to sell you on some broader paradigm of functional programming, but they're all still functional at their core and understanding the fundamentals is far more important.
Node.js isn't a language, it's just some libraries added on to Javascript.