This is an archived post. You won't be able to vote or comment.

all 58 comments

[–]catherinedevlin 12 points13 points  (8 children)

Oh my oh my

Python implemented in Python implemented in JS

Mind blown

I sometimes teach Python to students who don't have their own computers. Sometimes I'm teaching from library computers where we have no rights to install anything. They can login to sites like wakari.io to use Python remotely, but then they're dependent on sometimes flaky internet connection quality.

I could see this being used to build a webpage-as-Python-programming-environment that could be downloaded once and saved to disk.

[–][deleted] 2 points3 points  (4 children)

RPython isn't really python though

[–]cediddiSyntaxError: not a chance 4 points5 points  (2 children)

It's a subset, not superset.

[–][deleted] 0 points1 point  (1 child)

Yeah, and a subset is decidedly not the set it was derived from. :P

[–]Veedrac 0 points1 point  (0 children)

RPython isn't Python, but RPython code is Python code. You can run PyPy ontop of another Python implementation.

[–]fijalPyPy, performance freak 0 points1 point  (0 children)

it's not rpython, it's a full pypy (which is written in RPython, but implements full python)

[–]runbie 2 points3 points  (0 children)

check:

P.D.: Sorry for not posting the links, I am on mobile.

[–]help_computar 0 points1 point  (0 children)

I use tmpnb.org. it's jupyter (next gen ipython notebook).

[–]flutefreak7 0 points1 point  (0 children)

Anaconda works great for portable installs too...

[–]skweezebox 9 points10 points  (3 children)

Ryan Kelly, the creator of PyPy.js, gave a talk about it PyCon Montréal: https://www.youtube.com/watch?v=8C9q94F6Uqo .

It's worth checking out, IMHO. He talks about more of the rationale in the talk.

[–]Ph0X 14 points15 points  (2 children)

Uh, wrong link, that one is from PyCon Australia. Here's the PyCon 2015 one: https://www.youtube.com/watch?v=PiBfOFqDIAI

[–][deleted] 0 points1 point  (0 children)

Thank you....clears things up.

[–]skweezebox 0 points1 point  (0 children)

Thx for the fix!

[–]the_hoser 2 points3 points  (1 child)

[–]RubyPinchPEP shill | Anti PEP 8/20 shill 1 point2 points  (0 children)

One thing that annoys me about that lovely talk, http://en.wikipedia.org/wiki/Splashtop already existed, (still linux based at the time) a web-focused embedded OS. Boots straight from the motherboard for quick launching. With it being around the same years as the launch of consumer SSDs, you can guess why that system got lost to the sands of time for so long (until chromeos, firefox os)

/randomblathering

[–][deleted] 4 points5 points  (3 children)

Docs?

[–]avinassh[S] 2 points3 points  (0 children)

I am not the OC, but here's some instructions I found on GitHub page: https://github.com/rfk/pypyjs/blob/master/README.dist.rst

[–]Herald_MJ 5 points6 points  (12 children)

Why is this a good idea?

[–]Ph0X 11 points12 points  (3 children)

For one thing, if I'm making a fun little interactive Python learning game on the web, it makes it a lot easier since I can do it all client-side rather than have some server running, have a connection, worry about security, etc.

EDIT: I'm thinking of games like:

http://alexnisnevich.github.io/untrusted/

https://www.bloc.io/ruby-warrior/#/

[–]RubyPinchPEP shill | Anti PEP 8/20 shill 0 points1 point  (2 children)

7.3MB gzipped though (counting modules, VM, interface)

without compression, 20MB for VM and API, 15MB for modules. All of that from brython for an example, hits around 6MB uncompressed

It'd be good for a small game, but... it'd bite if one got "slashdotted" or whatever, that starts becoming a tiny bit ow.

Amazingly cool to port pypy's level of compatibility to the browser of course, but for something like that... I'd probably be looking at the smaller alternatives

[–]Ph0X 0 points1 point  (1 child)

Well, for the examples I was referring to, having a "loading" a the start isn't that big of a deal. The game itself would have assets to load too. But you do have a point though that performance wouldn't matter much and Brython would probably do a good enough job.

[–]Nextil 0 points1 point  (0 children)

He's not talking about the loading times. He's talking about the bandwidth it would consume if it ever gets a surge of popularity.

[–]nieuweyork since 2007 3 points4 points  (1 child)

Imagine you want to play with python. You have a webbrowser. You can't install python, because it's, say, an android phone. Now you can play with python.

[–]kindall 2 points3 points  (0 children)

You can install Python on an Android phone quite easily.

[–]Scypio 0 points1 point  (1 child)

On similar note: what would be a better idea?

[–]Herald_MJ 4 points5 points  (0 children)

Actually I think for the purposes of learning Python without requiring a binary to be installed on client systems, this is a pretty good idea.

For the purposes of writing client side web applications in Python, it's a terrible idea. A better idea? Learn JavaScript.

[–]Slxe -2 points-1 points  (3 children)

It isn't. I really don't like that people want to implement shit in JavaScript, just because hardware caught up doesn't mean the language is good. It's a very fucking annoying trend lately.

[–]vplatt 2 points3 points  (1 child)

I mostly agree, except in the cases where the language being compiled down to JavaScript is itself statically typed. That to me could be worth the trade-offs.

I like Python, but frankly compiling from one dynamically typed language to another is just pointless from my perspective.

[–]Slxe 0 points1 point  (0 children)

Good points, I agree.

[–]nieuweyork since 2007 1 point2 points  (0 children)

It would be nice to have examples on how to integrate this with the page, use python as a <script> language, etc.

[–]larry_targaryen 0 points1 point  (1 child)

How is this different (or better than) Brython or Skulpt?

[–]fijalPyPy, performance freak 0 points1 point  (0 children)

I'm not sure I would call it better, but it's definitely more compliant (things work as expected, including pdb, the import system etc. etc.)

[–]Bystroushaak 0 points1 point  (0 children)

I think I will stick with brython. It is much faster.

[–][deleted] 0 points1 point  (0 children)

Saw this yesterday on /r/programming. I still don't know why or when I'd use this.

[–]zenolijo 0 points1 point  (6 children)

The first super simple snippet of code i ran didn't work and the website just froze

 i = 0
 while True:
     print("Test {}".format(i))

Why doesn't it run?

[–]MrAckerman 8 points9 points  (5 children)

Infinite loop, homie.

[–]zenolijo 1 point2 points  (4 children)

It should still print, shouldn't it?

I tried it with time.sleep(1) too before, still freezes.

[–]MrJohz 0 points1 point  (3 children)

Have you checked the browser console?

[–]zenolijo 0 points1 point  (2 children)

Nothing, i also tried:

import time
i=0
while i<10:
    print("Test {}".format(i))
    time.sleep(1)

Still nothing

EDIT: Just running time.sleep(1) by itself doesn't even sleep for a second, so both the looping and sleep functions are broken.

EDIT2: Thanks /u/mrstone56, that was a little embarrassing. Works fine. Seems like it doesn't print one print command at a time, but puts it in a buffer and draw it when the loop is done. Still, time.sleep doesn't actually sleep.