Follow Slashdot stories on Twitter

 



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:
  • by mcvos ( 645701 ) on Saturday September 19, 2009 @10:46AM (#29476351)

    What a waste of time and energy. The only thing worse than Python is, well, Javascript.

    That is exactly the whole point that you're so obviously missing here: nobody sane should have to write Javascript, and yet it's the only thing that's supported by browsers. So converting code from other languages to Javascript is the only sensible solution at the moment. (For the longer term, it'd be nice if they replaced Javascript with something halfway sane.)

  • by ggpauly ( 263626 ) on Saturday September 19, 2009 @10:51AM (#29476375) Homepage

    In most ways (no explicit integer type being an exception) Javascript is a remarkable and beautiful language [crockford.com]. It has libraries available on a server near you through Dojo, among others. Javascript is one of the best things about browsers.

    What browsers need is a workable CSS and DOM interface (although the DOM interface has improved in recent years). 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.

  • by timeOday ( 582209 ) on Saturday September 19, 2009 @11:04AM (#29476441)

    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.

  • by s4m7 ( 519684 ) on Saturday September 19, 2009 @11:23AM (#29476521) Homepage

    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.

  • by Anonymous Coward on Saturday September 19, 2009 @12:34PM (#29476955)

    This is something i can agree with.

    So much of JavaScript is really good, but actually programming it is hellish.
    The interfaces between it and HTML/CSS are sub-standard. (IMO)

    I wouldn't want an alternative, i would just like it to be fixed.
    But getting web browser vendors behind it is the hardest part, especially when it comes to everyone's favorite company, Microsoft. (although admittedly recently they have been pretty decent, which i am really happy about)

    I wouldn't mind if it evolved some more functionality present in Java, we are getting closer with things like LocalStorage and newer features which makes me really excited.

  • Re:A practical use (Score:3, Insightful)

    by ggpauly ( 263626 ) on Saturday September 19, 2009 @01:18PM (#29477249) Homepage

    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 [crockford.com] before modding this down. ****

  • by Animats ( 122034 ) on Saturday September 19, 2009 @01:35PM (#29477363) Homepage

    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 [blogspot.com], 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.

  • by BitZtream ( 692029 ) on Saturday September 19, 2009 @02:15PM (#29477619)

    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.

    Why? So in 2025 you can sit around talking about the new language thats fills its roll perfectly but isn't to your liking and wasn't the perfect vision you thought it would be 15 years ago? Javascript has barely changed in the last 15 years. The environment that javascript deals with has changed a lot, but the language, not so much. Any language (or more appropriately put, any environment) that has 15 years of patches for an environment that changes rapidly is going to look and feel the same, regardless of if it starts off with your precious languages or not.

    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. The language does not make the programmer, the programmer does. If you find a language/environment difficult to use, you are the shitty part of the equation. Languages are just that, languages. They describe things. You are the one that has to figure out how to describe what you want, if you can't do that, the language or environment isn't the problem, you are.

    Stop blaming JS for you being a shitty developer who can only parrot things out in whatever language you learned from your CS professor.

  • by Hohlraum ( 135212 ) on Saturday September 19, 2009 @02:17PM (#29477637) Homepage

    Why is it ok for Java to be slower than everything that came before it? Because supposedly its easier to use and hardware is always getting cheaper. Why is it ok for Python to be slower than Java? Because it IS easier to use and hardware is always getting cheaper.

  • Re:GWT for Python? (Score:2, Insightful)

    by Xtravar ( 725372 ) on Saturday September 19, 2009 @02:41PM (#29477761) Homepage Journal

    Eh, a language is only as good as its standard library. I don't like telling people to download/build/install a number of other libraries of specific versions just to run/build my stupid application.

    It's just a fact of life. For personal applications (where it's hard enough to get people to use your app anyway) and work applications (where licensing causes multiple headaches on this front).

    And no, I don't use Ruby, Python, or Javascript so I can't comment on any of their libraries.

  • by jellomizer ( 103300 ) on Saturday September 19, 2009 @02:42PM (#29477763)

    It really wasn't OK for Java to be slower then languages that came before it. Its success is rather limited. (now I opened the door to all the JavaDevelopers and IBM Trolls) Java was meant to be a replacement for for all those apps that are out there. But it has done little in terms of front end applications, where it was hoping to succeed the most. Why because of its poor performance, on standard PC and especially with GUI's Even using a fast PC you know when you are running a Java App. That is why Microsoft Visual Studios even with the abomination of .NET virtual machine garbage, has made it more popular for front end development then with Java. Because it performs better.

    Saying that is bad because it is slower then Java means that Java is really slow and people are not happy with that so anything slower will make us more unhappy.

  • by s4m7 ( 519684 ) on Saturday September 19, 2009 @02:51PM (#29477831) Homepage

    wow, cs rage much?

    I am perfectly capable of programming in JS. I've written a number of extremely useful classes in the language and I don't care for your tone.

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

    well, hello mr. strawman. I never declared that I wish javascript would go away, and I don't suggest any "better" language should take its place... I merely asked for an alternative that reflects how it is used in a modern sense more accurately.

    Why? [...]Javascript has barely changed in the last 15 years.

    Thank you for answering your own question. js wasn't a good language in the first place and 15 years of cobbling have only gone on to expose and underscore its various weaknesses. JS can do quite a bit, and it's undoubtedly useful. that doesn't change the fact that it's fundamentally a poor structure for doing what people do with it now: namely DOM scripting and asynchronous requests. I don't disagree that in 15 years whatever we develop today probably won't be a good fit for what we're doing with it then: this however is no excuse for a complete lack of progress.

    If you find a language/environment difficult to use, you are the shitty part of the equation.

    well that's an extremely lazy way of looking at things. Yes languages are just that, languages, and since there's no excuse for being a "bad programmer" and expecting your tools and vocabulary to be up to the task you're attempting to address, we should all still be programming in assembler using punchcards by your logic. God forbid we make use of decades worth of brilliant thought on the topic of how programming languages ought to be structured and keep things moving forward.

  • by OrangeTide ( 124937 ) on Saturday September 19, 2009 @02:57PM (#29477861) Homepage Journal

    Saying that is bad because it is slower then Java means that Java is really slow and people are not happy with that so anything slower will make us more unhappy.

    What?

So you think that money is the root of all evil. Have you ever asked what is the root of money? -- Ayn Rand

Working...