5 ms·
> "If functional programming is that good, why is nobody using it?" In the past 25 years, I think we've seen quite clearly that programming language popularity
by ken 6y ago
> "If functional programming is that good, why is nobody using it?"
In the past 25 years, I think we've seen quite clearly that programming language popularity depends on many different factors, and "quality of he underlying paradigm" is way down on that list -- if it's even a factor at all.
Just a quick glance at any list of most-used-languages will tell you that 50% of popularity is "is it being pushed by a big company?", and 25% is "is it the primary interface for a popular platform?"
Take away those two factors and there's maybe only about 3 languages left in the top 25 (Python, Ruby, PHP?).
Where quality shines is in being able to stay a viable niche for a long period of time. That's Scheme.
- hintymad 6y agoOh, lots of people are using functional programming. They just don't use the paradigm exclusively nor do they use a purely functional programming language. Let's see, - Supporting higher order functions in programming languages. Check. - Usual operations on higher-order functions like currying? Check. - Functional reactive programming. Check. Rx was a big thing a few years ago. - Purely functional data structures. Check. Even Java has a few reasonably popular libraries that support such data structures. - Using referential transparency whenever we can. Check. - Using CPS (continuation-passing style) in daily programming. Check. - Using recursion in production. This is not functional programming per se, but given that so many people mention recursion whenever they mention functional programming, it's worth listing recursion here. And mutual recursion and tail recursion, two of the hallmarks of entry-level functional programming techniques? Check and check. For instance, RxJava implements trampoline just to support tail-recursion, as it is necessary to implement cleanly some of RxJava's operators. - Common techniques seen in functional programming, particularly the ones that involve map, reduce, scan, left-fold and right-fold. Check. This is just the items that are on top of my mind. I'm sure I missed plenty. The gist is that people have been adopting functional programming. They just don't necessarily move to a purely functional programming language for practical reasons: platform, support, community, ecosystems, or even marketing. Programming paradigm is just one factor among many when people choose their programming languages.
- sweeneyrod 6y agoWho uses CPS in daily programming? Or do you mean using a compiler that uses it?
- hintymad 6y agoDefinitely in compiler, but also in daily JavaScript as a way to avoid deeply nested callbacks.
- Twisol 6y agoThe Visitor pattern is not much more than a CPS-style transform that lets you represent sum types in a language without them. A CPS transform for a computation of type `X` gives a computation of type `forall A. (X -> A) -> A`. That is, instead of evaluating to ("returning") a value of type `X`, you take a function that you deliver a valid of type `X` to, and return whatever it returns. CPS-transforming a sum type `X + Y` gives `forall A. (X + Y -> A) -> A`, and if you distribute over the sum you get `forall A. ((X -> A) * (Y -> A)) -> A`. The visitor is the pair of functions you pass in, `(X -> A) * (Y -> A)`, and the value decides which method to call. In either event, it returns whatever the chosen visitor method returns. (Dropping into Java syntax, this is the type of the `visit` method: `<A> A visit(Visitor<A> visitor)` -- and the Visitor is `interface Visitor<A> { A onX(X x); A onY(Y y); }`.)
- skrishnamurthi 6y agoCallback hell in JavaScript.
- emsal 6y agoI'm no expert but I think that the async-await pattern is quite similar to CPS.
- agumonkey 6y agoI cannot claim it is, but async/await, at least in ES seems to be a continuation monad without the do notation.
- hintymad 6y ago
- chubot 6y agoI think the second reason is probably more important. What languages were pushed by a big company but weren't a primary interface to a platform? The only ones I can think of are Java and C#, which are very big languages, but combined they're dwarfed by these languages, which follow the second rule: C (Unix), C++ (compatible with C), JavaScript (browser), Objective C (OS X and iOS), Kotlin (Android), bash (first program to run on the Linux kernel)
- user5994461 6y agoC# is a primary interface to the Windows platform. Java is a primary interface to the Android platform (2008). When it was originally made decades ago (1996), it was supposed to be the first language for cross platform development (compile once run anywhere), it may not be one platform per se but it is equivalent in a way.
- chubot 6y agoYeah it's true that C# gives you more access to Windows than any other language, e.g. for GUIs and such. Java became popular without Android, but Sun was very much a platform company (Solaris -- they just didn't succeed in the long term.) So basically the point is that the first reason is a special case of the second... Marketing alone does a little bit for a language, but having the platform is more important. People choose platforms and not languages. Big companies are the ones that own platforms (Linux being an exception).
- user5994461 6y agoOh right almost forgot about Solaris. ^^ I don't recall Solaris ever being any significant, so must have been a good argument that Java could run on the many Unix/Linux variants besides Solaris.
- samatman 6y agoSolaris was huge, in the US at least, in the 90s. I learned Unix and C on a SparcStation, and to this day I prefer workstations to other computers. Even if Apple is the only one still making them...
- user5994461 6y agoPHP was pushed by the LAMP platform and that was pretty much the only language to make dynamic web sites in the 1990s and onto the 2000s. (The alternative would be CGI scripts if I remember well?) Ruby only has some popularity in the silicon valley. Never heard of companies really adopting Ruby outside of there. It's open to debate whether it can qualify as one of the popular languages.
- tonyedgecombe 6y agoPHP was popular before LAMP came along, if anything LAMP came about because PHP was so common. Early on its key feature was easy hosting, there were a lot of shared host sites where using anything other than PHP or maybe a bit of Perl was difficult.
- alexhutcheson 6y agoYou could describe PHP as the primary interface to Apache. It would be straining the the metaphor a bit, but I'd say it's still a reasonable way to explain PHP's popularity. mod_php enabled shared hosting with reasonable performance. If mod_perl had been usable in an untrusted shared environment, then PHP might never have taken off the way it did.
- ken 6y agoRuby is definitely big in Seattle -- I would say bigger than Python or PHP, but that could just be my circles. In the language popularity lists I've seen, it's typically in the #11-15 slot, which is not too shabby. The "LAMP platform" is defined by the set of people using PHP/Perl, so I wouldn't call it "pushed" by that. It's not the native platform of Linux, Apache, MySQL, or the web, and there wasn't exactly any big company pushing it (Facebook famously uses it but it had already cemented its popularity by then).
- agumonkey 6y agoFunctional programming main problem was its mathy roots (too dry, too abstract, too cryptic, too culturally alien). IMO. Nobody (hyperbole) gives a damn about math, even though they'll all end up using the very same ideas in mainstream clothing. It might not be obvious to half the dev crowd but most thing they're talking about since 5 years is basically 80s academic FP. Destruct, patterns, lambdas, folds ..
- przemo_li 6y agoHey. PHP do have its great niche. Namely it's the only programming language where whole ecosystem lives and dies by the "build and burn the whole world on each request" mantra. It have significant advantages compared to other models of computation. (Granted even PHP devs often misplace "developer friendliness" of PHP, so you are not alone ;))