Experiences/guidance on teaching Python as a first programming language

Devin Jeanpierre jeanpierreda at gmail.com
Wed Dec 18 03:33:54 CET 2013


On Tue, Dec 17, 2013 at 4:32 PM, Roy Smith <roy at panix.com> wrote:
> There's very few mysteries in C.  You never have to wonder what the
> lifetime of an object is

Yes you do. Lifetimes are hard, because you need to malloc a lot, and
there is no defined lifetime for pointers -- they could last for just
the lifetime of a stack frame, or until the end of the program, or
anywhere in-between, and it's impossible to know for sure, and if you
get it wrong your program crashes. So there's all these conventions
you have to come up with like "borrowing" and "owning", but they
aren't compiler-enforced, so you still have to figure it out, and you
will get it wrong. Successors like C++ mitigate these issues with
destructors (allowing heap-allocated stuff to be tied to the lifetime
of a stack), and smart pointers and so on.

> , or be mystified by which of the 7 signatures
> of Foo.foo() are going to get called

C still has overloaded functions, just fewer of them. It'll still
mystify you when you encounter it, though.
http://www.robertgamble.net/2012/01/c11-generic-selections.html

> , or just what operation "x + y" is
> actually going to perform.

I don't know. Will it do float addition? int addition? size_t
addition? How does coercion work?

+ can do many different things, it's not just a straight translation
to an obvious machine instruction.

> If you maim yourself with a razor-sharp chisel, do you blame the chisel
> for being a bad tool?

If I didn't need it to be that sharp, then yes.

-- Devin



More information about the Python-list mailing list