+ 1

Functional programming

I would like to learn more about functional programming! Where should I start and what languages is best? Why to use functional programming over imperative programming? Is there any good guides out there?

20th Dec 2016, 7:40 PM
johan
8 odpowiedzi
+ 1
Yes, I agree. I would rather go for a well established imperative language that support some of the useful FP constructs (purity/safety) and allows multiple styles/paradigms. Python is a good choice. If you want a strongly typed language doing the same you can look at D.
21st Dec 2016, 6:13 AM
Ettienne Gilbert
Ettienne Gilbert - avatar
+ 1
Ettienne Gilbert : Python *is* strongly typed. I assume you mean static typed
22nd Dec 2016, 12:22 AM
Amaras A
Amaras A - avatar
+ 1
If you're looking for something with upsides of both functional and object oriented programming, try Rust https://www.rust-lang.org/en-US/
22nd Dec 2016, 12:45 AM
Rishi Anand
Rishi Anand - avatar
0
Haskell, Scala. But they have a steep learning curve
20th Dec 2016, 8:07 PM
Rishi Anand
Rishi Anand - avatar
0
There are others too (Scheme, Lisp, Erlang, ..) but I agree - Haskell and Scala are the ones that seem to be most popular. I'm no functional expert, but apparently the big deal is that functional languages are more mathematically pure. For example, functions in FP languages are not allowed to have side effects outside the function - so passing pointers as arguments to functions are not allowed (since this can mutate variables outside the function). So only passing by value is allowed, and returning though the return value. This means FP languages can cache function results, and if the function is called again with the same arguments, just return the cached result. This property also makes FP functions ideal for threading. But IO seems to be one of their Achille heels. IO cannot be "pure", so they need bailouts from purity to accommodate IO ( called monads in Haskell). They have other performance issues as well (excessive allocations) plus the face that function purity makes some algorithms /idioms extremely difficult. I'm not yet sold...
21st Dec 2016, 12:22 AM
Ettienne Gilbert
Ettienne Gilbert - avatar
0
How about the fp parts in python?
21st Dec 2016, 6:01 AM
johan
0
@Amaras A: Indeed you are right - Python is a dynamically typed, but strongly typed language. My bad - you get that from typing without thinking!
1st Jan 2017, 12:43 AM
Ettienne Gilbert
Ettienne Gilbert - avatar
0
@Ettienne Gilbert: no worries, it happens even to the best
2nd Jan 2017, 3:38 AM
Amaras A
Amaras A - avatar