Python is readable

Albert van der Horst albert at spenarnc.xs4all.nl
Tue Mar 20 08:20:02 EDT 2012


In article <mailman.795.1332131633.3037.python-list at python.org>,
Chris Angelico  <rosuav at gmail.com> wrote:
>On Mon, Mar 19, 2012 at 12:23 PM, Steven D'Aprano
><steve+comp.lang.python at pearwood.info> wrote:
>> On Mon, 19 Mar 2012 09:02:06 +1100, Chris Angelico wrote:
>>
>>> On Mon, Mar 19, 2012 at 8:30 AM, John Ladasky <ladasky at my-deja.com>
>>> wrote:
>>>> What I would say is that, when PROGRAMMERS look at Python code for the
>>>> first time, they will understand what it does more readily than they
>>>> would understand other unfamiliar programming languages. =A0That has
>>>> value.
>>>
>>> This is something that's never truly defined.
>>
>> I'm sorry, I don't understand what part of John's sentence you mean by
>> "this". "Programmers"? "Value"? "Understand"?
>
>I should have rewritten that into the next paragraph. Anyhow. Further
>explanation below.
>
>>> Everyone talks of how this
>>> language or that language is readable, but if you mean that you can look
>>> at a line of code and know what *that line* does then Python suffers
>>> badly and assembly language wins out;
>>
>> This is at least the second time you've alleged that assembly language is
>> more readable than Python. I think you're a raving nutter, no offence
>> Chris :-)
>
>None taken; guilty as charged. And unashamedly so. With that dealt
>with, though: My calling assembly "readable" is a form of argument by
>drawing to logical, but absurd, conclusion - by the given definition
>of readability, assembly is readable, ergo the definition sucks.
>(That's a term all logicians use, you know. Proper and formal jargon.)
>
>> Assignment (name binding) is close to the absolute simplest thing you can
>> do in a programming language. In Python, the syntax is intuitive to
>> anyone who has gone through high school, or possibly even primary school,
>> and been introduced to the equals sign.
>>
>> x =3D 1234
>> y =3D "Hello"
>
>Not quite. In mathematics, "x =3D 1234" is either a declaration of fact,
>or a statement that can be either true or false. In mathematics, "x =3D
>x + 1" is absurd and/or simply false. That's why Pascal has its :=3D
>operator, supposed to be read as "becomes" and not "equals". IMHO this
>is simply proof of one of the differences between programming and
>mathematics.
>
>> I don't know about anyone else, but I wouldn't have guessed that the way
>> to get x=3D1234 was with "x dw 1234".
>
>Except that it's not quite the same thing. That 8086 Assembly
>statement is more like the C statement:
>int x=3D1234;
>The nearest equivalent of assignment is:
>mov x,1234

I tried to mentally translate that to my ciasdis assembler syntax
and discovered that there is no instruction in the 8086 for that.
It would require using a scratch register like AX.

In my very precise ciasdis assembler syntax it would be  1]
XXXXXX: DL 0
MOVI, X| R| AX| 1234 IL,
MOV, X| F| R| [AX] XXXXXX L,

If you were restricted to the 8086, (not 80386 or better)
you could not have chosen AX, and you would have used BX instead.
[ The first MOVI, could be replaced by a LEA, instruction
LEA, AX'|  MEM|   XXXXXX L,
(Go figure!) ]

So a realistic fragment could have been
        PUSH|X BX,
        MOVI,  X| R| BX| 1234 IL,,
        MOV,   X| F| R| [BX] XXXXXX L,
        POP|X  BX,

The real unreadability comes from the fact that the novice would
ask herself why on earth the BX register was freed while the AX
register was free to use. And she is lucky, because no flags
were harmed in this sequence, another pitfall.

You can't blame me for the unreadibility of the ciasdis-syntax.
It merely reflects the abomination that the 8086/80386/Pentium
is.

Bottom line. A comparison between a HLL where the goal is abstraction
and assembly where the goal is precision and control, is unproductive.
And if you insist to do it, you better be a real expert.

<SNIP>

>
>And that's where the nub of the question is. How well is sufficiently
>well? Clearly you do not require your code to be comprehensible to a
>non-programmer, or you would not write code at all. If you don't
>demand that the reader learn basic keywords of the language, then it's
>equally impossible to expect them to comprehend your code. If you're
>writing production code, I see no reason to avoid language features
>like Python's list comps, Pike's %{ %}  sprintf codes, or C's pointer
>arithmetic, just because they can confuse people. Learn the language,
>THEN start hacking on the code.

Can we just agree, that it is a compromise?

>
>ChrisA

1] ciasdis.html on the site in my sig.

Groetjes Albert

--
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst




More information about the Python-list mailing list