
Functional programming in JavaScript is an antipattern - doubleg
https://medium.com/@alexdixon/functional-programming-in-javascript-is-an-antipattern-58526819f21e
======
minitech
Piling a bunch of redundant libraries on top of each other, becoming confused,
and drawing the conclusion that functional programming was the problem? Okay.

~~~
chriswarbo
Yeah, I was quite confused when reading. Semantically, Javascript is basically
a crappy Scheme (first class functions, lexical closure, etc. but no macros,
tail calls, call-cc, etc.), with lightweight objects and prototypical
inheritance.

The functional/OO split in JS is basically whether to focus on the Scheme part
and only use objects as hash tables, or whether to focus on the objects,
methods and inheritance and avoid Schemey functions.

You don't need any libraries to do either. If it makes life easier to include
a library (whether functional or OO or whatever) then include it; if it
doesn't, then don't.

~~~
globuous
I thought tail calls were in the ES6 spec, just not implemented by all
browsers or something. Node has a flag to use tail call optimization I
believe.

EDIT: ES2015 specs [1]: "Some of its major enhancements include modules, class
declarations, lexical block scoping, iterators and generators, promises for
asynchronous programming, destructuring patterns, and _proper tail calls_."
(emphasis mine)

[1] [http://www.ecma-international.org/ecma-262/6.0/](http://www.ecma-
international.org/ecma-262/6.0/) (introduction)

------
KeyboardFire
The article seems hopelessly tautological. One of the arguments for
Clojurescript is that it "is a functional programming language," with the
reasoning that this makes functional programming easier. The author then goes
on to answer - and I quote - "Why isn’t it popular?" with "Not popular
enough." I am thoroughly enlightened.

------
vorotato
Functional programming in javascript is an antipattern instead use clojure.
LOL if I were going to use a ??? -> js, I would at least use fable/reason. I
have tried to get into lisp several times and then tried once to get into
OCaml/F# and it was effortless.

------
AstralStorm
> Felt like the language was fighting me every step of the way

Welcome to JS programming.

~~~
baldfat
That was my feeling exactly back in the 90s. I feel that things have gotten a
million times better, but I still have a bad taste in my mouth.

~~~
nallerooth
Agreed. I was recently reminded about the broken scoping rules of old versions
of IE. Also, the dev tools available today are insane compared to the ones we
had in 2010 (and the ones we kind of didn't have in 2000).

~~~
maze-le
Oh my, webdevelopment in the early 2000s. Back in the day we debugged with
'alert()' that was quite the experience... Compared to that the tools today
are almost another world.

