Good answers have already been given, but there are still some questions left to be answered by the PO, which I will try to address here
What are the pros and cons of functional programming [in relation to parallelism and threading]?
The issue here is not so much the functional vs. imperative, but rather mutability vs. immutability.
Imperative languages tend to make great use of structures and objects mutable, with state change. A property of an object, encapsulated by a pair of methods get and set is an example of this.
This style of programming is usually simple, in an environment single-threaded, but gains orders of magnitude of complexity when considering multi-processed environments. For, if more than one process can read and change a variable, it is necessary to control the accesses simultaneous read and write to memory (through the use of semaphores, for example). And this control, because it is very complex, is also very susceptible to problems such as deadlocks, low performance and other implementation errors.
Functional languages tend to use only structures and objects immutable. This means that created objects are never changed again (if an information needs to be changed, it implies creating a new object, and do not change the old).
This style is much more expensive, from the point of view of memory consumption, but it has a great advantage: all the difficulties associated with memory reading and writing control cease to exist (but, of course, some new difficulties also arise).
Hence, in part, the predilection of functional languages for lists, because they are structures that can be easily manipulated, without giving up the immutability (it is possible to "add" an item to a list simply by creating a new "head" that points to the old list - that is, a new list object is created, but without having to copy the items from the old list to the new one, saving processing).
'Cause I should learn Haskell?
That’s a trick question, because I don’t think so that you should learn Haskell (at least not now)!
You (OP) don’t seem to have much knowledge about functional languages. And Haskell is for sure one of the most complex and difficult programming languages to learn. In addition to immutability, you would have to learn concepts such as lazyness, purity, type-classes, monads, monoids, transactional memory... And believe me, this is all the stranger than the fact that it’s functional. : P (In my opinion, it’s more or less like wanting to learn quantum physics, without having learned classical Newtonian physics: it’s possible, it’s just not sensible).
There are much more accessible options:
- Scheme is a multi-paradigm Lisp language, suitable for students, that makes strong use of functional concepts, and is relatively easy to learn (if you ignore the parentheses).
- Clojure is more of a Lisp dialect. Some claim that it is even more modern and more functional than Scheme, with the advantage of running on the JVM. Personally, I haven’t had the opportunity to learn Clojure in more depth, but it seems to be one of the most interesting languages to use today.
- Scala is a language that I have professional experience with, and therefore can speak better. At first glance it looks a lot like Java and Ruby, but from "inside" you can see that it was very inspired by Haskell. It is not fully functional, and is far from pure, but is usually a good option for those who have experience in OOP languages like Java or C#. Libraries like the Lift (a web framework) also allows you to see, in practice, the advantages (and disadvantages) of functional style in areas typically dominated by traditional object orientation.
- F# is, like Scala, another example of functional hybrid x objects. But F# "picks up heavier" on the functional side, for being a superset of Ocaml. It can also help to get the "prerequisites" needed to learn Haskell (for example, the computation Expressions of F# are monads, which in turn are very important to understand Haskell).
Apart from these, it is possible to use the main functional concept, first-class functions, in Ruby, Python and even C# (3.0+) and Java (8.0+).
After your question, this one came up, it would be nice to reconcile the ideas, or leave the one more focused on Haskell itself: http://answall.com/questions/13372/programm_functional-e-programm-object-object-que-sao-e-quais-suas (not duplicate, only Inkei to cross-linking for interested parties)
– Bacco
@Bacco In my opinion, it is better to leave as separate questions. I don’t know enough about Haskell to answer, but I do know that he is quite different from the most "popular" functional languages (Lisp, F#) by his rather rigid type system (in addition to being "purely" functional - unlike Lisp, for example, which includes non-functional features). I mean, it’s not just about discussing functional characteristics - that can apply even to imperative languages, such as Python and Ruby - but rather to a language that does not run away from this paradigm even a millimetre.
– mgibsonbr
Being "pure" and being "functional" are separate yet related concepts. This means, for example, that Scheme (a type of Lisp) is not "less" functional than Haskell, although only the latter is considered "pure". See http://stackoverflow.com/a/4382400/158074. But, in fact, Common Lisp is no longer considered a functional language, precisely because it admits the imperative style.
– rsenna