6 ms·
For all the positives of JavaScript, I still prefer Python. There are a lot of similarities, but I give Python higher marks in a few areas. The first one that j
by mkramlich 17y ago
For all the positives of JavaScript, I still prefer Python. There are a lot of similarities, but I give Python higher marks in a few areas. The first one that jumps out immediately is the lack of requiring "var" in Python variable declarations. What I'd like to see instead I think is Python built-in to every major browser as a default language. And/or make it super easy for users to install runtime plugins for Python, Ruby, etc. that way we're not limited to a particular language in the browser client.
- baddox 17y agoI bet as soon as you attempt to implement a DOM manipulation standard for Python you'd introduce all the same cross-browser incompatibilities as Java has. Also, in many ways Javascript is superior to Python. Closures are the only examples I know of off the top of my head.
- mikeklaas 17y agoPython has as much support for closures as javascript. The only significant feature in this respect that it is missing (that I am aware of) is multi-statement, in-expression lambdas. Javascript's syntactic nicety is higher there, but on balance I think python's is far superior. Both great languages, though.
- infinite8s 17y agoAlthough python's lexical scoping is all screwed up (python 3.0's nonlocal keyword fixes this, but it is still ugly).
- baddox 17y agoLast year my Languages instructor mentioned that there was some problem or incompleteness with closures in Python because Guido didn't want to fully implement it or something. Perhaps I'm mistaken.
- mhansen 17y agoJava != JavaScript
- baddox 17y agoI meant Javascript. I just typed the wrong name, but I didn't confuse the two languages.
- orangecat 17y agoYeah, I don't get the recent Javascript love-fest when Python and Ruby (heck, even Perl) are tremendously superior. Mainly due to lacking insane design decisions like default global scope and having standard libraries that are actually useful. I mean, did it not occur to anyone that a language heavily used for processing user input might benefit from String.trim? And you'd think a language built on key-value pairs would come with a hashtable object. Yes I'm probably ranting; I've spent a large portion of the last 12 hours writing a bunch of Javascript that I really shouldn't have had to.
- util 17y agoDon't objects function as hashtables? var v = {"a": 1};
- arethuza 17y agoI think the only real restriction is that you can't use arbitrary objects as keys - only strings or things that easily convert to strings (such as numbers). See: http://ajaxian.com/archives/true-javascript-hash-table http://ajaxian.com/archives/true-javascript-hash-table Personally, I've never really regarded this as much of a problem.
- cracki 17y agopython's variable scoping is useless. i can't reassign a variable in an upper context. i can mutate the object it refers to, but i can't reassign the variable right there. instead it gets instantiated at the current level. that's why javascript has "var". it has real lexical scoping. IIRC python 3 has the "nonlocal" keyword to "fix" this mess, but i'm not pleased by that. i read the PEP and understand their reasoning. still, it's different behavior from what other languages do (notably scheme and js). they can't even make proper lambdas, but that's because they painted themselves into a corner with the syntax. a freeform mode for python might solve the lambda issue... but then we'd have ruby or javascript, pretty much. what tips the scales for me (i use python most) is libraries and environment. javascript doesn't yet have a real command line scripting experience. microsoft's windows scripting host and jscript come close, but all the library documentation is scattered throughout MSDN. i much prefer python's HTML documentation. it's terse and easy to browse.