TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Why is functional programming not more popular?

27 pointsby allanmacgregorover 5 years ago
In the last couple of years I been getting involved with Elixir development and as of late starting get my toes wet with Scala.<p>The more I learn and use functional programming languages like Elixir, the more I&#x27;m convinced there is a significant advantage to using functional languages&#x2F;paradigms specially in certain domains.<p>Yet, Functional programming is still regarded as a fad or fringe, curious to hear HN perspective on the matter.

15 comments

stevenaloweover 5 years ago
Dear FP evangelists - Here’s how to sell the unwashed masses on FP:<p>1. Shut up about monads. “Monads” sound like a bad D&amp;D monster. No one cares about either of those things<p>2. Benefits sell, not mechanisms. Show me the benefits in a way that solves my problem without warping my brain around in the process, and I’ll buy it.<p>3. Every new paradigm has a ‘gap’ that must be overcome, a proverbial “click” of a new brain-circuit forming, before understanding&#x2F;enlightenment is possible. This process is accelerated by direct experience, but slowed glacially by overly formal abstract presentations<p>4. Stop trying to show me how hip&#x2F;smart&#x2F;woke&#x2F;l33t you are by spouting FPisms; that impresses no one, bores most, and makes you look like a poseur. Benefits, McCoy.<p>5. I love Scala, but it’s an acquired taste that didn’t happen overnight, and it started as a non-threatening “better Java” path that led to self discovery through refactoring. Please Give us space to breathe and languages that don’t cause Calculus 101 PTSD flashbacks.
评论 #21460047 未加载
评论 #21468868 未加载
SamReidHughesover 5 years ago
There are several kinds of FP:<p>There&#x27;s FP as in, it isn&#x27;t horrid C++&#x2F;Java class-making with virtual functions and constructor boilerplate.<p>There&#x27;s FP as in, hey we&#x27;ve got lambdas and are doing stuff with them (like chaining callbacks or using futures).<p>There&#x27;s FP as in, a language that materially inhibits your ability to be non-explicit about what your code is doing.<p>So it might be good to be aware of what mechanisms by which FP provides a benefit. Much of it is, it&#x27;s not horrid class-making and workarounds to do basic stuff the language should support. It&#x27;s just half-decent language design. But then there&#x27;s the matter of being materially or somewhat culturally being explicit about side effects. And these are two different aspects.<p>And many devs don&#x27;t get the latter. They&#x27;re kind of smart-sounding words and they&#x27;ll agree with them if you say it, but they don&#x27;t really get it.<p>And among people who don&#x27;t really get it, there&#x27;s also the FP people who cargo-cult it. I&#x27;m talking about the people that rewrite their for loops in terms of map&#x2F;reduce&#x2F;std::transform or what-have-you, because they&#x27;re crazy people unwilling to make mutable local variables. (Kind of like how some will never make a function-local goto statement.)
yesenadamover 5 years ago
(Probably this is a very naive comment. Anyway..)<p>I&#x27;ve dabbled in some FPish languages, most lately Prolog (which I loved) and ML. I do a lot of graphics programming, so was wondering how to do that with ML. Like say you have an 3D array representing colour pixels, and want to change a pixel&#x27;s colour. It seems in FP either you make a new copy of the whole updated array, or use fiddly workarounds where you store the changes and actually do them at some later time.. Googling about it, I felt quite embarrassed for FP, since all the talks I&#x27;d seen present it as a mega-cool super-sophisticated best way of doing everything. And as if changing variable values is a barbaric sin. ..So, back to C to do graphics.<p>Situations like this, where large data structures must be repeatedly changed in small ways, which happens in a lot of domains I guess, seem tricky to do efficiently with FP!
Tomteover 5 years ago
* People think imperatively most of the time.<p>Together with<p>* Imperative&#x2F;OOP programming works. All kinds of cool software have been built using those paradigms.<p>that means that few people have a pressing need to look into functional programming. Some who are curious do. Some of those love it and don&#x27;t want to go back.<p>But there&#x27;s nothing wrong with not doing functional programming!<p>And last<p>* Both C++ and Java have adopted (or stolen) quite a few things from functional programming languages.<p>The FP purist will say that it doesn&#x27;t matter, but it really does. They stole those parts that get their users maybe a quarter the way to functional nirvana, but with very little effort. That&#x27;s obviously enough to succeed.
评论 #21458798 未加载
评论 #21479766 未加载
fulafelover 5 years ago
In the market of ideas, there usually isn&#x27;t any reason that makes the good ideas unpopular. That&#x27;s the default outcome.<p>Some good ideas eventually make it to mainstream &#x2F; conventional wisdom because there&#x27;s some second factor that brings them to the spotlight. For languages it might be a killer app, big corporate investment, etc.<p>In <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=QyJZzq0v7Z4" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=QyJZzq0v7Z4</a> Richard Feldman puts up a (well founded IMO) argument that OO became accidentally popular because of C++. C++ didn&#x27;t do OO well, nor was OO the main benefit of C++, it just happened to be something that came with C++.
p1eskover 5 years ago
Because no one can clearly explain the advantages of FP. Not “in theory”, but using commonly used practical tasks. I don’t care about immutability unless it clearly makes my life easier and so far I got by just fine with non-FP style of doing things. The only valid argument I heard is “it expands your mind as a programmer”. Yeah, whatever.
评论 #21455279 未加载
评论 #21456516 未加载
phonebansheeover 5 years ago
You live in a world where the dominant programming languages include things like JavaScript, PHP, and Python. It&#x27;s not that no one cares about functional programming, it&#x27;s that almost no one cares about _any_ kind of structure. (Yes, that&#x27;s an exaggeration, but not by a lot.)
a_bored_huskyover 5 years ago
This is a recent talk on the topic by Richard Feldman: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=QyJZzq0v7Z4" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=QyJZzq0v7Z4</a>
artemisynaover 5 years ago
You are correct that it is easier to use functional languages in some domains. There are quite a few messaging clients that use Erlang under the hood. Facebook uses Haskell for its spam engine, where being very explicit about if a long chain of things fails open or closed is important. These days, most of the major programming languages have ways of representing functional elements.<p>However, it&#x27;s hard to make functional programming general purpose. There are some posts about it elsewhere, but iterative programming tends to make reasoning about the storage of different objects in memory quite a bit easier. Given how all abstractions are leaky anyhow, there will almost always eventually be some component that is easier to deal with using OOP. The inverse is not necessarily true.<p>There are some practical considerations here as well. While it&#x27;s possible to make OOP-esque structures in functional languages, it&#x27;s not trivial. Meanwhile, using a piece of functional code in an already OOP system generally isn&#x27;t too bad - there is, once again, some syntactic sugar, but the scope tends to be clearer. Putting a bit of functional code inside say, a class, tends to muck with the usage and assumptions of said class less than putting a bit of OOP into functional code.
评论 #21453718 未加载
评论 #21456759 未加载
muzaniover 5 years ago
I&#x27;d turn the question around. What does functional programming do better? What would you miss about not having it?<p>I like OOP because it&#x27;s like boxes where you can just plug one cable from one part into another. It&#x27;s easy to write &quot;contracts&quot; in, as in assigning what object does what.<p>There are definitely flaws with this, in that it can get messy, but does FP solve it better? What exactly does FP do better?
评论 #21466678 未加载
评论 #21459430 未加载
评论 #21458667 未加载
ktpsnsover 5 years ago
My gut feeling: Because it is more difficult. Many people fear the learning curve and better do what everybody else is doing.
评论 #21468651 未加载
评论 #21454033 未加载
valandover 5 years ago
1. Older paradigms have been reinforced by many predecessors, creating lindy effect.<p>2. Being a relatively new paradigm, less people understand where, when, how, and why FP fits. There is a lack of effective education over FP.<p>3. Having some radical jargons (e.g. HOF, recursion &gt; looping) , FP brings fear of change. Especially, recursion &gt; looping can only be applied to languages with gc, preferably those with tail call optimization.<p>4. FP&#x27;s more universal virtues (immutability, pure functions, type system, no side effect) are not advertised enough compared to other virtues (recursion, hof).
评论 #21460224 未加载
0xdeadover 5 years ago
Suppose you&#x27;re in a situation where you have to resolve a bug under 15 minutes, or you&#x27;ll get fired, or maybe your company will go bankrupt. If the codebase if FP based, it is certainly going to be more difficult to quickly find and fix the bug as compared to a codebase written in a simpler language. FP is good for experimenting and playing with, but IMO it is not suitable for anything serious. Rust is also not going to get too far for the same reason I believe.
adamzapasnikover 5 years ago
Give it some time, Elixir is clearly gaining traction.<p>I think it&#x27;s mostly related to the &quot;age&quot; we live in. For the last two decades OOP has been the main thing. New problems arise, software is written differently now and a lot of development related things have been changing, so maybe&#x2F;probably there will be a shift to FP.<p>That&#x27;s my sole opinion, though.
django77over 5 years ago
Because when you start learning, you learn what is popular - in my case that was OOP principles in python and javascript. Only later on I learned about functional programming through Clojure. It&#x27;s really hard to do that mental shift, and it takes time. A lot of people don&#x27;t want to invest into learning a different paradigm