4 ms·
I really wish that we would see a concerted effort to get Python in the browser (or anything reasonable, really) rather than creating yet another new dynamic la
by peterhunt 15y ago
I really wish that we would see a concerted effort to get Python in the browser (or anything reasonable, really) rather than creating yet another new dynamic language that needs half a decade to grow a decent ecosystem. JavaScript has been around for years and only in the past few years have we seen a legitimate developer ecosystem emerge around it.
- fuzzythinker 15y agocoffeescript is probably the next closest thing. I think I remember firefox and/or chrome will enable it soon.
- ma2rten 15y agoThat'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.
- tzs 15y agoWouldn't Python's use of whitespace to indicate nesting be annoying? JavaScript sometimes gets into pages embedded in script tags (as opposed to be being loaded from external files by script tags), and this is sometimes done by being echoed by server-side PHP or something similar. Having to deal with getting the whitespace right while doing that could be annoying, and would also make the code much harder to read on the server side. I think for this application, the more forgiving a language is about layout the better.
- zmmmmm 15y agoI think that going from a language with real genuine closures to one with the half measure that Python has (lambdas) would actually be a backwards step. Plus I agree with the other (downvoted) commenter that whitespace would be a huge annoyance. A language for the web has to be something robust to copying and pasting to / from web pages.
- andybak 15y agoClosures and lambda (anonymous functions) are orthogonal features. Python has closures (and one last limitation related to scope and rebinding was fixed in Python 3) Furthermore although I agree Python's limited lambda's make it slightly uglier to do some constructs, it's merely syntactic sugar. First-order functions are the critical feature. Whether you are compelled to give them a name or not isn't critical.