So how exactly does functional programming make parallel processing easier, at the end of the day the challenge is how to split up a job while keeping them independent enough you don't have too many threads all paused waiting from one thread to finish. More specifically how is functional programming better than the more common model of strong OOP plus thread pools embraced by C# and java (also c++ but far more painful to make work).
Pure functional languages help because it allows the compiler to mathematically reason about interdependencies in data. That's about it, really. I don't know any real details, though.
Yes, because of the way it works, FP would lend itself to parallelism, though I have honestly never thought of it. I can see how it would work, but I am having a terrible time trying to explain it. It sorta boils down to how FP and Imperitive languages execute:
Functional
foo(bar(gaz()))
Imperative
foo()
bar()
gaz()
The first has no notion of a program state; it says explicitly what the result will be, that being the return value of foo(). You cannot, under general circumstances, call multiple things one after another.
The second does have a notion of a program state. You can use phrases like "after I call foo()", etc., and after you do call foo(), who knows what the state of the program will be. Anything could have changed.
Because functional programming generally ignores the idea of state, parallelism is far easier because threads can't exactly collide with each other trying to access data, like they can in C/C++. That is not to say you can't hack the general behavior of one into the other; I've done it, it is just a little painful at times.
Now Haskell...that is in the category of voodoo. It is cool, and there are plenty of awesome things it lets you do, lazy evaluation alone being pretty cool. Its literally like telling the compiler "hey, this is exactly how to do this" on a very high level, and then it does it.
If there is a question of what language to learn first...hmm. The most applicable is probably Python, because:
- most big languages have a C-like syntax, which though different in the details, is effectively like Python's
- since white space is syntactically important, you are forced to get into the habit of well formatted code
- garbage collection
- objects, which is a must for fun things like games
- tuples so you can return multiple things from a function
- a nice insulating layer between you and your hardware/memory
- implicit typing; I think it is good for a beginner because, although it will cause you some heartache, you have to check what kind of stuff you are passing around and those skills are good for higher-powered stuff like C where you can override the type checker
Any other intro-type language has it's own set of issues for newbies: non-standard syntax, surprising behavior, mathematical behavior (which not everyone gets, mind you), and sometimes just general badness.
Also, prototyping in Python is the most productive method of development in my opinion. It is like programming duct tape: you just sit down and get something working real fast, then can analyze how it works so you can implement it in something else.