Hi there,

to continue the discussion about AS->JS cross compilation, I'd like to add
another option which, I think, could
lead to better acceptance of Apache Flex in the HTML5/JS sphere.

The title of this message says exactly what I mean. Right now we're talking
about cross compiling the Flex SDK
itself, along with all of its components.
Which is great, I am not against this at all. But, it would definitely also
make sense for us to be able integrate with
the enormous wealth of JS components already out there. (Yes, this would
only make sense if you only plan to
cross compile your project to JS, not also to SWF, but I believe this is
could be a very common use-case in the future).

The way that TypeScript and Randori/SharpKit integrate with JS is by
declaring some sort of interface which has exactly
the same signatures of their JS counterparts. I think this will quite
probably make the most sense for Apache Flex as well.
And we could just use regular actionscript interfaces to do it. Probably
with a small bit of annotation, so, for example,
a JQuery AS3 integration could look like this:

[NativeAPI(path="/js/jquery-1.4.js")]
public interface IJQuery {
  function Each():IJQuery;
  function getJSON():IJQuery;
  //etc, etc, etc
}

What we then would need is some sort of compiler support that recognizes
the annotation and automatically includes the
specified .js file. (instead of trying to cross compile the interface)
The same could be done for components, for instance, if we could figure out
an elegant way of integrating with the Sencha/ExtJS
components we could probably gain the attention of quite a few folks.

It would probably make sense to add some optional "glue" code as well. By
which I mean some code that might translate
API conventions between Flex and the referenced JS components. For example,
a property such as 'dataProvider' is common
in Flex, but quite probably not in a lot of JS component libraries.

If we want to gain some traction in the HTML world I strongly believe we
need to make friends out there :) And what better way of
making friends than through integrating with them :)

Obviously the code example I'm giving is very simple, and the exact
implementation will require some further discussion. But I believe
the implementation of this shouldn't be too elaborate and therefore could
act as a bit of low-hanging fruit which could give the whole
AS->JS situation another turbo-boost.

Please feel free to call me a fool and tell me my idea is crap, because I
might just be talking out of my ass as usual. :)

-- 
regards,
Roland

-- 
Roland Zwaga
Senior Consultant | Stack & Heap BVBA

+32 (0)486 16 12 62 | rol...@stackandheap.com | http://www.stackandheap.com

http://zwaga.blogspot.com
http://www.springactionscript.org
http://www.as3commons.org

Reply via email to