Thursday, April 28, 2011

Plan for preliminary work

My project was accepted, and therefore its time to do some preliminary work before official coding time starts.

First and foremost project goal is to make PyJS to be able to translate and run itself.
Basically, this means that it should be possible to do this:
#> $PyJSRepo/pyv8/pyv8run.py --strict translator --strict -o /tmp/translator.js $PyJSRepo/pyjs/src/pyjs/translator.py
And it should:
1. Translate translator.py and all its dependencies
2. Load result in pyv8
3. Use loaded in pyv8 translated Translator to translate translator.py again
4. Result of (3) has to be completely identical to result of (1)
This goal has to be achieved for mid-term evaluation (July 12). 

In order to achieve this goal we have to make pyjamas support all 180 modules on which translator.py depends.

At this moment, most of them fail with some kind of error either during translation or execution. These errors are caused by one of 3 issues:
1) Lack of support for specific syntax, like a[::] (ternary slice, bugs #364, #434, #577, #582)
2) Lack of support of specific features in pyjslib, like type(lambda x:x).
3) Restrictions of environment, like weakref.py. Such modules cannot be supported directly, and we have to provide replacement with compatible API or remove dependency on it from other modules.

First and second issues could be resolved via either fixing pyjs/pyjslib or providing replacement module, which does not use this particular feature.

To help myself track progress and properly prioritize work, I'll make simple pyjamas web-app, which will show list of all modules Translator uses, and show results of translation/evaluation of each of them.

Therefore plan for next week is as follows:

1) Find/make tool to produce dependency graphs for translate.py, compiler.py and other base modules we would need.
2) Add simple compile/eval test suite for all modules from (1)
3) Make pyjamas-GAE web app to show results from (2)
4) Fix import path issues in pyv8* tools
5) Fix issues in master for pyv8run

This will be useful for tracking stdlib support as well and providing good overview of current pyjs compatibility with cpython.

1 comment:

  1. Watcing with interest! Best wishes.

    As someone without deep technical understanding it would be interesting to know more about the following:

    How do other (skulpt, emscriptem, ?) in browser python interpreters compare? Would be useful to add this to your intro post.

    Would it make sense to add to the plan a server side component that could handle any modules not in the client? Or is this what step 3 is?
    Sort of a DWR (http://en.wikipedia.org/wiki/DWR_%28Java%29) for python?

    ReplyDelete