Object model reformation?
brendan at mozilla.com
Wed Dec 26 20:53:04 PST 2012
Axel Rauschmayer wrote:
> Is the object model reformation (OMR) still on the table for ES6?
It never was -- it missed the cutoff by over five months.
> The reason I’m asking is that I recently remembered a technique from
> the Java collections API: you could wrap any collection in a read-only
> “view”. That made it possible to have aliases to internal data
> structures without worrying about them being modified. The OMR would
> allow one to implement such wrappers for arrays.
Java, schmava :-P.
I have a theory: hashes and lookup tables (arrays or vectors) have
displaced most other data structures because most of the time, for most
programs (horrible generalizations I know), you don't need ordered
entries, or other properties that might motivate a balanced tree; or
priority queue operations; or similar interesting data structures we all
studied in school and used earlier in our careers.
It's good to have these tools in the belt, and great to teach them, know
their asymptotic complexity, etc.
But they just are not that often needed.
So if JS grows a big collections API with some nominal-ish
interface-like faceting, I'll be surprised -- and disappointed. I don't
think we need it. This isn't that language. Those minority-use-case
data structures are usually one-offs. These aren't the hash-and-array
droids you're looking for.
Iteration protocols for collections? Sure, but don't fit all pegs into
the one octagonal hole. Lists want value iteration, dicts want [key, value].
Abstraction is two-edged, especially when piled up to handle
"collections" that might need to scale off of data cache memory. That's
another point: if you really want to scale in the modern world, you want
functional data structures, maps and folds, immutability. Abstracting at
that level is cool and people do it even in the small, in the dcache.
Doesn't work the other way, especially with mutation and eager effects.
Anyone disagree strongly?
More information about the es-discuss