And in all of the examples on the github page. Why not just get rid of the λ variable and use `contra` directly? I guarantee this will confuse/frustrate people otherwise.
This looks pretty cool, but it seems to me it has hardly more than a sprinkling of "functional taste". Promises are much more functional in the modern sense of preserving composability outside the abstraction by creating values that represent asynchronous computations, which can be composed flexibly with a then method.
I think this library looks great. It seems to do just enough, and browser compatibility with a small filesize is wonderful.
I almost can't believe that all of the other (current) comments are complaining about the use of the λ character. Unicode is hardly a new concept, and it is certainly not "hostile" (hyperbole much?).
In fact, as modern languages like Julia become popular, I think we will see increased use of unicode characters in coding. Julia is very unicode friendly, which aids scientists and mathematicians when translating formulas to code. For example, it supports the "element of" operator ('∈') for testing if an item is in a set. These unicode characters actually _improve_ readability in many contexts, while being less convenient to type if you're only accustomed to ASCII.
But there are many different options available in Emacs for inserting exotic characters, as listed here, for example: http://stackoverflow.com/questions/10192341/how-to-enter-gre... - I didn't have any need for them, as I only need lambda character when I'm programming in Racket (which understands this character natively, which is very nice!), but both abbrevs and input method ways of doing this look legit.
Promises are a superior abstraction, easier to reason about, provides consistent error handling. Sadly (in my opinion), this is an `async`-like library.
What? Why? I disagree on all of those points. Promises are inconsistent[0], slow[1], and I find them a hassle compared to async. The Node.js core and community convention is to use callbacks and callback-embracing tooling for a good reason.
Performance: I cannot honestly remember a single case in my entire Node.js career where promise execution time was a performance bottleneck.
Inconsistency: If you're consistent in your promise library usage, then promises will always behave the same way. Wrap libraries as necessary.
Promises are incredibly easy to reason about - the code reads very synchronously. Until we have native concurrency primitives available at the language level, I'll settle for ".then". It's pretty much how I'd read it in my head anyways.
If promises are a hassle, you're probably not using them correctly.
Promises that implement Promises A+ are consistent. The fact that jQuery's implementation is broken has no relation to promises whatsoever (nobody seriously calls them promises anymore).
But I was talking about a different kind of consistency: consistency in your code. Errors not being swallowed, the same representation for all async values.
The performance post you linked to is almost a year old and is quite outdated. Since it was posted, Bluebird[1] was written and leveled up the game:
30 comments
[ 1.9 ms ] story [ 51.8 ms ] threadI don't understand this. Do you mean "so you don't need to use the λ character"?
https://github.com/kolodny/wttt
https://github.com/bevacqua/contra?1#comparison-with-async
I almost can't believe that all of the other (current) comments are complaining about the use of the λ character. Unicode is hardly a new concept, and it is certainly not "hostile" (hyperbole much?).
In fact, as modern languages like Julia become popular, I think we will see increased use of unicode characters in coding. Julia is very unicode friendly, which aids scientists and mathematicians when translating formulas to code. For example, it supports the "element of" operator ('∈') for testing if an item is in a set. These unicode characters actually _improve_ readability in many contexts, while being less convenient to type if you're only accustomed to ASCII.
e.g. in Vim: Ctrl-V, U, 3bb <ret>
Which is OK for this one library... but if I had delta and epsilon libraries too I could see it getting to be a pain.
In terms of typing efficiency, 6 keystrokes, it's about the same as just typing "contra" except harder to remember.
[0] http://lostechies.com/derickbailey/2013/09/20/consistency-pr...
[1] http://thanpol.as/javascript/promises-a-performance-hits-you...
Inconsistency: If you're consistent in your promise library usage, then promises will always behave the same way. Wrap libraries as necessary.
Promises are incredibly easy to reason about - the code reads very synchronously. Until we have native concurrency primitives available at the language level, I'll settle for ".then". It's pretty much how I'd read it in my head anyways.
If promises are a hassle, you're probably not using them correctly.
Promises that implement Promises A+ are consistent. The fact that jQuery's implementation is broken has no relation to promises whatsoever (nobody seriously calls them promises anymore).
But I was talking about a different kind of consistency: consistency in your code. Errors not being swallowed, the same representation for all async values.
The performance post you linked to is almost a year old and is quite outdated. Since it was posted, Bluebird[1] was written and leveled up the game:
[1]: https://github.com/petkaantonov/bluebird/blob/master/benchma...https://en.wikipedia.org/wiki/Flow_control_(data) https://en.wikipedia.org/wiki/Control_flow
I expected a "please stop sending until I am ready to receive again" mechanism.