3 ms·
Firefox nightlies do support Python. It's unfortunate that nobody wants to migrate away from JS though.
by MostAwesomeDude 15y ago
Firefox nightlies do support Python. It's unfortunate that nobody wants to migrate away from JS though.
- tikhonj 15y agoWhy is it unfortunate? Once you learn it properly, JavaScript is a very pleasant language to work in and, I find, quite a bit more expressive than Python. It also doesn't make using a functional programming style painful the way Python does.
- romaniv 15y agoAre you implying that anyone who doesn't consider JavaScript a "very pleasant language" must simply not know it "properly"? Are you implying that there are no other possible reasons?
- MostAwesomeDude 15y agoWhat does "functional programming style" mean? Does it mean lambdas or other anonymous functions? Python lets you close over names at any scope and define functions anywhere; you don't need the "lambda" keyword. Even if you want to only use lambdas, it's been shown that Python does not need statements, only expressions, to express everything, although you quickly turn your code into Scheme-soup. JS doesn't somehow improve on this. Is it first-class functions? Python has those, just like JavaScript, although Python goes further, enabling you to have real bound methods, descriptors, properties, class methods, and all other kinds of fun. Is it map, filter, and fold? Python's still got map, filter, and fold (foldl, called "reduce" in Python.) Python also has list comprehensions, borrowed from Haskell, as well as generator expressions, providing that valuable laziness that some functional languages value so much. And, in Python 3, there are set and dictionary comprehensions as well. JavaScript doesn't have comprehensions at all. Is it referential transparency or immutability? Unlike JavaScript, Python refuses to allow you to edit the values of certain builtin types, like str and unicode. So, uh, what did you mean, exactly?
- effn 15y agoThe lack of tail call optimization, persistent data structures, pattern matching and the cumbersome lambda syntax makes functional programming style very painful in Javascript.
- ootachi 15y agoPython is much harder to make fast due to its highly dynamic nature. (Yes, Python is a much more dynamic language than JS -- see del(), locals(), code objects, etc.)
- MostAwesomeDude 15y agoThe work has already been done; see PyPy (http://pypy.org/ http://pypy.org/).
- beagle3 15y agoI'm not sure how locals() or code objects makes Python much more dynamic than JS -- even on it's own, but especially since it very rarely appears in idiomatic python code. Nothing in Python comes close to the dynamic mess that is JavaScript's "with" (bindings in Python are lexical; "with" makes bindings in JavaScript dynamic!) Even if you were right, you could still make code that doesn't use these features fast, and slow back to interpreted if any of these features is used -- that's what JS JITs do when they see "with". And finally, Lua is as dynamic as Python (both of which are, in my opinion, less dynamic than JS thanks to lexical binding). And Lua has been made significantly faster than any Python or JS implementation (Mike Pall's LuaJIT2)