Python is readable

Steve Howell showell30 at yahoo.com
Wed Mar 21 17:30:07 CET 2012


On Mar 21, 9:22 am, Evan Driscoll <drisc... at cs.wisc.edu> wrote:
> On 01/-10/-28163 01:59 PM, Steve Howell wrote:
>
>
>
>
>
>
>
>
>
> > Code shouldn't necessarily follow the example of English prose, but it
> > seems that English has had some influence:
>
> >   1  push(stack, item) # Push on the stack the item
> >   2  push(item, stack) # Push the item on the stack
> >   3  stack.push(item)  # On the stack, push the item
> >   4  stack item push   # On the stack, take the item and push it
> >   5  item stack push   # Take the item and on the stack, push the
> > former.
> >   6  item push stack   # Take the item; push it on the stack.
>
> > The first three ways are the most common ways of arranging the grammar
> > in mainstream programming languages, and they are also the three most
> > natural ways in English (no pronouns required).
>
> > #1/2 are imperative.  #3 is OO.
>
> In my opinion, people who make statements such as "#1/2 are imperative,
> #3 is OO" are missing pretty much the entire point of what OO is.
>
> OO is much more about semantics and the way code is structured. The
> difference between #1/2 (especially #1, of course) and #3 is
> surface-level syntax only.
>
> About the strongest statement you can make along those lines is that #3
> will allow you to do dynamic dispatch on the type of 'stack' while #1/2
> won't, but even that isn't true of course. For instance, CLOS will let
> you write '(push stack item)' (which is the direct analogy in that
> language to #1) and do even more powerful dynamic dispatch than what a
> language like C++, Java, or Python will let you do.
>

In the grand scheme of things, of course code structure and semantics
are more important the surface-level syntax.

If you take it as a given that structure/semantics are sound (big
assumption, I know), then the next issue with regards to "readability"
is the syntax itself.




More information about the Python-list mailing list