[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Programming Languages, "to C or not to C, that is the Q."



Peter Robinson wrote:
You are picking an example that is unlikely to be seen in many programs and
 which is not typical of most programs that I have written or seen.

    No.  I picked a fairly common example one that I use quite frequently.
Dereferencing a variable which itself is pointed to by a variable.  IE,
passing a reference to a subroutine.

You may have forgotten the learning stage which I am sure you went through
 when you first saw Python.

    No, I haven't.  I remember it quite clearly.  It was a 3-4 hour long
seminar at the O'Reilly conference in Monterey.  I believe it was 2000.  It
was presented by David M. Beazley, author of "Python: Essential Reference", a
book I use to this day ven though it is several versions out of date.  He
started with the basics and by the end of the seminar was covering threading.
Python, never, was a mystery to me.  It was quite liberating because it
addressed pretty much every vile and putrid thing about Perl that I loathed.

I do not know Python, but I recently tried to decipher a few scripts in Python and was not able to grasp quite a few things.

The hardest thing to grasp in Python if one is coming from a Perl background is slices. That's it. Everything else is pretty much common without the large mess of line noise to go with it.

> There are apparently many elements not common to other
> languages

Not really. There are elements removed (braces and semicolons being prime) but pretty much everything else maps well to concepts common in all languages.

> (don't you have to follow a certain standard indentation for instance?).

Yes, blocks are denoted by indention. However unless one is in the practice of writing Perl (or C, or Pascal, or...) without intenting their blocks this is a non-problem. Blocks in those languages are there to make the code human readable. Ultimately that is the goal for maintainable code. Python simply makes that the block structure for the language instead of having a separate block structure for the machine.

    For example in Perl one might do this:

if (foo) {
    bar();
} else {
    baz();
}

    In Python it is:

if foo:
    bar()
else:
    baz()

Same code, same indention, same condition, same branch structure, same way to call a function the only difference is in Python the indention tells the machine and the human what's going on whereas in Perl the {}s are for the machine and the 4 spaces are for the user.

That's the beginning, end and totality of Pythons mysterious and controversial indention.

I wound up googling a bit more
until I found the same thing in C -- which I understood without problems
because I am familiar with C. What does that prove? -peter

That you're inflexible when it comes to common coding concepts as they map into other languages?

--
         Steve C. Lamb         | I'm your priest, I'm your shrink, I'm your
       PGP Key: 8B6E99C5       | main connection to the switchboard of souls.
-------------------------------+---------------------------------------------

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: