Experiences/guidance on teaching Python as a first programminglanguage

Discussion in 'Python' started by Oscar Benjamin, Dec 9, 2013.

  1. Hi all,

    I work in a University Engineering faculty teaching, among other
    things, programming. In our last meeting about improving our teaching
    syllabus and delivery we've identified the first year programming
    courses as an area where there is room for improvement and we're
    considering (mainly on my suggestion) switching to using Python as the
    first programming language that we use to introduce our students to
    programming. I'm interested to know if anyone can share experience of
    a similar situation or can point to any case studies about this.

    The course is for ~100 1st year students with half studying
    Engineering Mathematics and the other half Electrical Engineering.
    Currently we introduce programming with C for the 1st semester and
    then C++ for the 2nd semester. In the 3rd semester they learn Matlab
    and following on from that they can take optional units run by the CS
    department in Java, Haskell and many more. Our faculty does not
    currently offer any Python courses for students at any level in CS or

    Many of the students complain that the C course is too hard and my
    experience is that it doesn't equip them with the general
    understanding of programming that we really want them to get from the
    first programming course. I'm not sure about the Electrical
    Engineering students but the Engineering Mathematics students tend not
    to use C/C++ once they have covered Matlab and just use Matlab for all
    future projects, including in situations where it is highly

    In our recent meeting I proposed that Python should be the first
    programming language, and others proposed that Java should be the
    second. So we're currently evaluating the option of having Python in
    the first semester followed by Java in the second. Both courses would
    have to be created from scratch meaning that we would need to draw a
    complete outline and syllabus by mid-January in order to roll this out
    for the next academic year.

    I think that the benefits of this would be that using an "easy"
    language would be less distracting while we introduce the general
    concepts of programming. What we really want is for the students to
    focus on things like "why would I write a program?", "what kind of
    things can I do with a program?" and "how would I go about writing a
    program that does X?". Ideally by the end of the course we want that,
    given a description of a simple command line program that would
    perhaps calculate something or do some simple data processing, then
    the students would feel confident that they could do that. I think
    that using C distracts them from learning these more important general
    lessons as they struggle with simple things like how to print output,
    or avoid segmentation faults. Also ideally they would continue to use
    the language, where appropriate, for subsequent project work (which is
    when they would *really* learn the language).

    Some of the objections to the idea that were voiced in the meeting were that:
    1) Some people felt that Python is not an "industry standard" unlike
    C/C++/Java and that it is not as good for employability.
    2) Students should learn to program in a statically typed language
    because it leads to good programming discipline.
    3) Python is too close to Matlab (which is considered essential for
    some industries our students often go in to).
    4) It is better for students to be introduced to programming with a
    low-level language so that they gain a better understanding of how
    computers "really work".
    5) Learning to program "should be painful" and we should expect the
    students to complain about it (someone actually said that!) but the
    pain makes them better programmers in the end.

    I'm particularly interested to know if anyone can share experience of
    switching to teaching Python as a first programming language in a
    similar context. A written up case study that I could circulate among
    the relevant staff would be especially useful.

    Thanks in advance,
    Oscar Benjamin, Dec 9, 2013
    1. Advertisements

  2. Oscar Benjamin

    rusi Guest

    1 Some Background

    Early in my teaching career - 1988 -- I experienced what it means to
    switch from Pascal to Scheme to teach programming. And in 2002 I
    swtiched to using python. I may talk a bit about this but before

    2 Some Philosophical Context

    Some years ago I read in a book (I think it was called "Heart of
    Philosophy") about the difference between 'ideas' and 'concepts.'
    Ideas are large vague touchy-feely things like freedom, love, justice
    etc; things that matter but poets deal with better than intellectuals.
    Concepts are the basic currency for an academic. In a typical 1-hour
    class you deal with a few and in a lifetime you deal with thousands;
    in short they are a dime a dozen -- especially if you are an academic.

    And yet if you have a conscience you'd know that covering the concepts
    specified in a formal printed syllabus is cheating. What really needs
    to be conveyed are a few ideas:
    - modular code
    - code invariants
    - abstractions
    - Syntax, semantics and the large grey in between which for want of a
    better word we may call 'structure'
    - Recursion much wider than people think
    see http://blog.languager.org/2012/05/recursion-pervasive-in-cs.html
    - Interpretation
    see http://blog.languager.org/2013/08/applying-si-on-sicp.html
    - Computable and non-computable
    - The meaning and significance of the word 'code'
    - (Even more vaguely) beautiful (and ugly) code

    Before reading on, I suggest you think what for a while what for you
    are important/core ideas and then what vehicles/mediums are
    conducive/obstructive to them.

    3 My Prejudices

    Historically I've been associated with functional programming. While I
    am not so passionate about it as when I was half my age. still I'd

    - FP *as a philosophy* collects a bunch of stuff -- technology,
    practices, culture -- that conduces to good programming even for
    kids who after the course never use FP *as a technology*

    See http://blog.languager.org/2012/10/functional-programming-lost-booty..html

    - By contrast OOP is mostly (at best) clerical common sense --
    organizing libraries to be easily searchable is better by data than
    by code. At worst OOP is hogwash -- inheritance.

    And so…
    - Python which can be quite functional, imperative and object oriented
    has a rather special place. Because it is object oriented you will
    be able to use it to silence those who are subscribed to that
    religion. Because it is imperative you can write straightforward
    code -- 'scripts' -- without undue fanfare Because it is functional
    (well almost -- I have some beefs in this regard) you can use it as
    a vehicle to actually convey important *ideas* in short space and

    - For me Lisp (closely followed by APL) are the ultimate in
    programming paradigms. However they are not serious technology in
    2013. [Even the birthplace of Scheme -- MIT -- has switched to
    python]. And so in 2013 python occupies a sweet spot in the sense of
    being academically clean and realistically usable.

    - That said there are some important elements of FPLs, most notably a
    polymorphic type discipline, that are sorely missing from python.
    Unfortunately Haskell is much harder to teach/learn than python and
    with each new addition only gets harder. So python remains even
    with its lacks, an academically sound language.

    4 CS-Edu Writings

    My CS-101 syllabus from the early 90s --
    uses gofer a predecessor of a predecessor of Haskell

    Some more general CS-Edu related writings, containing strewn about
    "FP is a good idea"
    and following 2 posts
    rusi, Dec 9, 2013
    1. Advertisements

  3. Oscar Benjamin

    rusi Guest

    Yeah this will get some people's back up -- Atrocious! Preposterous! etc

    Change the word 'pain' to 'taxing' 'hard' 'challenge' etc and there is much
    truth in it. Here is Joel Spolsky on why Java is a poor language for
    this reason: http://www.joelonsoftware.com/articles/ThePerilsofJavaSchools.html
    rusi, Dec 9, 2013
  4. That's like saying that when teaching woodwork we shouldn't
    let people use hammers, we should make them use rocks to
    bang nails in, because it will make them better carpenters
    in the long run.
    Gregory Ewing, Dec 10, 2013
  5. But in teaching woodwork you SHOULD let people use basic tools, and
    not just a CNC lathe. Or in the most extreme sense, putting together
    IKEA furniture is not carpentry, and neither is picking from an
    extremely limited toolbox programming - which is why "Build a program
    without writing a line of code" systems are junk for anything
    complicated. (Occasionally, VERY occasionally, it's possible to use
    the simple drag-and-drop system to get you 90% of the way, and then
    fill in the rest yourself. Usually, you'll end up fighting the system
    as soon as you do something the author didn't intend.)

    Programming shouldn't be painful just for the sake of making it
    painful. But you should be programming, not just solving a Sudoku
    puzzle. It should be possible for a programmer to develop a unique
    program that does a unique thing, and if that's beyond the scope of
    the system, the system isn't a programming system. (Might still be a
    useful system, of course, but it's not programming.)

    Chris Angelico, Dec 10, 2013
  6. That's the only point I was trying to make. Pain in and
    of itself doesn't help anyone to learn anything!
    Gregory Ewing, Dec 10, 2013
  7. NAILS????

    Nails were verboten in my high school wood working class...

    We used dowels and glue; chisels to carve dove-tails; etc.
    Dennis Lee Bieber, Dec 11, 2013
  8. We were allowed to use screws, but they had to be brass, not steel, we
    had to drill appropriate clearance and pilot holes, and countersink where

    And god help you if you deformed the slot in a brass screw head by over
    tightening - I think that may have been why they made us use brass ones
    only, so that such damage was easier to spot and more likely to happen.

    And yes, I can dovetail, mortise and tenon, dowel etc etc etc.
    Denis McMahon, Dec 11, 2013
  9. Ohhhh we used to DREAM of using screws! We were given steel shafts and
    had to tap the threads into them with our teeth.
    Larry Martell, Dec 11, 2013
  10. GLUE???
    Grant Edwards, Dec 11, 2013
  11. Oscar Benjamin

    Neil Cerutti Guest


    You lucky BASTARD!

    We had to build bookcases out of banana leaves held together with
    our own spittle.
    Neil Cerutti, Dec 11, 2013
  12. I'm particularly interested to know if anyone can share experience of
    Just one experience from the "other" (student's) side.

    When I started to study engineering science in 1991, Pascal was the
    "first language" at the university in question (there were no
    programming classes at highschool over here at that time yet). The class
    was quite motivating and taught me some essential basics, I think.
    Although issues such as object-orientation or event-based (GUI)
    programming were not even mentioned, which is something that I'm
    desperately missing today.

    When I went to a different university (in 1993), still in engineering
    science, they used C as the "first language" in the class there. The
    result was that I tried (and succeeded) to pass that class with the
    strict minimum of effort possible and deliberately forgot everything
    that I had to learn about C as quickly as possible afterwards. I was a
    "very good" student back then otherwise, so this was not due to
    general laziness. What that class has taught me, essentially, was to
    *hate* C. And it was not an issue of bad teachers. And they didn't mean
    to make me hate C, after all, it was them who had chosen that language.
    I never ever used C for anything (outside of that class). And ever
    after that experience, I avoided all languages that were even remotely
    similar to C, such as C++, Java, C#, Javascript, PHP etc.

    In numerics classes and for research projects, I had to learn and use
    Fortran, which was easy after the introduction with Pascal. The
    teachers who taught me Fortran easily were the same as those who made me
    hate C.

    Then, I accidentally got in touch with Python (in 1994 iirc) and
    thought it was interesting and useful. In fact Python is the only
    programming language that I ever learned without being obliged to do
    so. And the only one that I keep using whenever I have the choice.

    Since then, the university that once used C as a "first language"
    has switched to Python. Which is a good thing, imho. If I had had to
    learn the basics of programming with C instead of Pascal, I most
    certainly would have avoided anything even remotely connected to
    programming ever since, even "office automation" through scripting
    (which is what I use Python for today).


    Wolfgang Keller, Dec 12, 2013
  13. I think that's disappointing, for two reasons. Firstly, C syntax isn't
    that terrible. You might prefer Python syntax to it, but it's
    undeniably better than several of its predecessors (I do not want to
    write in COBOL, tyvm!), and there are recent languages that manage to
    get some things so crazily backward (like abolishing operator
    precedence so 2 + 3 * 4 = 24 not 14) that I wouldn't want to use them.
    And secondly, C is very much the language of Unix. Sure, its best job
    is implementing high level languages so day-to-day code doesn't need
    to use it, but it's still important when you need to get to some
    lower-level facilities. For those two reasons, I think a basic working
    knowledge of C is useful for working with computers, networking,
    pretty much everything these days. It won't break your brain to
    understand multiple styles, and it might help you to remember why it
    is you love Python syntax so much :)

    Last time I had to do some C work, I was reminded just how amazingly
    convenient a high-level string class is... all I wanted to do was
    concatenate a bunch of strings with spaces between them, and I had to
    go through so many hoops!

    " ".join(list_of_strings)

    Et voila.

    Chris Angelico, Dec 12, 2013
  14. And ever after that experience, I avoided all languages that were
    It's not just the abysmally appalling, hideously horrifying syntax. At
    about everything about C is just *not* "made for human beings" imho.

    It's just an un-language that gets at about everything wrong. Sort of
    like Microsoft's products.


    Wolfgang Keller, Dec 16, 2013
  15. I've never heard C syntax reviled quite so intensely. What syntax do
    you like, out of curiosity?
    Ned Batchelder, Dec 17, 2013
  16. Oscar Benjamin

    rusi Guest

    I had a paper some years ago on why C is a horrible language *to teach with*

    I believe people did not get then (and still dont) that bad for
    - beginner education (CS101)
    - intermediate -- compilers, OS, DBMS etc
    - professional software engineering

    are all almost completely unrelated
    rusi, Dec 17, 2013
  17. Yes. In esr's essay on becoming a hacker[1] he says:

    """There is perhaps a more general point here. If a language does too
    much for you, it may be simultaneously a good tool for production and
    a bad one for learning."""

    Definitely true, though I think it has exceptions.

    [1] http://www.catb.org/esr/faqs/hacker-howto.html

    Chris Angelico, Dec 17, 2013
  18. Oscar Benjamin

    Rick Johnson Guest

    That could be a result of two possibilities:

    1. Your high school years were before the great war, or:
    2. Your wood shop teacher was a Luddite, a sadist, or both!

    FYI: Fastener technology has come a long way since the fall
    of the of the "Amish empire". All that laborious joinery has
    been surpassed by mass production of helical threads and
    pneumatic drivers. What once took a "master craftsman" an
    entire day to build could now be built by a novice in mere

    Dovetails are nothing more than sadistic nostalgia --
    they give old men a "chubby" and young men a nightmare.

    When are we going to realize that the goal, *ahem*, OUR
    GOAL, is to delegate minutiae DOWNWARDS, building the
    collective knowledge base layer by layer...


    Because, when you've got all your mental focus attuned to
    carving intricate inter-meshing teeth into dense hardwoods
    using razor sharp hand tools, you will be unable to see the
    big picture, and furthermore, you might slip and cut your
    finger off!
    Rick Johnson, Dec 17, 2013
  19. Oscar Benjamin

    Roy Smith Guest

    There is nothing more satisfying than cutting a set of dovetails by hand
    and having them glide together like silk, the first time you test-fit
    them, with no daylight visible anywhere.

    Someday, mine will be like that :)
    Roy Smith, Dec 17, 2013
  20. I suspect that your manual skills are rather better than mine. One of
    my favourite expressions, perhaps because I only ever heard my dad use
    it, is "like watching a cow handle a shotgun".
    Mark Lawrence, Dec 17, 2013
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.