4 ms·
To me as a Lisp user, Python breaks more than it fixes. Lexical scoping? Nope, can't have it. Code as data, data as code? Not really. Literals for data? Compila
by jpr 16y ago
To me as a Lisp user, Python breaks more than it fixes. Lexical scoping? Nope, can't have it. Code as data, data as code? Not really. Literals for data? Compilation to native code? Compiler/interpreter warnings? Warnings for name collisions when importing? Standard for the language? Nope.
And I don't really buy the argument that Python is simple and clean. It has multiple inheritance, metaclasses, operator overloading, decorators and whatnot. Also the type system is broken, a deriving class can define an overriding method that has incompatible signature, rendering isinstance powerless (yes, I know you probably shouldn't use isinstance much anyway, but dammit, it should at least mean something).
- jrp 16y agoI agree. I first learned to program in Python and then started learning about other languages with more options enabled. Coming from a Lisp to Python would have felt strange. Maybe worth it to use a nice library or program?
- stcredzero 16y agoAnd I don't really buy the argument that Python is simple and clean. Yes, but consider the competition. Python is a significant margin above average, but this says as much about the sorry state of computer languages in general as it says about Python. Heck, English is considered an "easy to learn" language among human languages, and it's a mess! Really the problem is with human beings.
- queensnake 16y ago(More specifically, English is said to be "easy to learn, hard to master" (because as you say, it's a mess).)
- zephyrfalcon 16y agoPython does have lexical scoping though. The only difference with languages like e.g. Scheme is that you cannot rebind variables in the enclosing scope.
- koenigdavidmj 16y agoYou mean like this? (define x 3) (let ((x 38)) (display x) (newline)) 38 Actually, you probably meant that this doesn't work: (define x 3) (begin (define x 38) (display x) (newline)) 38 (display x) (newline) 38 ; we want 3 here EDIT: fix formatting
- zephyrfalcon 16y agoMore like this: def f(): x = 1 def g(): x = 2 # creates new local variable x # no way to assign new value to x in enclosing scope!
- count 16y agoI'm probably naive for even asking, but why would you want to be able to change the value of x in the enclosing scope, unless you passed in a reference to it to g() (which doesn't exactly even work, as Str and numericals are immutable). If you had to change the value of X, make it a return value of G and assign that within the enclosing scope. I view this as a benefit - less accidental stamping on variables/etc. I wouldn't consider myself A+ #1 programmer by any stretch though. This sort of thing seems like it would enable too many 'side effects' though.
- zephyrfalcon 16y agoLispy languages like to use this construct for all kinds of purposes. See the appendix at the end of http://paulgraham.com/icad.html http://paulgraham.com/icad.html for examples. You can do this in Python too, but it requires a bit more work. Python is asymmetrical here; you can see a variable in an enclosing scope, and if it's a mutable object you can change it, but you cannot reassign the name.
- koenigdavidmj 16y agoPython 3 lets you use the statement 'nonlocal varname' and it will grab it from the outer scope, as well.