3 ms·
This is kind of a surprisingly myopic/inflammatory comment to see on HackerNews. Both systems have their pros and cons, and people tend to be biased to prefer t
by cdrini 5y ago
This is kind of a surprisingly myopic/inflammatory comment to see on HackerNews. Both systems have their pros and cons, and people tend to be biased to prefer the one they learned first or worked extensively with first. And you don't have to choose; most languages nowadays support elements from both paradigms.
But honestly there's nothing even to argue, cause the comment doesn't really say anything.
- bayesian_horse 5y agoMost languages I know don't really shine in both paradigms. Python even comes close, but it is shunned in OOP circles because of dynamic typing and loses street-cred in the FP hoods for its syntax. C# feels clunky in both. F# is good in FP, has good interop with OOP, but why would you? It definitely seems easier (or is more popular) to start people on imperative programming styles, because it is easier to make analogies. From there it's a quick jump to OOP.
- ReleaseCandidat 5y ago> It definitely seems easier (or is more popular) to start people on imperative programming styles, because it is easier to make analogies There are simply _way_ more 'imperative' programmers/teachersTtutorials/books/... than 'functional' ones.
- bayesian_horse 5y agoThinking back to my days of starting programming, it was a lot easier to get my head around "do this then that" rather than working in expressions and functional paradigms. When teaching/instructing others, this impression only deepened. It took a long while to even understand why functional programming has any appeal. I know that some university courses start out with scheme or lisp as a first language. But I suspect they get away with it because they have a captive audience and one that is already selected for high math tolerance.
- anoctopus 5y agoPython loses cred in FP circles for being rather opinionated against FP. Map/filter being second-class to list comprehensions, reduce and partial being in functools, and no multi-line lambdas are the obvious/well-known examples of this, but more generally python has first class functions but doesn't make creating and manipulating functions ergonomic.
- gilch 5y agoWhere is the "no multi-line lambdas" myth coming from? I see this one a lot and its wrong. Python's lambdas can have as many lines as you want. Did you mean to say that lambda expressions can't contain statements? But no Python expressions can! But functional programming is all done with expressions anyway, to the point where functional languages don't even have statements, so what's the problem?
- anoctopus 5y agoNo statements means no locals, which is sometimes bad for clarity and/or performance. Functional langs without statements have let-bindings.
- gilch 5y agoThat's really not true either. The lambda parameters are locals [a]. A let-binding is just a lambda that you call immediately. You can use defaults so the value doesn't have to appear as an argument [b]. Also, Python has assignment expressions now [c], and comprehensions are expressions which can have their own locals [d]. >>> (lambda a, b=2: ... print(a, a, b, b, c:=3, c, *[[d,d] for d in [4]][0]) ... )(1) 1 1 2 2 3 3 4 4 That's four different ways to get locals with no statements.
- ranit 5y agoMy wild guess is that GP comment was meant to "provoke" thoughtful comments in defence of FP. And regardless of GP's intend, it really succeeded in that regard - just looking at some of the responses.