I just can't get myself to love JS the way I do other languages... so, this is my current little weekend project.
It's a source-to-source translator so it interops reasonably with JS and should perform similarly also.
The parser is derived from CPython's so that part is relatively complete, but the "backend" isn't done yet. For example, there's not even support for "class" yet.
I was just looking at the source, and I want to compliment you on how good it looks. Very well done -- really organized and thought out with much less hackery than expected (which JS seems to have a tendency to bring out...)
What version of the language is this and what subset of stuff works, it seems like everything I try gives me some kind of error, maybe I'm just picking the wrong things.
like it lets me create a dictionary but if I try to call the iterkeys() method it doesn't like that, and the built-in function dir() doesn't work. It has range() but not xrange()?
The version is the "still lame" version where I haven't implemented those functions yet. :)
Parser-wise it's 2.6.2, but those functions you mention are in C code in real-Python, so I need to (re-)write them in JS. You can see the list of supported global functions and method functions if you grab the source off bitbucket.
(Incidentally, "for x in a_dict" will work the same as iterkeys currently)
If I were to guess, not having seen PyPy's: I'd like something about 100x smaller than PyPy seems to be, and I don't want a mandatory up-front translation "build" step.
I really, really want to do Python client-side (or rather compile Python to Javascript). Javascript is just so painful for me. Being able to test Python code as Python would be the major reason.
Requires Silverlight, but is far more complete as it wraps IronPython. I think its quite neat what you can do with silverlight even if its EEEEVIL MS tech.
On the topic of Silverlight: is there a reason beyond Microsoft's economic whims that Silverlight couldn't be implemented for non-IE browsers? And if it were implemented across browsers, would it easily work across different OS's?
Or is Silverlight not really a browser plugin like Flash?
(As is probably obvious, I'm totally ignorant of how browser plugins, Flash, Silverlight, and most other things work.)
I don't use it, but the trypython.org page has a statement:
"Target browsers are Firefox 2 & 3, Safari and IE 7 & 8. (It won't work in other browsers until there is a version of Silverlight that works with them.)"
Thanks. I did a little googling. It appears that Silverlight works (at least marginally) in several browsers on two OS's (Windows and OS X).
I'm still curious about why Silverlight works for, say, Firefox on OS X, but not Firefox on Linux. I understand that Microsoft probably wants to prevent Silverlight from working on Linux, but I'm curious whether it's something hard to do because Linux doesn't have X, Y, and Z that Silverlight requires, or is it relatively easy to do (if you had control of the codebase).
Maybe it's just me (Firefox 3.5.2 on WinXP), but the plus key ('+' and '=') doesn't seem to work, so I can't type 1+2 or x=1. Just tried it in Chrome, and that works fine. IE8 does too (though it's very slow).
Anyway, very neat project! How layered is it -- do you think it could approach the speed of JavaScript?
Fun stuff. I've got a similar proof-of-concept project for Ruby, called "CappRuby" which targets the Objective-J runtime (not unlike how MacRuby targets the Objective-C runtime):
I wasn't able to type a colon either. I also wasn't able to type '+', '_', '<', '>', '|', '?', and '~'. These all have the common pattern of being shifted on a normal US keyboard, so I'm going to assume it's related to that.
I can't get shift-+ or shift+; to print to the screen. Nothing gets printed. Shift-<other keys> works as expected. Without '+' and ':' it is quite limited.
Doing the source-to-source translation on top of the javascript on the client side is quite neat.
I'd actually love to create a "GWT like" that would compile my python (in javascript/html/css) for the different browsers out there. That would be awesome.
As snprbob86 pointed out, that already exists: Pyjamas @ pyjs.org.
I used pyjamas a while back for a couple toy projects. It's quite nice and sounds like what you're looking for.
With Skulpt, I wanted to avoid the build step that Pyjamas has (the compiler's written in Python, not Javascript so you run it ahead of time) and at least when I used it, it sometimes felt like Javascript with Python syntax, rather than actually programming in Python. It's certainly closer to Python than Skulpt is today though!
In Opera 10 b2, the python shell never seems to grab focus correctly, so pressing space will scroll down the page way past it, making it very fiddly to use!
Along with hn user pmorici I'd like to find out what subset of Python this supports.
Hrm, sorry about Opera. I tested in a few browsers, but I confess my browser-dom-fu is weak.
From the look of it I'm telling MooTools to stop that event, but backspace doesn't seem to stop in Opera either. Maybe they don't want people disabling keyboard navigation maliciously?
edit: re: subset, my intention is for source-level 2.6 compatibility with the core language, but that's definitely far away.
Very neat and all, but why not let the browser handle the input instead of emulating a US keyboard layout? Makes it hard to write stuff on non-US keyboards...
It's a source-to-source translator so it interops reasonably with JS and should perform similarly also.
The parser is derived from CPython's so that part is relatively complete, but the "backend" isn't done yet. For example, there's not even support for "class" yet.