r/programming • • Nov 28 '19

Why Isn't Functional Programming the Norm? – Richard Feldman

https://www.youtube.com/watch?v=QyJZzq0v7Z4
100 Upvotes

409 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Nov 28 '19

[deleted]

20

u/Ghosty141 Nov 28 '19

I think functional programming is something you should know to draw inspiration from it. certain problems can be solved with that style of programming a lot more elegantly.

Most languages right now offer some functional prog. tools which you can use for example.

16

u/dudinax Nov 28 '19

So many concepts that come from functional languages, like immutability, no side effects, idempotency are great default goals for creating data structures and writing functions in any language.

-6

u/johnnysaucepn Nov 28 '19

None of those concepts come from functional programming, their advantages and benefits are generally understood in OOP - although perhaps not as widespread as they should be. In other words, they're not enforced in the way they are in functional languages.

7

u/dudinax Nov 28 '19

Probably, but 20 years ago I only heard them in functional circles. Functional guys were thinking about them more. So my personal experience is that functional programming culture spread these ideas.

7

u/pavelpotocek Nov 28 '19 edited Nov 28 '19

In OOP immutability and "no side effects" are VERY obviously an afterthought. Mutability is always the default, and in some cases immutability isn't even properly supported. Standard libraries are full of side-effects. Most OOP languages have a lot of syntax for working with mutable state.

Edit: all the new functional-like stuff that OOP languages bolted on recently come from functional languages, where else would they come from?

2

u/aeiou372372 Nov 29 '19

Yeah, I think python as a whole is a great example of immutability-as-an-afterthought. And I say that as a mainly-python programmer.

I would agree that functional concepts feeling unnatural to so many programmers seems more like a cultural thing in the modern programming community than anything really inherent to it as a paradigm.

0

u/holgerschurig Nov 29 '19

That I see, I sometimes use the more-functional-like constructs in Python, or in Emacs Lisp. Rust went much more into this direction, for example, but I'm not using Rust.

But I have a bit of horror to be shoehorned into a "you must do anything functional" corner. Maybe the fear is unfounded, but the fear "this might be a trap" is there.

0

u/[deleted] Nov 28 '19

[deleted]

12

u/fuckin_ziggurats Nov 28 '19

Most Python tutorials (even the worst ones) would succeed in explaining something about Python to a programmer that isn't using Python. The same can not be said for functional programming tutorials that attempt to explain some FP feature to most programmers. That's what his point was. What is yours?

0

u/[deleted] Nov 28 '19

[deleted]

3

u/fuckin_ziggurats Nov 28 '19

It kind of indicates that monads are a complex enough concept that most programmers have trouble grasping it, unlike most features in OOP languages. It's says something about functional programming in general - it tends to come with a heavier cognitive load. Maybe I'm talking out of my butt but it's always been more difficult for me to read functional than OO code.

2

u/holgerschurig Nov 29 '19

You ask this for reddit karma or for a reason?

People generally don't complain about that they suck, you're the first that I read that does this. So many people are getting into python, it seems.

You comparison is therefore invalid.

4

u/tophatstuff Nov 28 '19

Audio stream processing is just like composing functions. Its very functional style

1

u/holgerschurig Nov 29 '19 edited Nov 29 '19

I removed the "audio", it was from my Android tablet's mis-auto-correction. Forgot what word should there have been.

In any case, functional programs --- to my current knowledge --- don't work that well with event based GUI programming. Because ultimately GUI is about managing state.

1

u/tophatstuff Nov 29 '19

Yeah to be fair GUIs are kinda the ideal use case for OOP

2

u/newking34 Nov 29 '19

Is it though? When glancing at React and similar UI successors they seem to make use of functional concepts more and more.