A pensioner learns Python

When I was younger, I thought of myself as a pretty good programmer. I started with Algol 60 in 1970 and since then have learned (and forgotten) lots of programming languages. But as my career developed and interests evolved, I spent more time managing people who programmed rather than programming myself and focusing on software requirements and use rather than on development issues. So, I haven’t written any significant programs for many years, with Java the last programming language that I learned about 15 years ago. But, I have always enjoyed programming so now that I’m retired, I decided to see if I could revive my old programming skills.

I never liked Java – it always seemed to me to be a wordy and inelegant language (compared, for example, to Pascal) and I had no wish to program in that language.  I flirted with Ruby but finally decided on Python – it’s a popular language (the 4th most popular according to this survey) and used as the programming language for the Raspberry Pi – the small, ultra-cheap computer that I fancied playing with. Python is a dynamically typed, interpreted language – completely different from Java.

So I started learning Python about 10 days ago and so far have written a few hundred lines of code. My experience is that you can learn enough of a programming language  in a week (if you understand the basic structures, it’s really just an issue of syntax and idiosycrasies) to write useful programs but it takes several months (and thousands of lines of code) to be completely ‘fluent’ and proficient in that language. Python was no different. I had written my first program (bubble sort) within a couple of hours of getting started and, although I still forget to include some of these damned colons, I’m reasonably confident in the basic functionality of the language (but haven’t yet tried some of its more esoteric features).

So, coming from a background in reliable systems, what are my impressions of the language:

1.    It’s a very productive language – you can do a lot with only a few lines of code. It does encourage a ‘program by experiment’ approach to development rather than thinking it through in advance but that’s no bad thing when you are learning a new language. It means you are less likely simply to work in the structures of the language that you already know.

2.     Part of the productivity comes from lots of built-in operations e.g. on strings. But these seem rather arbitrary and simply are ‘things that might be useful’ rather than a coherent and orthogonal set of functionality. I found myself programming operations then sometimes discovering there was a built-in function to do the same thing.

3.     The use of whitespace as a bracketing device is incredibly error-prone. This has been the major source of problems for me as I changed things and forgot to change the indentation. Maybe this could be solved with a better editor but essentially it was a stupid and unnecessary design decision.

4.       My experience with statically typed languages means that I’m suspicious of the dynamic typing and I certainly haven’t used it in a constructive way. I find myself writing str (X), list (X), etc. just to be completely sure that a variable is the type that I expect. Learning to be comfortable with dynamic typing will, I suspect, take some time.

Overall, I’m impressed but with reservations and I’ll certainly be continuing to use the language. I think that programming is possibly a bit like swimming in that once you learn, you never really forget – you just get slow and rusty. I’m at that stage but over the next few months, I hope to get a lot better and more ‘Pythonic’. I’ll post again in a few months about my experiences.

One thing I am completely convinced of, however, is that we would be much better teaching Python rather than Java as an initial programming language. All of this ‘public static Class’ crap is completely confusing for beginners. I think abstraction and program structuring are things that come later and it’s far better to design a programming curriculum around programming by experiment so that students can get immediate gratification and see progress being made.

3 thoughts on “A pensioner learns Python

  • November 30, 2015 at 2:02 pm

    Dr. Sommerville you made a good decision. Python is definitelly better for beginners than Java. I don’t like Java much myself but as much as i hate to say it has so many enterprise grade tools other languages like C++ and PHP are missing…

  • November 30, 2015 at 11:12 pm

    I want more professors and schools to read this and start using Python as the starting language. Programming by experiment is the best way to learn a new language, but sadly the schools I’ve studied in are still stuck in 70s way of teaching, all learning, no practical application.
    Great post, loved it!


Leave a Reply

Your email address will not be published. Required fields are marked *