Teaching Programming
Dave Angel
davea at ieee.org
Tue May 4 12:22:08 EDT 2010
Ethan Furman wrote:
> <div class="moz-text-flowed" style="font-family: -moz-fixed">Andre
> Engels wrote:
>> On Tue, May 4, 2010 at 4:35 PM, James Mills
>> <prologic at shortcircuit.net.au> wrote:
>>> On Wed, May 5, 2010 at 12:21 AM, Ed Keith <e_d_k at yahoo.com> wrote:
>>>> To deal with indentation I had to
>>>>
>>>> 1) keep track of indentation of all chunks of code embedded in the
>>>> document and indent inserted chunks to the sum of all the
>>>> indentation of the enclosing chunks.
>>> In my experience of non-indentation sensitive languages
>>> such as C-class (curly braces) it's just as hard to keep track
>>> of opening and closing braces.
>>
>> Although I have little or no experience with this, I still dare to say
>> that I don't agree. The difference is that in C you do not _need_ to
>> know where in the braces-defined hierarchy you are. You just embed or
>> change a piece of code at the right location. In Python however you
>> _do_ need to know how far your code is to be indented.
>
> And how do you know where the right location is? You have to figure
> it out from the different (nested) braces at the 'right' location.
> For me, at least, it's much easier to get that information from the
> already indented Python code, as opposed to indenting (and
> double-checking the indents) on the braces language.
>
> ~Ethan~
>
>
Much more important to be able to read code reliably than write it quickly.
When I was heavily doing C++ I found myself wishing that incorrect
indentation would be an error or at least a warning. And I hadn't ever
heard of Python. When I did, I said "About time!"
Of course, I was surrounded by many programmers who ignored any warning
that the compiler produced, while I cranked up warnings to max, with
pedantic.
On one project I generated C++ code, about 20k lines. And it was all
indented and commented. Most of that code went through the code
generator twice. The "source" was a header file from outside my
organization. The generator used that to create a new header, more
detailed. Then the generator used that to create source & headers that
were actually used by the project.
DaveA
More information about the Python-list
mailing list