
Pyjaco - Python to JavaScript translator. - d0ugal
https://github.com/buchuki/pyjaco
======
HerrMonnezza
This looks great and more advanced than the other Python to JavaScript
translators on the market.

Last year, I wrote a comparison of the ones I could find, but none of them
actually was in very good shape: [http://chargen.blogspot.com/2011/08/survey-
of-python-to-java...](http://chargen.blogspot.com/2011/08/survey-of-python-to-
javascript.html)

~~~
streptomycin
Since you seem to be the expert, let me try to bother you...

I'm in the very early stages of porting an app from Python to Javascript, and
I have no illusion that it's going to work out of the box from a translator
(lots of third party libraries, and switching from server side to client
side). But it would be nice if at least some of the obvious syntax could be
translated.

However, all of the several translators I've tried simply die with a message
like "this library is not supported" or "this language feature isn't
supported" and then they produce absolutely no output, which isn't any help at
all. Are there any translators that will simply skip over stuff they don't
understand while translating stuff they do understand?

Also, side note, those floating boxes on the right side of your blog make it
impossible to grab the scrollbar thingie when it is under them, as it is near
the top of the page, which is very annoying to me.

~~~
HerrMonnezza
I'm afraid I'm no expert - I just reviewed the converters because I would have
liked to use Python both on the client- and the server-side; however, I
eventually abandoned the idea.

I'm not sure how a converter could "skip over stuff it doesn't understand
while translating stuff it does understand": it may make sense to work on
"small" translation units (e.g., a function or method), but the code that
comes out of the translation of a unit should be -at least syntactically-
correct in the target language. Indeed, the more mature Python-to-C
translators (e.g., Cython) do restrict the Python that are allowed in the
source file, and refuse to compile the entire file if your code contains
unsupported syntax.

If you are willing to invest some effort into adapting a translator yourself,
(besides Pyjaco! :-)) PJS and Py2Js are both very clean and easy to
understand/patch. Although they are no longer developed, they might provide a
good starting point to build the "simple minded" translator that you would
like to have.

(Thanks for the remark on the blog layout - I just picked one of the standard
styles and did not pay much attention to the details.)

------
ch0wn
This is really cool and it's the first time I see this project. Is there still
progress going on? The last commit was 3 months ago.

Unfortunately, the error reporting of the live demo isn't very helpful at this
stage. I quickly ran into some compilation errors:

    
    
        syntax not supported (IfExp: <_ast.IfExp object at 0x7f161d834a10>)

~~~
rushabh
This fork seems to be more active: <https://github.com/chrivers/pyjaco>

~~~
neoel
Thats the one being in development, Allthough it's going a bit slower
recently. There are plans to completely overhaul the project. Since it was
built upon fork upon fork. Lots of decisions are outdated.

------
caioariede
This is an awesome and exciting project!

The unique trouble I found by myself is that list comprehension are not fully
supported.

    
    
        [x for x in (1, 2, 3, 4) if (x % 2) == 0]
    

This won't work as expected. I opened an issue about this:
<https://github.com/chrivers/pyjaco/issues/69>

------
k_bx
> print [] == []

True

ok, I love this thing already!

wow, it also knows about bound-methods <https://gist.github.com/2947907> , no
need to hack with _.bindAll().

------
lucian1900
It doesn't appear to be further along than Pyjamas.

~~~
flashingpumpkin
The issue I had with Pyjamas is that the whole tool-chain and compilation was
a bit borked and the documentation a bit vague. After playing around with it
for a day I decided it was too cumbersome so I ditched it in the end and tried
py2js which Pyjaco is forked from. Mind you that was 2 years ago so a lot
might have improved in that time but it convinced me that writing JS in Python
is (was) not really feasible.

------
apgwoz
Does this provide a sane way to deal with callbacks? Obviously, in JavaScript
you're writing callbacks all the time, and nested defs (think callbacks which
call something that requires a callback... repeat) in Python are ugly and
annoying. For example, try writing factorial in CPS style sometime in Python.

~~~
lucian1900
Twisted's Deferreds solve this problem for Python already. They might even
work unmodified with this translator, but they are a simple enough concept to
re-create if necessary.

