Re:Script type="text/python"
by afhof on Monday July 19, 2010 @11:49PM
(#1531085)
I wouldn't mind seeing Python become the default scripting language for browsers over Javascript. Not that IronPython has to be the implementation. Python has a huge library and an easy learning curve.
[ Parent
| on HN ]
Re:Script type="text/python"
by postfuturist on Tuesday July 20, 2010 @02:36AM
(#1531346)
I love Python, I really do, but JavaScript happens to be slightly better as a browser language because it is a little freer with the anonymous functions. Most JavaScript programmers use this all the time, without even thinking. Here's a jQuery example:
$.ajax({ url: 'ajax/test.html', success: function(data) { $('.result').html(data); alert('Load was performed.'); } });
The equivalent Python would be this (assuming you ported jQuery):
def successcb(data): Q('.result').html(data) alert('Load was performed
Q.ajax(url='ajax/test.html', success = successcb)
OK, that's not too bad, I guess. Named parameters are nice. Having to define the success callback separately is not so great.
Edit, HN broke the formatting.