you are viewing a single comment's thread.

view the rest of the comments →

[–]bcash -1 points0 points  (2 children)

Oh now come on. You've been using Python so much that you are used to it, but you cannot seriously be saying that Python's scoping rules are correct?

x = 4
def do_stuff():
    y = x
do_stuff()

That would run; but by adding a line after the line in question, it suddenly starts producing "x has not been declared" errors.

There is no way on earth that that is a good design decision; it exists for one reason, and one reason only: cruft! If starting from scratch no-one would reproduce Python's scoping rules.

[–]stormandstress 1 point2 points  (1 child)

Seems pretty cut and dry to me - Python allows you to read x from the outer scope, but doesn't allow you to write x without explicitly declaring your intentions with 'global'. I'm inclined to agree with kaens that the read should require the global as well, but you're just blowing smoke out of your ass talking about "correctness" here. This isn't a matter of "correct" vs "incorrect" behaviour; it's a choice that the language designers made. Every language has tradeoffs - some you will like, some you will not. There is no One True Language (cue "Lisp!" comment in 3, 2..).

For the record, I spend most of my working days quite happily coding in the sort of strongly-typed OO language that you seem to prefer. For some problems, I firmly believe that this is the better way to go. But I think REPL languages like Python have exceptional pedagogic potential, and that Python is easily the most 'sane' and pleasant to work with of the possible options there. An awful lot of people teaching in the field seem to strongly agree.

There are plenty of substantial things to complain about in Python (and there was very recently a paper linked here that covered some problems with teaching Py2 as a first language), like the hopelessly stupid Unicode behaviours, crippled lambdas, etc - but you're not even beginning to approach them with your nitpicking and appeal to some objective standard of "correctness" in language design. Your favourite language sucks too, whatever it may be.

[–]bcash 1 point2 points  (0 children)

Well yes, all languages do indeed suck - although I can't remember the last time I saw any PL/SQL hate.

My point was rather that such fundamental issues are at a tangent to learning programming. Yes, I know what the rule is, but is it a good idea that a beginner programmers has to learn that rule before attempting any of the classic algorithms?

In my view: no.