Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Programming

Python Converted To JavaScript, Executed In-Browser 176

lkcl writes "Two independent projects, Skulpt and Pyjamas, are working to bring Python to the web browser (and the JavaScript command-line) the hard way: as JavaScript. Skulpt already has a cool Python prompt demo on its homepage; Pyjamas has a gwtcanvas demo port and a GChart 2.6 demo port. Using the 64-bit version of Google v8 and PyV8, Pyjamas has just recently and successfully run its Python regression tests, converted to JavaScript, at the command-line. (Note: don't try any of the above SVG demos with FF2 or IE6; they will suck.)"
This discussion has been archived. No new comments can be posted.

Python Converted To JavaScript, Executed In-Browser

Comments Filter:
  • GWT for Python? (Score:3, Interesting)

    by mcvos ( 645701 ) on Saturday September 19, 2009 @10:43AM (#29476331)

    It's not entirely clear to me what Skulpt is exactly, but Pyjamas is apparently GWT ported to Python, which sounds like a really cool idea. Now if somebody did the same thing with Ruby and Scala, I'd be really happy.

    Javascript is just way too stupid to program manually, but currently we're in the odd situation where we're writing server stuff in Ruby, and browser stuff in Java. That's just wrong.

  • A practical use (Score:4, Interesting)

    by slthytove ( 771782 ) <.moc.liamg. .ta. .nella.m.semaj.> on Saturday September 19, 2009 @11:19AM (#29476503) Homepage

    As a high school computer science teacher, I can see a practical application of this. Currently, I think Python is one of the best languages to learn basic programming concepts with, in that it is relatively straightforward, powerful, and there's not much "voodoo" to prevent students from diving right into programming. It's possible to do some really cool things in Python with not much code.

    However, one of the problems is that it can be difficult to give students a way to show off their code. Since it's an interpreted language, they can't just give an .exe or a .app file to someone else to show it off - they need to say, "Oh, go and install Python, and these libraries, etc." Yes, there are solutions such as py2exe and py2app, but getting these set up can be quite a task in itself. By running Python inside JavaScript, you basically open up the whole web-connected world as a potential audience to these budding programmers. It's much easier to say, "Hey, check out this link!" than "Hey, download Python (but get the right version) and this graphics library, then download my .py file, and open up a command prompt and type python blahblah.py!"

  • Re:python sucks (Score:4, Interesting)

    by the_humeister ( 922869 ) on Saturday September 19, 2009 @11:36AM (#29476579)

    I prefer a javascript assembler [ajaxian.com]

  • Re:GWT for Python? (Score:3, Interesting)

    by loufoque ( 1400831 ) on Saturday September 19, 2009 @12:00PM (#29476695)

    Javascript is just way too stupid to program manually

    Not more than Ruby or Python.
    Don't confuse languages with libraries.

  • Re:python sucks (Score:5, Interesting)

    by the_humeister ( 922869 ) on Saturday September 19, 2009 @12:12PM (#29476779)

    Found something better: 6502 assembler! [6502asm.com]

  • Re:Why, God, why???? (Score:5, Interesting)

    by bcboy ( 4794 ) on Saturday September 19, 2009 @12:19PM (#29476839) Homepage

    I felt the same way until I watched Douglas Crockford's videos on javascript. If you hate javascript, you're doing it wrong. I now prefer it to the other languages being discussed here.

  • by lkcl ( 517947 ) <lkcl@lkcl.net> on Saturday September 19, 2009 @12:31PM (#29476927) Homepage

    What browsers need is a workable CSS and DOM interface (although the DOM interface has improved in recent years).

    yes - it's these DOM interfaces that i used for the pure-python port of pyjamas. the first one (webkit) i literally had to create, myself (it took 8 weeks). the second one, xulrunner, used a component created by the OLPC team, called hulahop; the third one, for windows only, uses python COM (the comtypes library) and python ctypes.

    But these are not issues with Javascript per se. Cleaning up the browser programming environment is not about getting rid of Javascript.

    From TFA: """
    anyway, just thought there might be people who would be intrigued (or
    horrified enough to care what's being done in the name of computer
    science) by either of these projects.
    """

    Not horrified, but I wonder if W3C politics is creating unforeseen consequences.

    it has to be said that the attitude of the webkit developers (one in particular who can be easily identified) has been incredibly bad, towards the free software glib/gobject bindings i created for webkit's DOM model [github.org]. nobody should have to put up with the kind of disrespectful treatment i was subjected to, and other contributors whom i've encouraged and trained to help out have been so intimidated by the webkit developers that they are unwilling to even make themselves known to the webkit team, in case they get treated the same way.

    it's a long story, and the webkit team will get burned for it, one way or another.

  • by lkcl ( 517947 ) <lkcl@lkcl.net> on Saturday September 19, 2009 @12:35PM (#29476965) Homepage

    i know you're joking, but there really _is_ a Visual Studio "universal translator" plugin available - i've seen it demo'd, converting c++ to java, to B, to ruby, to c#. it all used CLR as the intermediary. i heard that activestate were commissioned to add python to the mix, but, weirdly, it wasn't included in the release of the translator i saw.

  • Re:Why, God, why???? (Score:3, Interesting)

    by onefriedrice ( 1171917 ) on Saturday September 19, 2009 @12:45PM (#29477029)
    Well, haXe [haxe.org] is a Java-like language which compiles to Javascript among other languages. It's definitely general purpose enough to use in the client as well as the back-end, and it has nice libraries which make communication between them easy. It happens to compile to Flash, too. I'd imagine that any reasonably complex project could be built just about entirely in haXe.
  • by Animats ( 122034 ) on Saturday September 19, 2009 @03:48PM (#29478157) Homepage

    Because it IS easier to use and hardware is always getting cheaper.

    On the server side, 10x to 30x slower means building entire buildings full of servers. Or more expensive hardware in the cell phone. Or using another language.

    Python is actually a good general-purpose programming language, not just a "scripting language". The big problem is slow execution.

    The basic problem with CPython is that, being a naive interpreter, it has to check for the hard cases every time. "n = n + 1" ought to be a few machine instructions, maybe only one. But Python has to check for n being a float, n being a string, n being an object, etc., every time. Shed Skin, with a type inference systems, does analysis at compile time and determines that n is always an integer, then generates code for integer arithmetic only.

    There are all sorts of dynamic things one can do to a Python program while it's running. You can add a function to an object. You can replace existing functions. You can load new modules on the fly. But most of the time, for most of the objects, you don't do that. An efficient implementation needs to separate out the cases where something unusual might occur, and the far more common cases when the program is doing routine stuff that needs to go fast. The common cases can then be handled with much simpler, and faster, code.

  • by bill_kress ( 99356 ) on Saturday September 19, 2009 @04:28PM (#29478445)

    Strange assumption...

    Why on earth would you say Java was slower than everything that came before it?

    It's faster than everything but C, and even ties C in some cases.

    I believe the Language Shootout includes specs for Fortran and Basic (which were before Java), I'm also pretty sure it was faster than Pascal, Ada (Can't swear to that one, don't think it's on the shootout, but I don't remember it being specifically quick), heck hundreds of languages.

    I still don't know why Java gets crap about performance when it is the only language that seems to perform like C.

    Honestly the only thing I can think of is that like Visual Basic, it made programming possible for a LOT more people--people who didn't really know how to program and only wanted to implement a solution to a problem. They made good ideas into decent programs with very bad performance.

    I'm pretty sure that if Python ever becomes known as the language that is an "Easy" way to solve some problem, it'll have the same kind of issues.

    I've also seen some pretty crappy Ruby on Rails websites...

  • by shutdown -p now ( 807394 ) on Sunday September 20, 2009 @05:52AM (#29481937) Journal

    Here is reality for you developers of the world, if you think your language is better than all the rest, or some other language should go away, then you are a shitty programmer.

    I don't know of any "silver bullet" languages, though I definitely have favorites - and I do not wish all others to go away.

    What I do wish, however, is for badly designed languages which don't have any redeeming qualities to go away. And, yes, JS is on that list. Though, admittedly, way below PHP.

    On a side note, an example of a badly designed language with a redeeming quality is Common Lisp - it's ugly as hell, but nothing else matches it in terms of sheer power.

"Ninety percent of baseball is half mental." -- Yogi Berra

Working...