Live data from Hacker News

PyPy.js: A fast, compliant Python implementation for the web

pypyjs.org

51–60 of 144 posts

Re: PyPy.js: A fast, compliant Python implementation for the web

#53
post #23

Earlier quoted context omitted.

> python can't be directly included in Firefox or other browsers So Python is a bad candidate, but there are better candidates out there. For example, jsofocaml (using OCaml in the browser) looks quite promising. In the end, we need a lightweight yet properly defined and highlevel language, and the ML languages as well as the LISP languages are great candidates for that.

Purescript is a Haskell-like language that is designed to output to javascript. It looks quite nice and has seen a lot of attention lately. It's even in GSoC.

plus its semantics lie pretty close to javascript. Most importantly because it's strict instead of lazy. Eventhough its strict it has a very haskelly feel. Both in syntax and type system. Also I think strict semantics is the way to go for efficient Functional Reactive Programming.

Furthermore, Purescript's FFI is really nice to use and it's really easy to bind to existing javascript libraries.

PureScript is community is nice and active. They are also discussing a lot with the `virtual-dom` guys to bring react/om/mercury-like functionality to purescript [0] and it's quite freakin awesome.

Seriously I'd take purescript for javascript any day. I think it's great that we FP folks can finally do frontend dev :-)

[0] - https://github.com/slamdata/purescript-halogen

Re: PyPy.js: A fast, compliant Python implementation for the web

#54
post #11

This is glorious. From https://github.com/rfk/pypyjs/blob/master/CONTRIBUTING.rst : > We have the following major components in the PyPy repo: >> An "emscripten" build platform definition, which teaches pypy's rpython toolchain how to compile things with emscripten: ./deps/pypy/rpython/translator/platform/emscripten_platform/. >> An rpython JIT backend that emits asmjs at runtime: ./deps/pypy/rpython/jit/backend/asmj…

It's compilers all the way down.

Re: PyPy.js: A fast, compliant Python implementation for the web

#55
post #11

This is glorious. From https://github.com/rfk/pypyjs/blob/master/CONTRIBUTING.rst : > We have the following major components in the PyPy repo: >> An "emscripten" build platform definition, which teaches pypy's rpython toolchain how to compile things with emscripten: ./deps/pypy/rpython/translator/platform/emscripten_platform/. >> An rpython JIT backend that emits asmjs at runtime: ./deps/pypy/rpython/jit/backend/asmj…

Since PyPy compiles RPython to C, couldn't one write a web app in RPython, compile it to C, then to JS (with asm.js) and enjoy a quick page load and smaller file size?

By the way, is RPython a nice language to program in?

Re: PyPy.js: A fast, compliant Python implementation for the web

#58
post #23
post #9

I watched the presentation in Pycon 2015[1], and I really liked how honest/aware they are about the challenges and tradeoffs (so far, the performance it's pretty bad compared to javascript, and the download size is still an issue). At the end is answered why python can't be directly included in Firefox or other browsers(the presenter/main developer works for Mozilla) [1] https://www.youtube.com/watch?v=PiBfOFqDIAI

> python can't be directly included in Firefox or other browsers So Python is a bad candidate, but there are better candidates out there. For example, jsofocaml (using OCaml in the browser) looks quite promising. In the end, we need a lightweight yet properly defined and highlevel language, and the ML languages as well as the LISP languages are great candidates for that.

> In the end, we need a lightweight yet properly defined and highlevel language....

Even lua would be a joy!

Re: PyPy.js: A fast, compliant Python implementation for the web

#59
post #18

Sample code to execute some Javascript code inside PyPy.js. I couldn't find any examples. import js js.eval("console.log(\"hi!\")")

Just playing around: import js c = js.globals.document.createElement("canvas") js.globals.document.body.appendChild(c) ctx = c.getContext("2d") ctx.fillRect(10, 10, 10, 10) Edit: Here is a simple animation: import js import math import time c = js.globals.document.createElement("canvas") js.globals.document.body.appendChild(c) ctx = c.getContext("2d") def render(): ctx.clearRect(0, 0, c.width, c.height) t = time.time…

Sadly, if I paste that in, I get:

    >>> import js 
    ... c = js.globals.document.createElement("canvas") 
    ... 
    debug: OperationError:
    debug:  operror-type: SyntaxError
    debug:  operror-value: ('EOL while scanning string literal', ('c callback', 1, 12, "r = c.push('import js\n", 0))
    debug: OperationError:
    debug:  operror-type: KeyError
    debug:  operror-value: 'r'
And then the input window hangs. Strangely enough, if I type it in instead, it's okay.

(ChromeOS v43 beta-channel)

Re: PyPy.js: A fast, compliant Python implementation for the web

#60
post #11

This is glorious. From https://github.com/rfk/pypyjs/blob/master/CONTRIBUTING.rst : > We have the following major components in the PyPy repo: >> An "emscripten" build platform definition, which teaches pypy's rpython toolchain how to compile things with emscripten: ./deps/pypy/rpython/translator/platform/emscripten_platform/. >> An rpython JIT backend that emits asmjs at runtime: ./deps/pypy/rpython/jit/backend/asmj…

Since PyPy compiles RPython to C, couldn't one write a web app in RPython, compile it to C, then to JS (with asm.js) and enjoy a quick page load and smaller file size? By the way, is RPython a nice language to program in?

The differences are described here: https://rpython.readthedocs.org/en/latest/rpython.html
Post reply on HN