From: Paul Prescod Date: 2001-10-26T12:36:27+09:00 Subject: [ruby-talk:23394] Is Python rigid? I want to clear up what I believe is a misconception because these things have a way of turning into "common wisdom". Sean Russell wrote: > > Emiliano wrote: > > >> Why is it more important? To enforce a certain coding format? Example? > > > > Yes, to enforce a certain coding format. I'm no great fan of python > > myself, but one of the downsides (for me) of Perl & Ruby is the utterly > > There is always a balance between maintainability and productivity. I > still believe that the source of Pascal's failure was the obnoxious > rigidity. Python drops the rigid typing, but keeps rigid syntax, which is > the my main pet peeve about Python. What do you find so rigid? I think that maybe you haven't looked at Python deeply enough. Python has many flaws and some of them are corrected by Ruby. But Python's lack of syntactic flexibility can hardly be called a flaw if you judge it against, let's say, C, C++, Python, Java, Smalltalk, VB, Scheme or most other languages. (I'll leave aside the issue of Lisp, which is incredibly inflexible in one sense and incredibly flexible in another) In fact, a dirty little secret is that Python is so flexible that many of the arguments that it is good because it enforces a coding style are exaggerated. What especially shocks me is that you could argue that Python is obnoxiously rigid and then in another message say that you like Java! Consider translating some of this code into Java: j = [(x,y,x*y) for x in range(0,10) for y in range(0,20)] You want an arbitrary block indention in Python? if "dbblock": db.connect() a = 5 b = 6 db.disconnect() You want to put two statements on a line in Python? The syntax is almost the same as Java: temp = x; x = y ; y = temp But then you don't have to do that in Python: x,y = y,x How about this sweet bit of syntax: if 2 < i <= 5: print i (notice that I CAN put the statement suite on the same line as the statement) Let's say you're tired of Python's verbose regular expression matching syntax: from re import findall as f >>> f("b", "abcdefg") Python does not enforce an indentation width any more than other languages: if 1: if 2: if 3: if 4: if 5: if 6: if 7: if 8: print "a" if 8: if 7: if 6: if 5: if 4: if 3: if 2: if 1: print "b" I could argue that this should NOT be legal but it is. Python has getter/setter methods, operator overloading, syntactically meaningful iterators and sequences and generators. Once again, this is so far from anything that can be done in Java, C or any other mainstream language that at best we can say that on a "syntactic flexibility" scale, Tcl, Rebol and other "define your own syntax" languages are a 10, Perl and Ruby are somewhere around 9, Python is somewhere around 8, C++ (with operator overloading) around 6, and Java is probably at about 2. At least you can choose whether to use upper or lower case characters. Sean Russell wrote: > >... > > Ahh, but with Linux, if you *really* wanted to, you could make the change > yourself. Python is to Ruby as Windows is to Linux, and this is *exactly* > my point about local control. Between this comment and others about a) how Python doesn't offer much over Java for large projects (only 3-1 LOC compression) and b) how it is acceptable for Ruby to enforce naming conventions but not for Python to enforce indentation conventions, etc. I find it hard to feel that you did a reasoned evaluation of Python. Paul Prescod