News for hackers. Stuff that matters.
Re:Python, client side: Skulpt by s3graham on Friday August 07, 2009 @01:48AM (#747094)
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.

Re:Python, client side: Skulpt by dtf on Friday August 07, 2009 @02:21AM (#747139)
Very impressive work. But you'll need to implement "import this" for it to be considered a serious Python implementation.
Re:Python, client side: Skulpt by kevindication on Friday August 07, 2009 @08:37AM (#747469)
Any support at all for modules is really a requirement to be considered a serious Python implementation.

  >>> import sys
  don't have handler for: import_stmt
But otherwise, neato.
Re:Python, client side: Skulpt by dkersten on Friday August 07, 2009 @04:12AM (#747257)
Good point
Re:Python, client side: Skulpt by irrelative on Friday August 07, 2009 @10:10AM (#747579)
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...)
Re:Python, client side: Skulpt by mahmud on Friday August 07, 2009 @01:53AM (#747099)
Neat little thing. Feared and appreciated comprehensively.
Re:Python, client side: Skulpt by pmorici on Friday August 07, 2009 @03:46AM (#747235)
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()?

Cool none the less.

Re:Python, client side: Skulpt by s3graham on Friday August 07, 2009 @03:57AM (#747244)
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)

Re:Python, client side: Skulpt by snprbob86 on Friday August 07, 2009 @03:18AM (#747214)
Did you evaluate PyPy? I think they already have a significant RPython->Javascript backend.
Re:Python, client side: Skulpt by s3graham on Friday August 07, 2009 @03:30AM (#747220)
Link? I don't see it at http://codespeak.net/pypy/dist/pypy/doc/docindex.html#pypy-d... (a js interpreter, but no translator).

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.

Re:Python, client side: Skulpt by snprbob86 on Friday August 07, 2009 @03:41AM (#747232)
Apparently they removed it:

http://www.mail-archive.com/[email protected]/msg03946....

That post also mentions Pyjamas, a port of Google Web Toolkit which compiles Python instead of Java: http://pyjs.org/

Re:Python, client side: Skulpt by tome on Friday August 07, 2009 @09:25AM (#747516)
Well this is very annoying as I had started to use PyPy's Javascript backend in metapaw-dip:

http://www.metapaw.co.uk/projects/metapaw-dip/

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.

Re:Python, client side: Skulpt by zokier on Friday August 07, 2009 @07:50AM (#747429)
http://www.trypython.org/

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.

Another cool SL trick: http://www.mix09.org/labs/gestalt/samples/canvas.2d.drawing/...

Using Python inline in your html via Silverlight and a helper JavaScript called "Gestalt". It also supports Ruby.

http://www.mix09.org/labs/gestalt/

Re:Python, client side: Skulpt by pingswept on Friday August 07, 2009 @10:06AM (#747575)
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.)

Re:Python, client side: Skulpt by bmelton on Friday August 07, 2009 @10:50AM (#747649)
I believe Silverlight works in Firefox actually.

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.)"

Re:Python, client side: Skulpt by pingswept on Friday August 07, 2009 @11:43AM (#747760)
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).

Re:Python, client side: Skulpt by gcopenhaver on Friday August 07, 2009 @11:38AM (#747750)
There's an open source implementation of Silverlight, called Moonlight:

http://www.mono-project.com/Moonlight

I've never used it before, so I don't know how well it works or anything.

Re:Python, client side: Skulpt by pingswept on Friday August 07, 2009 @11:46AM (#747765)
I don't actually want to use a proprietary tool like Silverlight, or an open reimplementation, but I appreciate the effort to make the comment.

Thanks.

Re:Python, client side: Skulpt by benhoyt on Friday August 07, 2009 @05:03AM (#747315)
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?

Re:Python, client side: Skulpt by tlrobinson on Friday August 07, 2009 @03:13AM (#747207)
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):

http://github.com/tlrobinson/cappruby

(disclaimer: it's horribly incomplete and I haven't touched it in months)

Re:Python, client side: Skulpt by s3graham on Friday August 07, 2009 @03:35AM (#747227)
Neat.

ObjJ and Capp were my inspiration for doing a browser language without an offline convert process, so... thanks :)

I was wondering if I could use Cappuccino as the "Skulpt GUI toolkit" too, but that might start to get a bit silly with number of layers involved.

Re:Python, client side: Skulpt by DanielStraight on Friday August 07, 2009 @01:03PM (#747979)
All I get is a blank page... Is there something I'm missing or is the site down?
Re:Python, client side: Skulpt by avibryant on Friday August 07, 2009 @02:50PM (#748297)
All I get is a blank page too. I was very curious to look at this because I've been doing something very similar - for Smalltalk, instead of Python.
Re:Python, client side: Skulpt by paulbaumgart on Friday August 07, 2009 @05:29AM (#747339)
Anybody else on Mac OS X unable to type a colon in the interactive prompt?

I tried it in both Firefox 3.5 and Safari 4, and neither works.

Apparently it's not just this site, though. According to http://www.cambiaresearch.com/c4/702b8cd1-e5b0-42e6-83ac-25f... it's only sending a shift (KeyCode 16) when I try typing a colon...

On my Ubuntu system, the colon works just fine. Is this a known bug?

Re:Python, client side: Skulpt by apgwoz on Friday August 07, 2009 @06:33AM (#747369)
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.
Re:Python, client side: Skulpt by s3graham on Friday August 07, 2009 @12:23PM (#747867)
Hmm, sorry about that, I only tried the demo console on Ubuntu and Windows, and only with a US keyboard.

I haven't found a non-insane way of doing it.. see f.e. http://www.quirksmode.org/js/keys.html

Anyone have any pointers? (or patches? :)

Re:Python, client side: Skulpt by adrinavarro on Friday August 07, 2009 @10:01AM (#747566)
spanish qwerty keyboard layout here, works fine in safari 4 (osx), but I also use 'shift' to type colons, etc... maybe a fixed bug?
Re:Python, client side: Skulpt by uggedal on Friday August 07, 2009 @06:35AM (#747374)
Somewhat buggy:

    >>> print 1, 2, 3
    1 1 1
Re:Python, client side: Skulpt by diN0bot on Friday August 07, 2009 @09:09AM (#747498)
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.

Is this a problem on my end? FF3.1 Leopard.

Re:Python, client side: Skulpt by s3graham on Friday August 07, 2009 @12:19PM (#747857)
oops, thanks, I'll fix that.
Re:Python, client side: Skulpt by ccheever on Friday August 07, 2009 @04:06AM (#747251)
wow, that's super cool. i hope you keep working on it and making it more complete.
Re:Python, client side: Skulpt by Xixi on Friday August 07, 2009 @04:15AM (#747262)
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.

GWT is nice and all, but python >> Java...

Re:Python, client side: Skulpt by s3graham on Friday August 07, 2009 @04:27AM (#747279)
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!

Re:Python, client side: Skulpt by Torn on Friday August 07, 2009 @03:55AM (#747242)
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.

Re:Python, client side: Skulpt by s3graham on Friday August 07, 2009 @04:06AM (#747250)
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.

Re:Python, client side: Skulpt by m_eiman on Friday August 07, 2009 @10:54AM (#747658)
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...
Re:Python, client side: Skulpt by wooby on Friday August 07, 2009 @03:52AM (#747239)
Awesome - reminiscent of HotRuby, except cooler/faster/parses and executes all by itself. It would be nice if there was a JS Parrot VM.
Re:Python, client side: Skulpt by adrinavarro on Friday August 07, 2009 @09:52AM (#747551)

   >>> from __future__ import braces
   don't have a handler for: import_stmt
Looks nice, still a lot to do.
Re:Python, client side: Skulpt by cool-RR on Friday August 07, 2009 @04:59AM (#747314)
I can't even type = or +
Re:Python, client side: Skulpt by mahmud on Friday August 07, 2009 @08:59AM (#747492)
Opera and Firefox hijack + for the zooming in functionality.
Re:Python, client side: Skulpt by kennethreitz on Friday August 07, 2009 @01:39PM (#748103)
Amazing!! I love python and i love this :)

site looks down though..