Slashdot Mirror


Python Converted To JavaScript, Executed In-Browser

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

4 of 176 comments (clear)

  1. Re:Why, God, why???? by timeOday · · Score: 5, Insightful

    The only thing worse than Python is, well, Javascript.

    I'd be interested to hear what you like better, and why? Personally I'm still sad that Java (not Javascript) didn't win on the Web - a cross-platform, general purpose language that is at least a reasonable choice for most anything. To make programming faster, you can always use higher-level libraries or code-building environments on top of it, or compile some other syntax to java bytecode.

    Now instead the Web is a big mish-mash of fundamentally incompatible technologies. And if anybody does pull off the one-runtime-for-anything vision, it looks like it will be Microsoft.

  2. Re:How about a Javascript - to - python convertor? by s4m7 · · Score: 4, Insightful

    Cleaning up the browser programming environment is not about getting rid of Javascript.

    Maybe not, but javascript is not a good language, it's a bad language with some good features. The awful scoping mechanism is evidence of this enough. The intrinsic objects are too limited to be useful, so much so that now there are more than 4 different common framework projects to handle all the inconsistency in implementation and they're all incompatible with each other. anonymous functions are great but they make debugging a giant pain the arse.

    i would like to see a viable alternative language to javascript, just for variety's sake. It's just had layers of crap pasted on top of it since 1995 or whatever and it'd be nice to see a new approach that fits what people actually use it for these days.

    --
    This comment is fully compliant with RFC 527.
  3. Re:A practical use by ggpauly · · Score: 3, Insightful

    Why not teach Javascript itself?

    It's a simple but powerful general-purpose object-oriented language. It's also a functional programming language with C-like syntax, closures, and lambdas.

    A browser is the interpreter.

        **** Please read http://javascript.crockford.com/javascript.html before modding this down. ****

    --
    Verbum caro factum est
  4. Python implementations still suck by Animats · · Score: 4, Insightful

    Python is quite a good language, but the implementations suck. This is holding back widespread use of Python. It's too slow, typically 10x to 30x slower than C. That's far worse than Java.

    There have been several attempts at other implementations. But because Guido Rossum fights formal standardization of the language, treating his CPython implementation as a de-facto standard, everyone else has a moving target to hit.

    Google (who hired Guido) likes Python, but they don't like the low performance. CPython is a "naive interpreter" (very little optimization). Worse, with the rather lame implementation the Global Interpreter Lock, not only can't it use a multi-core CPU effectively, multi-thread programs run slower on multi-core CPUs. (The threads fight over the lock in an embarrassingly inefficient way.)

    Google is doing "Unladen Swallow", which is an attempt to bolt CPython to a just-in-time compiler to a virtual machine. It's not clear how well that will work out, but the end result will have more layers than seems to be indicated. The goal is 5x faster than CPython, which won't beat Java, let alone C/C++.

    It's cute that Python to JavaScript translation is possible, but it's not going to help much on the performance front.

    For a few years, the great hope of the Python community was PyPy, but that had too many goals, was being developed in "sprints", and after five years, the European Union pulled the plug on funding after it was slower than CPython.

    Shed Skin, which is a Python to C++ hard-code compiler, is currently the lead in Python performance, but it doesn't yet implement the whole language. Still, with about two people working on it, Shed Skin is doing better than most of the bigger projects. Shed Skin does automatic type inference. Python doesn't have declarations, but with enough analysis, the compiler can figure out what types each variable can hold and generate hard types, which makes for much faster code.