They're using objects, including arrays [1], so I think they would have been more precise to say that they're using objects and arrays as simple data structures rather than using OO features like inheritance and mutation.
This is just semantics then. If you're implementing a linked list or a tree without a class (or at the very least a function that behaves like a class), it's going to be awkward and clumsy.
Data-structures beyond what the standard lib gives you (string and array) are the main reason the addition of classes to JS was so helpful.
Absolutely. The navigation behaviors will have to be in functions though. And from an application code developer's perspective, the connection between these objects and functions may not be obvious. If only there were some way to associate behavior with state.
The whole point of the top comment is that they appreciate how this library chose not to associate behavior with state, and instead organized things as functions and data structures.
With the latter approach, the user is not limited to the bahaviors that the library author wrote. The data (not state) can be used freely. Similarly, the functions are not tied to any particular state - the data can come from anywhere, as long as it has the right shape.
Well, in principle you could have the node objects be created with an object literal in an outside builder function, and the manipulation also be done by outside functions. That's how it's done in languages without OOP. The question is how far are you willing to go to avoid doing anything that looks like OOP.
What they mean is functions and data are separate, emulating a more functional paradigm and less mutable state.
The functions are kept pure and the data is kept pure.
As opposed to an object oriented programming style in which data and functions share the same object and create bug ridden state machines thats not as easy to reason about.
I'm well aware of the pros and cons of mutability. I object (hah!) to this novel new use of the word "object". The concept is well defined by the ECMAScript spec.
Your first link's first sentence's first two words are "Immutable objects". No problem there. It doesn't conflate objects with mutability.
I have ideas but I don't think I'm getting them through. Most of the problems functional proselytizers have with objects come from inheritance and mutability. Instance methods from classes don't seem to conflict with any of the functional tenets.
As for mutability, I think it's good sometimes. Dates should have been immutable, but Maps are a good fit for mutation. Immutable maps might make sense too sometimes.
But I find it difficult to communicate about any of this when fundamental terminology is used in novel ways.
C# allows you to implement some data structures using `struct`s instead of `object`s. Probably not binary tree though.
I honestly still don't understand what you're getting at.
> a data structure in that context is clearly an ordered grouping of objects versus an unordered/loose grouping of objects.
What's an "ordered grouping"? What does "loose" mean? These are not gotchas. I'm trying my best here.
For me, if I were implementing a data structure, I would probably use objects. In fact, I'd probably use a class. I'm not trying to argue that data structures shouldn't be implemented in terms of objects or anything. My point is just that the tonal.js description is kind of nonsensical. Or at least hard to understand.
It's mostly a question of what the language considers to be an object.
There's often a stack-/heap-allocated dichotomy. Some languages consider stack-allocated structs not to be objects. They have no reference identity. Assignment has copy semantics. C# is one such language.
God i love to see this