
PyPy.js – PyPy in Your Browser - mikeckennedy
http://talkpython.fm/episodes/show/32/pypy.js-pypy-python-in-your-browser
======
corndoge
Instead of yet another .js to run * in the browser, maybe we should return the
web and browser back to it's pure days of marked up text documents with images
and move "web apps" to a generalized, native runtime designed explicitly to
run dynamically fetched untrusted code. Might be better than the current mess.

Edit:

And to all those thinking "but that's the browser", that's my point. We have
the browser and while it works, it's incredibly broken in a lot of ways. I'm
proposing a system designed from the ground up to do the job that the browser
has currently been hacked and add-on'd into doing.

~~~
jnowlan
While I completely agree, since it will never happen, why not strip javascript
out of a browser (FF?), come up with a new catchy name, and market it as a
safe browser. Just need a catchy name..., hmm, maybe Lynx? ;

~~~
AdmiralACK
Links, perhaps...

~~~
ciupicri
Links used to support JavaScript some time ago [1].

[1]: [http://links.twibright.com/user_en.html#ap-
javascript](http://links.twibright.com/user_en.html#ap-javascript)

------
giancarlostoro
I may get criticism from some, but sometimes I wish we did get other languages
supported by most browsers such as maybe Lua, of course Python, as well as
maybe a few others as an alternative to the JS. It would be useful for those
whose workflow doesn't fully involve JS.

~~~
kibibu

        <script type="text/vbscript">
           Sub link_onClick
              ' Do some processing!
           End Sub
        </script>

~~~
tracker1
What's funny, is I wrote and used a lot of JS in classic ASP... the only PITA
was dealing with COM iterators in JS was just not intuative at all. But it did
save me a lot in being able to reuse validation logic client and server.. it
also allowed for some nice serialization/communications... probably why I like
node so much now.. it's just less of a disconnect...

Closest I've come to JS client and server was with ActionScript via Flex/Flash
and VB.Net on the server... having XML literals on both sides was really nice,
though I prefer JS on both ends... I don't miss C# much at all.

------
fiatjaf
How does it compare with Brython?
[http://www.brython.info/](http://www.brython.info/)

~~~
callahad
PyPy.js literally starts with PyPy compiled to asm.js, so you intrinsically
get relatively comprehensive Python compatibility right out of the box.
Brython, as I understand it, is an independent attempt at implementing a
subset of Python in JavaScript.

Edit: rfk addresses this directly around 46:00 in the interview. Paraphrased:
"The big trade-off Brython does to get good performance is the number model.
Things there map pretty directly to JavaScript. But if you overflow or do
something different, you suddenly won't get Python's semantics. If you're
writing new code for Brython, it's a good set of trade-offs, and in some ways
you get tighter integration with the browser and the DOM. But if you're trying
to take some existing code off the shelf and run it... you're more likely to
run into issues."

~~~
aroberge
However, he is wrong about the state of Brython
[https://groups.google.com/d/msg/brython/NRHEaoxAfgw/xMipOAYN...](https://groups.google.com/d/msg/brython/NRHEaoxAfgw/xMipOAYNBAAJ)

------
Siecje
In the future we might be able to compile to Web Assembly.

[https://github.com/WebAssembly/design/blob/master/README.md](https://github.com/WebAssembly/design/blob/master/README.md)

------
Animats
I'm amazed that it works, but not sure it's all that useful. Python is OK, but
it's not really much better than Javascript for the things people do client-
side.

Why do so many people hate the DOM? You need some kind of representation of
the page, and the DOM is just a tree representation of it. It's not hard to
access or modify from a program.

And why this sudden enthusiasm for running programs in the browser? Is it
because Java applets and Flash have finally been removed from most browsers,
and people needed those capabilities?

~~~
tracker1
It comes down to people do need to do things in a browser context... Java and
Flash just had horrible security track records. In the end, if Adobe had made
flash more standardized. If they could have gotten the format closer to
xapp/silverlight packages, around JS, SVG and MP3 native in the browsers, they
could have kept making money on the tooling, and been better off. That was my
hope when Adobe bought out Macromedia... didn't work out that way.

In the end, people are learning what works best... In the end it depends.. I
think it comes down to being that people want cleaner application development
targetting the browser.. I think modern node/babel/webpack apps are much
better as a workflow (I also like React). However, I don't begrudge people
wanting to target other environments.. I think source maps go a long way to
making it nicer to do in practice.

I'm also appreciating the resurgence of more FP concepts over OO everywhere...
Outside of controls/components, I don't think classes work well for most JS
needs.

~~~
Animats
Java and Flash were supposed to be sandboxed, but weren't. Is there a
convincing demonstration that "asm.js" is more secure? Or is it just that
nobody has done a big "asm.js" exploit yet. "asm.js" exploits have been
found.[1][2] There are probably others already being exploited.

[1] [http://www.scip.ch/en/?vuldb.12180](http://www.scip.ch/en/?vuldb.12180)
[2] [https://www.mozilla.org/en-
US/security/advisories/mfsa2015-2...](https://www.mozilla.org/en-
US/security/advisories/mfsa2015-29/)

~~~
tracker1
asm.js should have the same sandbox model that JS in general has. Which, while
not perfect, has been a bit better than Flash/Java... Removing all programatic
functionality from the browser simple isn't a reasonable option. And imho it's
better than the binary plugin option.

------
yeukhon
Seriously... do we really need to invent yet another implementation of Python
that runs on the web in Javascript? I mean it with heart. How about we just
have one language and one implementation forget about it? Wouldn't that be
super ideal?

~~~
emily-c
Even if it's not extremely useful it's an interesting project. People tend to
like doing interesting things for fun.

~~~
jawbone3
Per comments above, pypy.js is not presented as an trivial but interesting
thing, but as something useful.

~~~
Mizza
It's easy to see how this could be useful for somebody though.

Imagine you're a scientist, and you have a large, pure python codebase - let's
say for intelligently predicting the number of foos in a bar - and you want to
make that available via the browser, in order to visualize the progress of
your foo-hunter.

This makes it a trivial task - and means you can use cool web-based
visualization tools (D3, etc), and combine with other useful APIs.

~~~
dorfsmay
I think most scientific apps written in Python rely on native non-pure-python
(written in C, Fortran etc...) modules which I'd expect to not work in this
context.

~~~
voltagex_
If you wanted to go crazy you could use Emscripten but I could easily see
pushing the C+Python parts to a server-side web service and then using Pypy.js
for the rest.

------
hoodoof
I wonder if this is a toy/technology demo, or a really solid Python execution
environment.

Tech demos/toys are an interesting distraction for a minute. Deep efforts to
build a full execution environment warrant deeper attention.

------
rhabarba
A browser is not a decent platform for anything.

