Eric Elliott
Jul 24, 2017 · 1 min read

You’ve already made one concession where you say methods are useful. I’ve found methods very useful for collections, streams, trees, graphs, single values, Either monads, Tasks (representing an impure computation with pure logic), etc… any kind of functor, really (a concept introduced to programming via FP).

How do you handle long-lived processes which must maintain state? Things like network connections which enable live updates from remote systems? I do it with objects that listen for events and feed them into the system with something like redux-saga.

The Redux store is also an object with methods.

Sagas use generator functions which produce an iterator — an object with a `next()` method. Of course, that could have been implemented in functions with a pull stream, but the iterator is what got incorporated into the JavaScript spec.

The fact is, objects and methods are tightly interwoven into the JS spec and ecosystem. We must be able to understand them and get along with them, or we won’t get very far.

Refusing to deal with them on ideological grounds tells me you might be better off in Haskell.

Eric Elliott

Written by

Make some magic. #JavaScript