A Challenge Problem for Promise Designers (was: Re: Futures)
claus.reinke at talk21.com
Fri Apr 26 07:11:33 PDT 2013
> Can you point to any code in wide use that makes use of this
> "thenables = monads" idea you seem to be implicitly assuming?
> Perhaps some of this "generic thenable library code"? I have never
> seen such code, whereas the use of "thenable" to mean "object with
> a then method, which we will try to treat as a promise" as in
> Promises/A+ seems widely deployed throughout libraries that are
> used by thousands of people judging by GitHub stars alone.
> Thus I would say it's not promise libraries that are "harming the
> thenable operations," but perhaps some minority libraries who
> have misinterpreted what it means to be a thenable.
Instead of rehashing the arguments from the various issue tracker
threads, where examples have been presented even in the half (or
less) I've read so far, let me try a different track: consider the case
of Roman vs Arabic numerals.
As a user of Roman numerals, you might point to centuries of real
world use in the great Roman empire, complain that Arabic numerals
don't have explicit numbers for things like IX or LM etc, ask why anyone
would need an explicit symbol representing nothing at all, or ask for
examples of real world use of Arabic numerals in Roman markets,
or say that Roman numerals don't need to follow the same rules
as Arabic numerals, and that instead users of Arabic numerals have
misinterpreted what it means to work with numbers.
All those arguments are beside the point, though. The point is that
Arabic numerals (with 0) are slightly better than Roman numerals
at representing the structure behind the things they represent, making
it slightly easier to work with those things. And that is why Arabic
numerals have won and Roman numerals are obsolete, after centuries
of real-world use in a great empire.
Thenables in the JS-monadic sense represent common structure
behind a variety of data types and computations, including Promises,
they represent that structure well, and they give JS an equivalent to
vastly successful computational structures in other languages.
And that isn't because I or someone famous says so, but because lots
of people have worked hard for lots of years to figure out what those
common structures are and how they might be represented in
programming languages, refining the ideas against practice until
we have reached a state where the only question is how and when
to translate those ideas to another language, in this case JS.
Promises differ from other thenables, but there is no reason to
burden the common interface with those differences.
More information about the es-discuss