8
C34A
3y

JavaScript is a functional language.

It's probably closer to ocaml than it is to java. Why the fuck does no one talk about this? I would have learned it sooner.

Comments
  • 0
    maybe this is acknowledged more in JavaScript centered communities? I've never heard people talk about functional programming in js, but I am still relatively new to the language.
  • 3
    They squeezed OOP in and that is why the functional language part is forgotten by most. OOP is also the shitty part of JS and the reason most hate it.
  • 1
    Well it's been touted loud and clear for a long time and I'm not in the JS world. Closures for example where popularizef back when we still had Yahoo. As for OOP it's classes and stuff is all very recent. The prototype and function first approach have been there for ages of course the procedural and state too but OOP was not obvious to me.
  • 3
    It's not. It's a general language.
  • 0
    Well I mean the language works right. Don't most languages fit that definition of working, ie functional?
  • 0
    It is a lisp without the parenthesis. It's been a functional language since it's inception
  • 3
    Yeah it's really not a functional language at all..

    Sum types, immutability, match statements, control flow as expressions? But it got closures though
  • 3
    @galileopy LISP without the parentheses is just a longer way of saying “not LISP”
  • 2
    It does have support for some functional paradigms, like callbacks, closures, and higher-order functions, but the lack of strong typing, pattern matching, and other functional mainstays means it isn’t exactly a functional programming language. Try rescript for actual JavaScript functional programming
  • 1
    @12bitfloat yep, everyone and their dog have closures nowadays 😄
  • 2
    Just because it has functions as the main building blocks, doesn’t make it a functional language.
    It’s not even a proper language. It’s just a script language. But no one remembers that anymore.
  • 1
    JavaScript utilizes multiple paradigms. How you mix them is up to you.
  • 3
    @vintprox
    To quote some weirr xkcd-like comic:

    "JS is like a one man band; It does everything, but that doesnt mean it should."
  • 1
    @Ranchonyx couldn't say better myself
  • 0
    @LLAMS oh, don't be rude to JS, she is listening. No parens, no macros, eval/apply. I get it it is not a fully grown lisp, but the rest is there, even the continuation passing style is there. And that's a big thing.
Add Comment