4 ms·
That's because heavyweight clientside applications are only a more recent thing and JavaScript engines have improved alot. JavaScript is great for event based
by ma2rten 15y ago
That's because heavyweight clientside applications are only a more recent thing and JavaScript engines have improved alot.
JavaScript is great for event based programmming because of it's scoping rules. Python can't offer that.
That's why a few langang
- riffraff 15y agowhat scoping rules make javascript better than python for evented programming? I am not a big JS writer, but I can't seem to see anything important (nested functions, globals). Maybe you are referring to the fact that JS has an arguably better syntax for anonymous functions?
- crizCraig 15y agoIn python nested functions must be declared before calling them. Also stuff like this seems to crop up on me when I ry using closures: http://stackoverflow.com/questions/2516652/scoping-problem-in-recursive-closure http://stackoverflow.com/questions/2516652/scoping-problem-i...
- riffraff 15y agothat is what I meant as having a better syntax for anonymous functions. I agree it's bad (even with nonlocal in python 3) but that is not a matter of different scoping rules, it's only syntax.
- sid0 15y agoPython has implicit declarations, which lead to a world of hurt because you can't directly modify variables in arbitrary scopes. Python 3 has nonlocal, but that only extends the number of function scopes you can refer to to three. I think having implicit declarations is probably the worst mistake Python made. It just makes things so much more confusing.
- sid0 15y agoSorry, I made a mistake: nonlocal gives you as much power as usual closures. I still stand by my statement that implicit declarations make things very confusing.