await, typescript and spoon branches

65 views
Skip to first unread message

Bruno Jouhier

unread,
Nov 21, 2012, 4:43:22 PM11/21/12
to stream...@googlegroups.com
Hi all,

I've created three experimental branches recently:

* The await branch is an attempt to support the await / deferred proposal which has been submitted to EcmaScript (http://wiki.ecmascript.org/doku.php?id=strawman:deferred_functions). What I did is just a quick proof of concept but it shows that 1) there is a very good alignment between the await / deferred proposal and streamline, and 2) the full proposal can be easily implemented in streamline. To see what the result looks like, take a peek at https://github.com/Sage/streamlinejs/blob/await/examples/diskUsage/diskUsageAwait._js

* The typescript branch is an attempt to use streamline with TypeScript. I was quite successful with it and I managed to get a working version of the full tutorial in TypeScript (https://github.com/Sage/streamlinejs/blob/typescript/tutorial/tuto8-all.ts). After that I started to convert some of our project's modules to TypeScript; to get a better feel for what it would bring, but I hit some bugs in the TypeScript compiler. So I let it rest a bit.

* The spoon branch is an attempt to support Fedor Indutny's spoon transform (https://github.com/indutny/spoon) as an alternative to streamline's callback transform. I managed to hook it up but it only passes a subset of my unit tests because the spoon transform is incomplete (see https://github.com/Sage/streamlinejs/blob/spoon/test/common/spoon/eval-test._js - the tests that don't pass are currently commented out).

I would like to put more work into the await branch. I think that we need a clean async language extension to JS in the future and I would rather join a proposal which has already been discussed in the EcmaScript circles than push an alternate proposal which will likely be perceived as a marginal, personal initiative.

This does not mean that I would drop the _ syntax (our team has too much investment in it). Instead I would support both syntaxes together, so that you can choose and so that you can seamlessly migrate modules from _ to await if you choose to.

Regarding typescript, I would give it a slightly lower priority. The await syntax is likely to have more appeal than the _ syntax in the typescript community, because the keyword already exists in C#. So I'd rather get back to it after solidifying the await implementation.

I don't intend to put any work into the spoon branch at the stage. I'm waiting for Fedor to complete his implementation.

I had also added a timeout/cancellation API to futures in the master branch (see https://github.com/Sage/streamlinejs/issues/106). This API has not landed in NPM yet (NPM is on the v0.4 branch). I'd like to pursue this but I may choose to develop these features around the deferred API rather than around the future API.

I wanted to share this with you. I'm particularly interested by your thought on the idea to bridge the gap with the await/deferred proposal.

Cheers to all,

Bruno

Clayton Grassick

unread,
Apr 20, 2013, 4:23:57 PM4/20/13
to stream...@googlegroups.com

* The await branch is an attempt to support the await / deferred proposal which has been submitted to EcmaScript (http://wiki.ecmascript.org/doku.php?id=strawman:deferred_functions). What I did is just a quick proof of concept but it shows that 1) there is a very good alignment between the await / deferred proposal and streamline, and 2) the full proposal can be easily implemented in streamline. To see what the result looks like, take a peek at https://github.com/Sage/streamlinejs/blob/await/examples/diskUsage/diskUsageAwait._js

This link seems to be broken... where can I find the example?

I absolutely love streamline... Attempting to hand-write complex business login with callbacks is painful and massively error-prone. Thanks for creating this great tool... I've been evangelizing it.

Any thoughts of adding source mapping so we would see the pre-streamlined javascript in Chrome?

Cheers,

Clayton

Bruno Jouhier

unread,
Apr 20, 2013, 5:33:10 PM4/20/13
to stream...@googlegroups.com
Hi Clayton,

Thanks.

The current await example link is https://github.com/Sage/streamlinejs/blob/await/examples/diskUsage/diskUsageAwait5._js

I'm very busy with my project right now. So I haven't invested more time on the await feature and I haven't investigated source maps either. I just looked at the specs. Difficult to say how difficult this would be but the fact that the transform manipulates AST nodes that have mappings to the original source should help. The lib/callbacks/format.js already uses this information to format the code so that the lines remain in sync with the source (which is unfortunately not always possible because of hoisting).

I may implement it if I get some spare time but I won't promise anything because I'm really overbooked. If someone wants to contribute I'll welcome a pull request.

Bruno

Bruno Jouhier

unread,
Apr 20, 2013, 5:40:14 PM4/20/13
to stream...@googlegroups.com
Just added an issue for source maps: https://github.com/Sage/streamlinejs/issues/145
Reply all
Reply to author
Forward
0 new messages