Hacker News new | ask | show | jobs
by Homunculiheaded 5259 days ago
"Yet functional languages never really made it to the mainstream"

JavaScript development these days is getting pretty darn close to what I would consider 'mainstream' functional programming.

Heavy use of both first class and lambda functions, and closures have been standard practices for years now. And thanks to libraries like Underscore.js partial application and the use higher order functions like map/filter/etc are also becoming very common place.

I'll absolutely agree that what we see is not 'pure' functional programming but neither is a good deal of real world Common Lisp.

Anyone who has done a lot of programming in Lisp or Haskell has probably bemoaned the fact that many people are quick to dismiss so many great and useful tools these langauges provide. But I definitely think we're starting to see a trend where the most genuinely useful features of fp are becoming mainstream.

1 comments

There is a great deal of what functional languages can do that isn't (yet) being absorbed—especially from the statically typed areas, where you can statically verify things like the length of lists using GADTs or other impressively strong compile-time guarantees—but the bits that have been absorbed are useful enough and general enough that those elements of functional languages are already conferring huge benefits to 'mainstream' programming. I suspect that, by the very nature of 'mainstream' programming, it tends to absorb some but not all features of other paradigms, leaving things that are strongly esoteric aside but still grabbing useful features. This happened before with object-oriented programming, where the Java/C++ world incorporated somewhat watered-down elements of Smalltalk. We still don't see full-blown message-passing OOP in most mainstream languages, but we see enough useful features of OOP to make a difference.

I don't know, in general, that they're the "most useful" if utility is defined as conferring the ability to write better programs more quickly, more understandably, &c. But they are "most useful" in the sense that they confer such benefits with a minimum learning curve and with little deviation from the already understood mainstream programming paradigm. For example, monads are an incredibly useful feature, but the (perceived) barriers to understanding are high enough that no mainstream language will feature them as centrally as Haskell does.

I don't mean this as a sleight against anyone, at all—merely as a description. There are a lot of useful things which are outside the purview of the mainstream, and there's no reason to expect that nonetheless useful features of fp will necessarily make it into the mainstream. (And there are certainly cases where functional programming as a whole, and not just cribbed features, is desirable and advantageous, as in Jane Street's case, so I do hope that more non-academics come to see it as a valid paradigm for certain tasks.)