13 points · by Anon84 · 17y ago · 25 comments
The argument that many-core will lead to FP adoption used to appeal to me, but then I studied Erlang, and saw that its concurrency power was due to shared-nothing pure-message passing, and not due to it being functional. FP is a way to not need to share memory, but Erlang doesn't actually use that for concurrency. The thinking seems to be that inter-core communication should be coarser-grained (e.g. at the module level, not the level of recursion over a list), because it will always be slower than communication within a core.
Also, surprisingly to me, the over-hyped web services, SOA and ESB etc arguably also aim at pure-message passing concurrency.
If you actually want to do something you still have to have side effects, and that's when all that Haskell-ish beauty goes out the window.
It is still absolutely worth it to learn functional programming, it will change the way you think, it will make a better programmer in non functional languages, but it won't solve the problems of side effects.
http://journal.dedasys.com/2007/12/12/programming-languages-...
Most programmers, realistically, don't use that many languages at any given time, and if they could use fewer, they probably would. The more territory a language covers, the better off it is... well, at least as long as it can do so relatively well.
let tree = Node (Node (Leaf 3) (Leaf 4)) (Node (Leaf 7) (Leaf 8))
This value is constant, just like an integer or string constant in many languages. In other words, the right-hand side can be arbitrarily complex. And this data structure gets passed around in a very lightweight manner (by reference, not by copying).
The Java notion that values are either primitive, or objects... is limiting.
In my (limited) experience, Haskell code to do I/O (i.e., Monads) isn't a pretty or elegant as purely functional Haskell code. A lot of Haskell's useful tricks (i.e., its beauty like the ridiculously strong type system or lazy evaluation) don't work on code with side effects.
That's silly. Anyone who has worked with a pure OO language knows that there's nothing inherently imperative about the approach. Just because the most popular OO languages (C++, Java) ultimately force you to have a main() doesn't mean that a procedure is required to write OO code. That's more a reflection of the OS execution model than the language used to write the app.
I've personally written CORBA apps that were asynchronous, distributed and multi-threaded -- in C++. Object-oriented development is more than capable of handling the complexity of multi-core processing.
The point is, OO does not require that your code be executed any more sequentially than does a functional language.
OO does not require that your code be executed any more sequentially than does a functional language.
If by "OO", you mean mainstream OO languages like Smalltalk or Java, then they absolutely do have a more operational definition than a pure functional language does. Objects send messages to other objects; as a result of receiving a message, the internal state of an object changes.