Live data from Hacker News

PyPy.js: Python in the web browser

pypyjs.org

41–50 of 129 posts

Re: PyPy.js: Python in the web browser

#42
post #29

Earlier quoted context omitted.

Shouldn't be too surprising, given how PyPy is generally faster than CPython by about x7-8 factor: http://speed.pypy.org/ I'd expect a much larger difference in tasks that are pure Python (loading a CSV is done primarily through the csv module, i.e. all the hot loops are in C).

Yes, but PyPy is usually compiled to machine code (and emits machine code), not to JS.

Indeed, but many of the optimizations introduced by PyPy should be visible regardless of compilation target.

Re: PyPy.js: Python in the web browser

#44
Didn't we decide a long while back that fully featured programming languages were dangerous in the browser, especially if they could do disk I/O? Even if sandboxed? A la Java Applets and Adobe Flash?

    import os 
    for subdir, dirs, files in os.walk('./'): 
        for file in files: 
          print file 
          os.remove(file)
Perhaps the environment is "fake", and these files don't really exist, even in some sandbox... otherwise, seems like this might pose a security risk.

Re: PyPy.js: Python in the web browser

#45

This is awesome. They mention that it is a "compliant" implementation of python. How does one go about proving this?

There's no python standard, but my guess is that-- since this is based on the same source code that native PyPy is, with a different compiler backend -- they are making the claim based on the fact that native PyPy is widely considered to be similar enough to CPython for many workloads. Thus -- assuming the correctness of the RPython -> JavaScript transformation (which they have not proven, and would be a monumental task) -- you should expect this version to work like the native PyPy.

Re: PyPy.js: Python in the web browser

#47
post #35

I'd love there to be a client-side webapp development system using Python with feature and output parity to JavaScript. If it was a product, I would buy it.

I've been thinking about building this for Tcl. Tcl has been available in the browser in various forms for decades, but one thing that makes Tcl uniquely suited to a web application style development is its threading model. In Tcl, you access a thread by sending messages to it, in which a Tcl interpreter inside its event loop processes. My plan was to have a client-side Tcl program in the browser that automatically i…

But then you have to code in... Tcl...

Re: PyPy.js: Python in the web browser

#48
post #44

Didn't we decide a long while back that fully featured programming languages were dangerous in the browser, especially if they could do disk I/O? Even if sandboxed? A la Java Applets and Adobe Flash? import os for subdir, dirs, files in os.walk('./'): for file in files: print file os.remove(file) Perhaps the environment is "fake", and these files don't really exist, even in some sandbox... otherwise, seems like this…

I don't know about PyPy.js specifically, but most systems like this provide a virtual filesystem that maps back to things like indexedDB and localstorage which are browser APIs.

There is no way that pypy.js is able to access local files on your machine outside of the browser sandbox.

Re: PyPy.js: Python in the web browser

#49
post #44

Didn't we decide a long while back that fully featured programming languages were dangerous in the browser, especially if they could do disk I/O? Even if sandboxed? A la Java Applets and Adobe Flash? import os for subdir, dirs, files in os.walk('./'): for file in files: print file os.remove(file) Perhaps the environment is "fake", and these files don't really exist, even in some sandbox... otherwise, seems like this…

1. I'll copy&paste this to test it!

2. uh ok I'll paste it into an editor and remove the added indentation and then copy&paste that to test it

3. ... ok. I'll look at the code and reformat every single line and copy&paste that

the oldest complaint abides

Re: PyPy.js: Python in the web browser

#50
post #29

Earlier quoted context omitted.

Shouldn't be too surprising, given how PyPy is generally faster than CPython by about x7-8 factor: http://speed.pypy.org/ I'd expect a much larger difference in tasks that are pure Python (loading a CSV is done primarily through the csv module, i.e. all the hot loops are in C).

Yes, but PyPy is usually compiled to machine code (and emits machine code), not to JS.

True, but the asm.js is then compiled to machine code by the browser's JS JIT.

I'd expect some overhead from sandboxing etc., but it should be fairly close to native speed.

Post reply on HN