> Forcing people to use methods complicates things for no reason.

No, it doesn't.

All functions are in fact objects and most are methods in JavaScript, and there is nothing else.

Methods (== properties assigned function object values) are the natural way to express things in JavaScript.

Trying to pretend that this is not the case, and trying really hard to emulate (free) functions (which, to stress this point once more, do not exist in JavaScript) makes on the other hand's side everything more complicated than strictly needed.

> Why not just have state and logic separated?

That's a good idea.

This is also completely orthogonal to the question on how JavaScript is supposed to be used.

JavaScript is a hybrid langue. Part Small Talk, part Lisp.

It's common in JavaScript since inception to separate data (in the form of objects that are serializable to and from JSON) from functionality (in the form of function objects).

JavaScript was never used like Java / C++ / C#, where you glue together data and functionality into classes, and still isn't used like that (nevertheless they've got some syntax sugar called "class" at some point).

> Why force everything into some horrible combination?

Nobody does that. At least not in JavaScript.

Still that does permit to use methods.

Functions themself are objects. Using objects is the natural way for everything in JavaScript as there is nothing else than objects. Everything in JavaScript is an object. And any functionality the language provides is through methods.

Working against the basic principles of a language is a terrible idea! (In every language, btw). It complicates everything for no reason and has horrible code abominations as a consequence.

> If I want to use my method in another place I have to bring all the state along with it.

No, you don't. You need only to bring the data that you want to operate on.

The nice thing is: You get the functionality right at the same place as the data. You don't need to carry around anything besides the data that you work on.

The alternative is needing to bring the modules that carry the functionality that you want to apply to the data you need also to have around… As an example: `items.map(encode)` is nicer to write and read than `List.map items encode`.

You don't need to carry around the `List` module when the method can already be found on the prototype of the data object. Also it's more clear what's the subject and what's the object of the operation.

> I can't move my logic anywhere because it's tied to the contextual state.

That's just not true in JavaScript.

Nothing is easier then passing functions objects around, or change the values of properties that reference such function objects.

JavaScript is one of the most flexible languages out there in this regard!

You can even rewrite built-in types while you process them. (Not that I'm advocating for doing so, but it's possible).

> The style of the program itself is a weakness […]

You did not present any facts that would prove that claim.

> […] that's why people imitate another style.

No, that's not the reason.

You don't need to imitate Haskell when you want to write functional programs in a Lisp derived language… ;-)

People are obviously holding some cargo cult ceremonies when trying to write Haskell in JavaScript.

Your other opinions are based on wrong assumptions. I'm not going into that in detail, but some small remarks:

> For example we know the shortest distance between two points is a line.

In Manhattan¹? ;-)

> O(N) is definitively more "good" then O(N^2).

Maybe it's more "good"…

But it's for sure not always faster, or even more efficient, in reality.

Depending on the question and your resources (e.g. hardware) a brute force solution may be favorable against a solution with a much lower complexity on paper.

Welcome to the physical world. Where practice differs from theory.

> But the shortest distance between two points? Nobody argues about that (I hope some pedantic person doesn't bring up non-euclidean geometry because come on).

You don't need to look into non-euclidean geometry.

Actually, even there the shortest distance between two points is a "straight line". Only that the straight line may have some curvature (because of the curved space).

But you didn't even consider that "distance" is actually something² about that one can actually argue…

> You can't. The definition of bias is that the person who is biased is unaware of it.

No, that's not the definition³.

> Nobody truly knows who is blind and who is not.

Nobody truly knows anything.

What's the point?

What was actually the point of your comment, btw?

---

¹ https://en.wikipedia.org/wiki/Taxicab_geometry
² https://en.wikipedia.org/wiki/Distance
³ https://en.wikipedia.org/wiki/Bias