Comment on Show HN: a compiler from Python syntax to JavaScript syntax (like CoffeeScript)parentComments−endianOP15yExactly. It's purely syntax to syntax.Thanks for the confusion -- I've made the first paragraphs more clear about PJ's scope.Title changed: s/compiler/syntax cross-compiler/ EDIT: title changed again−scott_s15yThat's not a term I've ever heard, and "cross compiler" tends to imply something else: http://en.wikipedia.org/wiki/Cross_compilerI would call what you have done a source-to-source compiler: it translates from one target high-level language to another. http://en.wikipedia.org/wiki/Source-to-source_compiler−s3graham15yI guess defining what you consider syntax features vs. Python language/runtime would be appropriate for the docs.ie. 2 * * 1024? print object.__mro__? slice objects? __call__? etc.−endianOP15yHere's the decision procedure:If there's no collateral damage and the JS is clear (e.g. 28 --> Math.pow(2, 8)): do it.If there's no proper way to express the JS in Python (e.g. instanceof and typeof keywords): do itIf it's really important (only "print" and "self"): do itElse: DON'TThese few special cases that mess with your code are all mentioned in a section on the the main page.And you can easily remove them from the transformations if you want.
Comments
Exactly. It's purely syntax to syntax.
Thanks for the confusion -- I've made the first paragraphs more clear about PJ's scope.
Title changed: s/compiler/syntax cross-compiler/ EDIT: title changed again
That's not a term I've ever heard, and "cross compiler" tends to imply something else: http://en.wikipedia.org/wiki/Cross_compiler
I would call what you have done a source-to-source compiler: it translates from one target high-level language to another. http://en.wikipedia.org/wiki/Source-to-source_compiler
I guess defining what you consider syntax features vs. Python language/runtime would be appropriate for the docs.
ie. 2 * * 1024? print object.__mro__? slice objects? __call__? etc.
Here's the decision procedure:
If there's no collateral damage and the JS is clear (e.g. 28 --> Math.pow(2, 8)): do it.
If there's no proper way to express the JS in Python (e.g. instanceof and typeof keywords): do it
If it's really important (only "print" and "self"): do it
Else: DON'T
These few special cases that mess with your code are all mentioned in a section on the the main page.
And you can easily remove them from the transformations if you want.