Both these languages seem extremely similar to me. Although Python supports actual classes instead of being prototype-based, in Python classes are not all that different from functions that generate objects containing values and functions, just as you'd do in JavaScript. On the other hand, JavaScript only supports floating-point numbers and strings as built-in data types.
These seem like fairly shallow differences to me, so these things aside, what are some more important differences between them?
Python makes it simple to read and maintain code. Because of its flexibility, Javascript does not provide easy code readability or maintainability. To run Python code, you'll almost always need an interpreter. The ability to run Javascript code is built-in to most web browsers.
Python's "object-based" subset is roughly equivalent to JavaScript. Like JavaScript (and unlike Java), Python supports a programming style that uses simple functions and variables without engaging in class definitions.
Python uses dynamic semantics, meaning that its variables are dynamic objects. Essentially, it's just another aspect of Python being a high-level language. In the list example above, a low-level language like C requires you to statically define the type of a variable.
In fact, the two languages complement each other. Javascript is used as a client-side scripting language, whereas Python is mostly used as a server-side scripting language.
var
keyword in Python, implicit globals in ECMAScript, both are lexically scopedundefined
in Python, exceptions are thrownswitch
statement in Python but instead you're encouraged to use a dictionary in that manner, sometimes its convenient assigning properties to lambdas and executing themyield
statement, nor let
expressions/statements, nor array comprehension
s - however these are included in Mozilla's JS which is non-standardraise
vs throw
, except
vs catch
( Python, JS )and
, is
, and not
are used in Pythoni++
Object.prototype
new
operator in Python to create objectsI stole a good bit of info from http://hg.toolness.com/python-for-js-programmers/raw-file/tip/PythonForJsProgrammers.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With