Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

JavaScript has functional features (first class functions for one are done well) but I think that's about it. Side effects, mutability, etc all are allowed. Compare with Haskell, Elm, or Clojure where those things are either not allowed at all or discouraged.

The recent trend of "functional JavaScript" is mostly using third party tools that emulate feature from other languages (like Immtutable.js or Ramda), but IMO the core language cannot be called a proper functional language.



It is a proper functional language, just not a "pure" functional language.


Define proper functional language, as opposed to an improper one


To be fair, everyone has their own definition of FP. For me, it just feels weird to call JS functional when it only has one "feature" of most functional languages. And at least in my college studies, the discouragement of side effects was stressed as the main feature of them.


To me, as long as functions are first class members, and higher-order functions are possible, I consider a language to be functional.

Everything else is a convenience and not a requirement for the functional paradigm.

Mind you, I do much prefer a Lisp or Scala to Javascript, but I face no trouble writing functional code in Javascript.


Ok, just be aware that by that definition, just about every language that wasn't developed in the stone ages would qualify.


Yup. The same is roughly true for being object-oriented.

The big paradigm divisions were largely a thing of the 1990s; since then languages have become increasingly multiparadigm, so that it's almost hard to find a language that isn't nowadays. I think Haskell and Golang might be just about the last remaining standard-bearers of the league of one-trick ponies.


I did not know COBOL was functional too :)

Out of curiousity, what other criteria would you apply?


Not the one you replied but I was taught through university and books that functional programming's most important feature is the discouragement of side effects. Even on Wikipedia it's said to be a style of programming that "avoids changing-state and mutable data". I'd put discouragement of side effects and immutable data up there with higher-order functions (HOFs).

You're more than welcome to have your own definition, but it's my opinion that it's too broad since HOFs exist in some form in languages like Java and Ruby and I wouldn't call them functional though like another commented said, languages are mixing paradigms nowadays (with the exception of Haskell!).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: