3 ms·
Well, the author of the article called functional programming (FP) a "bandwagon" and cited how mainstream languages are incorporating FP features. This suggests
by gkuan 14y ago
Well, the author of the article called functional programming (FP) a "bandwagon" and cited how mainstream languages are incorporating FP features. This suggests to me that at least according to this author, FP is already "catching on" and probably more so than he prefers. Of course from the FP community's perspective, it still looks like an uphill battle.
About the 'scary' code examples, one is perfectly reasonable and the other is taken quite out of context. I think it is the case that one can always produce unreadable code regardless of language.
Proponents who are behind particular language and maybe even a specific compiler are promoting exactly those. Of course, FP-style can be used in any language that supports first-class functions, proper closures, and tail call optimization. There are plenty examples of mainstream languages with the first of those. The remainder are not as widespread. However, the advantages of many modern FP languages go well beyond that of the key features pioneered by LISP and the Landin's unimplemented language ISWIM from the 1960s. When people tout Haskell, they are probably not doing so just for the first-class functions. They probably are enamored by the sophisticated static type system, type classes, and many, many more important features which cannot be easily emulated in a mainstream language because they require language and compiler support. Another example: Because functional style often entails recursion, the lack of proper tail call optimization is a huge barrier.
The primary advantage of FP that the author of the article concedes is concurrency benefits from pure FP. Purity (statelessness) requires considerable language support. In most mainstream languages, state is just too pervasive to make any substantial purity guarantees for concurrency. FWIW, I think the jury is still out on the concurrency question in FP.
The fact is that many mainstream languages are becoming quite multi-paradigm. I think many in the FP community view that development positively. In the very least, ubiquity of some functional features will make it easier for people to transition to full-blown modern FP languages. However, having mainstream languages adopt just one or two features pioneered decades ago isn't entirely satisfactory. There is so much more in modern FP languages, but that is where the community splinters dramatically.
That said, obviously JavaScript is one of the most successful programming languages in history (with no slight intended towards any other mainstream language). The other mainstream languages have also achieved great success through many years of hard work. It is great that people are rediscovering FP there where appropriate. It should be interesting to see how these languages ultimately evolve.