4 ms·
FP is going mainstream. In the same way that mainstream OO wasn't pure OO in the manner of Smalltalk but instead hybrid languages like C++ and Java (and more re
by noelwelsh 6y ago
FP is going mainstream. In the same way that mainstream OO wasn't pure OO in the manner of Smalltalk but instead hybrid languages like C++ and Java (and more recently Python), mainstream FP isn't Haskell but languages like JS (w/ Typescript), Scala, Kotlin, Rust, Swift, and friends taking core ideas from academic FP and presenting them in way that works better for industry.
- giantDinosaur 6y agoSomething like Elm is also perfectly learnable in mainstream contexts. Haskell gets too much attention.
- noelwelsh 6y agoAgreed, Elm does seem very nice from my very limited experience. I'm not sure it's going to go mainstream, though, but we'll see!
- ilaksh 6y agoI think Ocaml is the O.G. impure functional language. I am having fun getting familiar with it again. You also didn't mention F# or ReasonML. Or are those too much like FP for your point?
- noelwelsh 6y agoYes, Reason, O'Caml, and F# are in the mix as well, though I think adoption is much lower than some of the other languages I mentioned. (I think Scheme and ML both have a claim to be O.G. strict impure FP, as both were developed at about the same time in the 1970s. O'Caml is more recent IIRC.)
- deleted 6y ago[deleted]
- suls 6y agoThe pessimist in me thinks that going mainstream means it will be less useful for screening applicants/keyword searching job postings. Sort of repeating what agile has brought us.
- noelwelsh 6y agoSure, but we'll all be into dependently typed languages then, or perhaps it will be the rebirth of logic programming, or maybe something that's not even on the radar. :-)
- skohan 6y agoI almost think the Swift/Rust approach is the right one for 99% of practical cases. In these languages I end up writing a lot of functional code, but it's important to have an escape hatch to just make the computer do what I tell it when I need to. Especially when using libraries which are not themselves functional.
- noelwelsh 6y agoAgreed. I mainly work in Scala and I really like this ability.
- IshKebab 6y agoMmm maybe, but none of those languages (afaik) have explicitly pure functions which is the keystone of functional programming.
- eru 6y agoOCaml is a functional-enough language. It ain't pure either. A language that can track purity is great, but not absolutely required. Btw, the D language does have facilities to track purity. It's not a functional language, though.
- didibus 6y agoActually it depends who you ask. There's kind of two school of thought. One says FP is about using functions with closures, higher order functions and anonymous functions as the main building blocks for modeling your program logic. This style is championed by Scheme and other Lisps. It is also slowly creeping up in all major languages. The other is about immutable data and pure functions, and modeling your program using those as your main building blocks. Either as much as possible, and sometimes even going as far as restricting yourself only to this.
- dirkt 6y agoIt's really really hard to get things right with pure functions. Haskell struggled with this for decades. You can't expect to be able to import this in some random language and just make it work. So random languages just pick what they like (lambda expressions, weaker forms of algebraic data types, sometimes the complete typeclass concept, various forms of Monads from "unnecessarily specialized because whoever picked it didn't understand it" to "properly done"0. And while having pure functions certainly forces you to get things right, you don't need to do this when copying ideas. And there are functional languages (some very old, like Lisp) that never had pure functions in the first places.
- thu2111 6y agoThose languages aren't FP though. They aren't even close. Kotlin advertises itself as 'multi-paradigm', like C++. One reply observes they don't have pure functions which is rather fundamental to most modern definitions of an FP language. But they also use imperative flow control in which statement ordering matters, their APIs are object oriented, there's no lazyness, type inference is intentionally limited. I don't think they've really borrowed many ideas from academic FP. Most such ideas were in fact explicitly rejected.