Javascript from Python
In a way I’m disappointed to see python-spidermonkey released. It’s a Python wrapper around the Mozilla project’s SpiderMonkey Javascript engine which allows Python scripts to execute Javascript code in a rock-solid, battle-tested embedded interpreter.
Why the disappointment? Because just 5 days ago I decided that a Python wrapper for SpiderMonkey would be the ideal project for me to finally attempt to do something productive with C. John J. Lee evidently beat me to it. I can’t complain though, as I was estimating a good six months to figure out how to get it all working.
Pettiness aside, this looks like a really valuable project. In addition to being critical for such things as web based unit testing (John’s DOMForm does exactly that) it may also provide a useful “sandbox” protected interpreted scripting language for Python projects. Python’s own rexec module is meant to provide a safe sandbox for executing potentially hostile code but has been disabled due to potential vulnerabilities. The SeaMonkey Javascript interpreter is tried and tested in this capacity, at least in its incarnation within the Mozilla family of web browsers.
I wonder if this brings XUL applications written in Python any closer.
I'm a bit confused after searching for information on this. First I thought PyXPCOM would do the trick for me, but it seems more dead than alive (@mozdev, @ActiveState).
Can anyone clear things up a bit? Javascript is a much nicer language than it seems, but would love to experiment with Python in XUL.
Martijn - 30th December 2003 11:18 - #
I agree with Martijn - Javascript is a much underated language and the fact its available for just about any operating system out there with a decent browser can only go in its favour. Plus, you can be productive in it without having to buy expensive GUI's and tools.
Strange how I've never seen any real programming books about it :-/ The only real drawback for me (and Simon mentioned this a few weeks back) is the debugging.
Richard Allsebrook - 30th December 2003 16:14 - #
As far as I can tell, this has little to do with using python to generate XUL apps - for that you really do need pyXPCOM. There does seem to be some life in PyXPCOM - there is a little traffic on the mailing list, for example. I'm trying to build mozilla with PyXPCOM enabled, using the patch in bug 129216. It doesn't seem to be working yet, but I can't seem to get anything at all to build at the moment, so maybe it's just my environment.
jgraham - 30th December 2003 17:58 - #
Chris Neale - 31st December 2003 10:33 - #
Indeed, python-spidermonkey won't help you with XUL, you need PyXPCOM for that (if you can build it!).
Actually, python-spidermonkey and the code that uses it are dodgy alpha versions, and, having made a first cut at JavaScript support in DOMForm and weighing O'Reilly's "HTML: The Definitive Guide", I fear I don't have the patience to solidly implement the browser object model & associated HTML DOM perversions. I may try and extract bits of Konqueror or Mozilla, and replace my stubby pure-Python code with those, but it could be tricky. Simon! A C project for you! OK, C++, with the complications of XP-COM and PyXPCOM, or KParts, Qt signal/slot mechanism & moc, sip & PyQt / PyKDE (plus its new KParts support), all thrown in.
John - 8th January 2004 14:55 - #