+ 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?
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.
+ 1
Ettienne Gilbert : Python *is* strongly typed. I assume you mean static typed
+ 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/
0
Haskell, Scala. But they have a steep learning curve
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...
0
How about the fp parts in python?
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!
0
@Ettienne Gilbert: no worries, it happens even to the best