Giter Club home page Giter Club logo

pythonjs's Issues

implement a modern framework

According to this article http://sporto.github.io/blog/2013/04/12/comparison-angular-backbone-can-ember/ a modern framework should contain:

  • Observables : need data descriptor support
  • Routing: Pushing changes to the browser url hash and listening for changes to act accordingly, integrate this in the in Machinima class
  • View bindings: Using observable objects in views, having the views automatically refresh when the observable object change.
  • Two way bindings: Having the view push changes to the observable object automatically, for example a form input.
  • Partial views: Views that include other views.

- Filtered list views: Having views that display objects filtered by a certain criteria.

Benchmarks?

This looks great! I actually have abandoned my tornado code for Node.js/Express. Are there any benchmarks? How does this stack up against the real Tornado?

fully implement exceptions

right now there is not filtering that is possible only the following syntax is supported

try:
     raise SomethingIfYouWant
except:
    if __exception__ == SomethingIfYouWant:
        print 'ouhou'

Improve tests and implement test suite

Create more tests and implement a run_tests function for complete check:

  • check pythonjs output in python
  • check pythonjs output is working as expected execute with node
  • check pythonscript output in python
  • check pythonscript output is working as expected execute with node

New Feature Suggestions

PythonJS very promising project.

Couple of feature suggestions after playing around for a while:

  1. Typed parameters support for functions/methods same as Python 3. We can leverage https://github.com/borisyankov/DefinitelyTyped here.
  2. LuaJIT adaptor: I believe the python dialect is the top reason for programmers love besides standard library. Having multiple backends for a python dialect meta compiler will be of great value. Lua has a great backend for systems, games & web, LuaJIT. I believe supporting Lua adaptor besides JS and Dart will make PythonJS a top-tier project.

PyPI version (0.8.3) is outdated

Trying to compile the simple code 10**2 gives a SyntaxError with PythonJS 0.8.3 (installed with pip), but I noticed it works with the latest version on GitHub.

Might be a good idea to update the version on PyPi.

pythonscript-0.7.3 doesn't work

I have changed setup.py (line 15)
pythonscript=pythonscript.main:command
to
pythonscript=pythonscript.pythonscript:command

and it works.

This project is awesome !, i like it.

'in' python operator translations

The following Python code

with javascript:
     print 'o' in 'kok'

Is translated as:

console.log(Object.hasOwnProperty.call("kok", "__contains__")
            && "kok"["__contains__"]("o")
            || Object.hasOwnProperty.call("kok", "o"));

The previous code does not work, but this trivial code works as expected:

console.log("kok".__contains__('o'))

test_if_true

getattr is broken by a bug in test_if_true, there is the patch :

--- a/runtime/builtins.py
+++ b/runtime/builtins.py
@@ -39,6 +39,8 @@ with javascript:
                        return True

        def __test_if_true__( ob ):
+               if JS("! ob"):
+                       return False
                if instanceof(ob, Array):
                        return ob.length != 0
                elif isinstance(ob, dict):

You may add a regression test regtests/class/attr.py:

"""instance attributes"""

class A:
    g = 6
    def __init__(self):
        self.b = 5

def main():
    a = A()

    TestError(a.b == 5)
    TestWarning(a.g == 6)
    try:
        x = a.c
        TestWarning(not 'No exception: on undefined attribute')
    except AttributeError:
        pass

    TestError(getattr(a, 'b') == 5)
    TestWarning(getattr(a, 'g') == 6)
    # TestWarning(getattr(a, 'c', 42) == 42)
    try:
        getattr(a, 'c')
        TestWarning(not 'No exception: getattr on undefined attribute')
    except AttributeError:
        pass

I did not submit a tree because I can no more recreate the same pythonjs.js file than original one, there is tons of:

-  __sig__ = {"kwargs": {"property": false}, "args": __create_array__("ob", "attr", "property")};
+  __sig__ = { kwargs:{"property": false},args:__create_array__("ob", "attr", "property") };

Improve PythonJS

  • add multiple targets to function calls
  • add multiple return values

«from stuff import thing»

How this should be handled since it's compiled it should maybe generate a dependency file or concate everything ?

improve metaclass support

metaclass support is clunky right now, one must repeat in each class which behavior must overriden define the __metaclass__ attribute. Also it doesn't support class metaclasses

class __init__ generated code is strange

if we compile the following code:

class A:
def init (self, _args, *_kwargs):
pass

class B( A ):
def init (self, _args, *_kwargs):
pass

we will get this:

var A, A_attrs, __A_parents;
__A_attrs = {};
__A_parents = create_array();
var __A___init
= function(args, kwargs) {
var signature, arguments;
signature = {"kwargs": {}, "args": create_array("self"), "vararg": "args", "varkwarg": "kwargs"};
arguments = get_arguments(signature, args, kwargs);
var self = arguments['self'];

var args arguments['args']; <----------------- this line seems redundant

args = get_attribute(list, "call")(create_array(args));
var kwargs = arguments["kwargs"];
kwargs = get_attribute(dict, "call")(create_array(kwargs));

}

A_attrs.__init = A___init;
A = create_class("A", A_parents, __A_attrs);
var B, __B_attrs, __B_parents;
__B_attrs = {};
__B_parents = create_array();
__B_parents.push(A);
var __B___init
= function(args, kwargs) {
var signature, arguments;
signature = {"kwargs": {}, "args": create_array("self"), "vararg": "args", "varkwarg": "kwargs"};
arguments = get_arguments(signature, args, kwargs);
var self = arguments['self'];

var args arguments['args']; <----------------- this line seems redundant

args = get_attribute(list, "call")(create_array(args));
var kwargs = arguments["kwargs"];
kwargs = get_attribute(dict, "call")(create_array(kwargs));

}

B_attrs.__init = B___init;
B = create_class("B", __B_parents, __B_attrs);

AttributeError: 'Slice' object has no attribute 'value'

...
  File "...lib\ast.py", line 241, in visit
    return visitor(node)
  File "...PythonJS\pythonjs\pythonjs.py", line 138, in visit_Subscript
    return '%s[%s]' % (self.visit(node.value), self.visit(node.slice.value))
AttributeError: 'Slice' object has no attribute 'value'

'get' method for 'dict' in Javascript mode

When translated in 'javascript' mode, 'dict' is translated as a Javascript 'Object'.

Is it possible to add some builtins methods to the Javascript 'Object' in order to better emulate a Python 'dict'?

I use for example:

    @Object.prototype.get
    def func(key, default_value=None):
        if key in this:
            return this[key]
        return default_value

Transitional exception handler in input reader to report file and line

Hi,

I am failing to get my Python module translated. PythonJS gives stack traces and I am unable to quickly determine the input lines that are causing this harm.

Is it possible to add a high level exceptional handler that is rethrows exception if it occurs, but also reports about lines in input file at the time this occurred? I think it will be a valuable property for every input processor.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.