9 ms·
I maintain that the best way to get started with functional programming is to pick a functional language and try to write a program with it.
by katovatzschyn 15y ago
I maintain that the best way to get started with functional programming is to pick a functional language and try to write a program with it.
- rwmj 15y agoExactly this. Trying to write pure functions in a standard language is completely the wrong approach. You might as well say, tie one hand behind your back and try to write with the other hand. Many functional languages don't require pure functions. Many functional languages have garbage collectors, and they are fundamental for writing pure functional data structures. (It's almost impossible to properly emulate this in, say C, especially if your structures have cycles) Many functional languages have other great features like type inference, macros, data patterns and more. Just using an existing language won't give you any taste for these.
- eru 15y ago> Many functional languages don't require pure functions. Yes. Though I would suggest a newcomer to pick a language that requires purity, in order to make the transition cleaner.
- seclorum 15y agoThe point is not: how. The point is: why.
- Peaker 15y agoThere are plenty of resources on why you would want to program functionally. One of the most notable one is: http://www.cs.utexas.edu/~shmat/courses/cs345/whyfp.pdf http://www.cs.utexas.edu/~shmat/courses/cs345/whyfp.pdf Benefits include: Easier reasoning about code correctness. More powerful abstractions leading to clearer and more succint code. Easier mechanical refactoring of code. Easier parallelism. More powerful compiler optimizations.
- seclorum 15y agoGreat, now answer: why not.
- eru 15y agoDepends on what you are looking for. Apart from any benefit from actually using any language or tool, there's also the joy of learning.
- gaius 15y agoI would finesse that slightly and say that the way is to pick a multi-paradigm language (OCaml, Scala, etc) and gradually work in more FP as you get more comfortable with it. E.g. you can start gently by simply replacing for loops with maps or folds, then introduce HOFs/closures, etc etc.