Python to JavaScript Compiler? Anyone written such a beast?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kenneth.m.mcdonald@sbcglobal.net

    Python to JavaScript Compiler? Anyone written such a beast?

    Of course, I'm not talking about something that would transform
    any Python code into semantically JavaScript code, but simply
    something that would analyze a "restricted " Python source file,
    and spit out equivalent JavaScript. The big advantage (as far
    as I'm concerned) is that one could make use of some of the
    syntactic shortcuts that JavaScript doesn't offer, that the Python
    syntax checker generally does a better job than the JS one, and
    (perhaps most importantly) this could be configured to put in 'instrumentatio n',
    such as checks to make sure than an attempt to access an undefined
    attribute actually throws an error.

    Color me curious,
    Ken

  • Steve Holden

    #2
    Re: Python to JavaScript Compiler? Anyone written such a beast?

    kenneth.m.mcdon ald@sbcglobal.n et wrote:
    Of course, I'm not talking about something that would transform
    any Python code into semantically JavaScript code, but simply
    something that would analyze a "restricted " Python source file,
    and spit out equivalent JavaScript. The big advantage (as far
    as I'm concerned) is that one could make use of some of the
    syntactic shortcuts that JavaScript doesn't offer, that the Python
    syntax checker generally does a better job than the JS one, and
    (perhaps most importantly) this could be configured to put in 'instrumentatio n',
    such as checks to make sure than an attempt to access an undefined
    attribute actually throws an error.
    >
    Color me curious,
    Ken
    >
    Take a look at the PyPy project, which has produced a JavaScript
    back-end (thugh I suspect it's more of a curiosity than a practical
    solution). It might suit your needs, though, and they've had a Summer of
    Code project going on it.



    and specifically



    regards
    Steve
    --
    Steve Holden +44 150 684 7255 +1 800 494 3119
    Holden Web LLC/Ltd http://www.holdenweb.com
    Skype: holdenweb http://holdenweb.blogspot.com
    Recent Ramblings http://del.icio.us/steve.holden

    Comment

    • Ben Finney

      #3
      Re: Python to JavaScript Compiler? Anyone written such a beast?

      kenneth.m.mcdon ald@sbcglobal.n et writes:
      Of course, I'm not talking about something that would transform any
      Python code into semantically JavaScript code, but simply something
      that would analyze a "restricted " Python source file, and spit out
      equivalent JavaScript.
      You may be looking for Pyjamas:

      <URL:http://pyjamas.pyworks .org/>

      --
      \ Hercules Grytpype-Thynne: "Well, Neddie, I'm going to be |
      `\ frank." Ned Seagoon: "Right, I'll be Tom." Count Moriarty: |
      _o__) "I'll be Gladys." *slap* -- The Goon Show, _World War I_ |
      Ben Finney

      Comment

      • fijal

        #4
        Re: Python to JavaScript Compiler? Anyone written such a beast?


        Helpfull link to JS specific docs in pypy:



        Comment

        Working...