Wanted: a strategy for teaching programming to newbies?

What is a good strategy for teaching a programming language to beginners?

I wasn’t a briliant student in any of the years I studied – I was lazy and better in finding records (vinyl) in record stores than actually studying – but I guess I was ok. Anyhow, I was kind of good in math (and history iirc). So I never encountered the problems that I have discovered among some of our students lately. This does not, and I don’t mean to, imply that I am smart and they are stupid. Studying lambda calculus now I appreciate my students’ problems better – so far I suck at lambda calculus so I cant’t be that smart!

Now, as a teacher, at a University I see a lot of frustration among students wanting, or are requested, to learn to program. Are the students stupid or is there something else that is incorrect? I’ve touched the topic before and will do so more in the future. My belief and my experience say the latter. So how do attack the problem of frustrated students? Tell them that they are doing university studies and they should get used to it? Well, to some extent it is true and perhaps important for students to realise, but I don’t think that’s the only way to go. So I want to get a bit deeper into the problems the students encounter. What are the main problems in learning how to program? Listing and discussing the main problems I think we can ask ourselves the question of what  a good strategy is.

Two main problems. One problem stands out, mathematical skills are required. Another one is the complexity of popular languages. I’ll try to go through the two problems below.

Mathematical background
Most languages, or rather the education (lectures, books, …) of it, require a mathematical background. Concepts like function and variable are assumed to be familiar to the reader.

Given the last two courses I’ve been involved in, where programming has been introduced to students with no thorough mathematical background I have understood via my own experience in supervising and listening to students but mostly via chats (not structured as proper interviews) with students that functions and variables are hard to grasp. How tolve this? I see two solutions

  1. Require a mathematical background for the course/program
  2. Try to find other means as a teacher. Be it the course literature, lecturing methods, dedicated tools.

Perhaps (1) is the only one that will work properly and this is used in programs where you end up as a computer science engineer. Doing (1) in a program for Applied IT or something similar where the students should not become cs engineers would perhaps make my life as a teacher easier but I think we will miss a lot of talented students – I don’t believe in a programming gene! I have met a lot of talents in students with no thorough math background. So for me it is interesting to look into (2). Fact is, I have been totally absorbed by this the last couple of weeks. I will write more about this, lots more… but I need to read, think (yes, sometimes I can think!), discuss and probe students a lot more.

Complexity of programming languages:

I have often showed a small piece of code to exemplify how complex a language is. At a conference in January I saw the same code presented by someone else to exemplify my point.. I can interpret this coincident in two ways – either I am clever or I need to study more literature on the subject since this is the canonical example. I’d go for the latter. Anyhow, lets look at the following piece of code;

int x=1;

Trivial isn’t it. Apart from the fact that isn’t if you were to explain everything behind the scenery. I think it would be fairly easy to postpone r-value and l-values and so forth. But if you tech Java, a popular language since the industry uses it, you have to write all the code below to simply output “Hello” on the stdout.

public class LeoSayer {
    public static void main(String args[]) {
        System.out.println("Hello");
    }
}

Now, this is complex. Ok, we can skip using the public keyword in the class. But still, class? static? public? void? main? String? args? []? System? System.out?

Of the code above I think only the println(“Hello”) would be easy to explain. But the rest?

….. As I see it we now have two options of explaining all the extra code:

  1. Still maintain that Java is easy to learn – but this is too hard to explain so just skip it.
  2. Saying Java is complex – so we need to skip it. Just accept.

How about explaining all the code? The students would leave the room before you’d come to the word static!

Note: I have written a small tool, that is too large to fit in the margin, that would remove most of the problems in the Java code above. More on this tool another day.

So clearly Java is not perfect as the first language. Last term, when introducing programming to students, we switched approach a bit. We started off by teaching some of the basic stuff like variable, function and assignment using Python. And later, after two weeks, switch to Java – when introducing Object Orientation. If Object Orientation is the way to go is another question – for me it has never been natural to think OO. Can’t help to state some other questions: Should the University adapt to industry needs? Should Universities teach the best available languages and make the industry adapt? Can we do both? Should Universities even consider the industry needs?

Anyhow, in Python, to output “Hello” you write:

print "Hello"

… using Python you can choose to use it interactively or execute the code via a script. This piece of code was understandably easier for students to understand than the Java counterpart. With Python you can go from procedural style to OO – but I believe Python’s OO syntax is too different from Java’s so I prefer to leave Python before reaching OO.

Apart from students disliking the syntax differences between Python and Java and having to make a switch between the languages we did see an improvement in results. There was actually less frustration in total compared to the year before. Unfortunately the results are not scientifically backed up – so you have to trust me on this one. Even though the students were frustrated about having to learn two languages I noticed that they asked less questions than the year before when we taught only Java. The frustrations they had is something we (read I, me, myself) have to get rid off – if we decide to keep the Python first and then Java strategy.

So after all this random thoughts, it’s almost time to state the question. But first some limits to the question:

  • The students don’t know mathematics
  • We cant assume that the students are willing to die to learn programming – we should perhaps make them want to do so. Using Free Software would be one strategy since you can explore everything you use. But that is a question about motivation. Another time!
  • The students should know Object Orientation and Java after having finished.

Ok, the question:

Can you recommend/propose a strategy when teaching programming?

I will set out on yet another quest trying to find a strategy. This is perhaps a sub task of the book finding quest or perhaps it is the opposite. Any input is welcome, as long as it is constructive….

About these ads

16 responses to “Wanted: a strategy for teaching programming to newbies?

  1. http://codingbat.com/

    http://programming-motherfucker.com/

    Tons more but that should get anyone started.

    It is also nearly impossible to be a successful and effective programmer if you don’t understand data structures, algorithms, basic logic, etc and some of the other foundations that are fundamental. If you are looking for just a nucleation point, the above links should begin the crystallization.  For students, you can at least pull from the resources at “programming-mf”. Probably not in your interest to send that link home with a bunch of kids.

    • I agree to the need of knowing data structures. Totally agree. But to get students started I would not recommend the complete work of Knuth.

      Will have a go at codingbat. Saving the link.. Thanks :)

      I like the programming-mf idea. I am a bit tired of all the methods out there. I invented my own programming project process/method some years ago (late 90’s). It’s called void main (the compilers I used then didn’t force int main). The meaning is – don’t spend so much &/#¤ time thinking – just do it (another name for the method was Nike). If it wasn’t for the names I think I might like them hipster programming methods better!

  2. Pingback: Henrik Sandklef: Wanted: a strategy for teaching programming to newbies? | Open World

  3. Hola Henrik,

    The problem is one I often encounter teaching evolutionary biology, so
    you are not alone. The most helpful things I’ve found are to examine two basic problems:

    1) The misconceptions that students bring with them; and
    2) Some people are not interested in what you’re teaching

    Dealing with the first problem requires knowing your students really well. Surveys could be a good approach. I can think of a few misconceptions about programming: it’s too complex, it’s expensive, I’m not a math person, etc. Unfortunately I’m not sure forcing people to take particular math classes will deal with that last one, unless that’s the goal of the course.

    The second problem is the flip side of the “programming gene.” I agree with you that predestination doesn’t determine ability. However, consider that there will be people taking your class who have WAY more programming experience than others. Consider the following groups of people: students who have tons of programming background, or at least the interest and inclination/habits because they have spent years and years before college programming, playing around with electronics and building stuff; versus people who have spent time studying nothing and heard it’s a good idea to learn programming, because they might get a job in it some day.

    I see the same groups of people in biology classes. I see people who have been doing research since they were in high school, and then I see people who say “I don’t know, I kinda like public health, like I heard there’s people in Africa who don’t have toothpaste and stuff.” Just like you, I am not saying that one group is in any way superior to the other, smarter or more deserving. However, this dichotomy will make a huge difference in what you teach and how well students take it in.

    I’m confident that if you had a classroom of just the experienced people, it wouldn’t matter what language you taught them. You could teach them Scheme and they could pick up Java from reading a book. Those are the people reading Knuth in their spare time anyway :)

    • Hola!!

      The problems with category (1) is both interesting and important to analyse. Knowing a class of hundred students is hard, especially if you as I meet them for the first time when actually doing the introduction course. But still there are some general misconceptions and barriers you/I as a teacher can get rid of. Most subjects are easy for some and hard for some – this course you may be the one having it hard, next time it may be the opposite. Motivating the students is the key (imo). And one way to do that is by encouraging them for what they have learned, i e their progression. This is hard to do since there may be hundred students (I had 119 last term). But you can leave this as an exercise to themselves. One misconception you break then is the “I can never learn this” and that’s important to rid.

      The interest category (2) is tough. I sometimes ask, as a teacher and as a father, myself what’s wrong with the youth today – when I was young I was eager to learn about everything. Bullcrap. I wasn’t. I knew tons of things about when Pink Floyd* did this and that and where they did it. I am not saying we should spend 60% of a course motivating the students why they need to learn this – but we could spend some minutes every now and then telling them why it it important. If you don’t set out to become a hacker – it is imo perhaps not crucial but really important to know a little about programming. I want to awaken an interest, man I sound like one of them TV preachers, especially in the students who come to the course with no interest. It’s hard to do this and at the same time keep the motivated students happy but with some good supervisors I think you can make the course interesting for the already interested and already skilled as well as for the ones with no interest from start…. But if I succeed in this I have to leave to others to say.

      … and about the programming gene. I think this calls for another post some day, but a short comment since I know I may be totally wrong (I am a dancing fool). I am not sure I can say whether there is such gene or not – but I am pretty sure that I can NOT tell if a person has such a gene or not. I am facing the same problem when teaching handball. Some of the kids show great skills early (say around 9-10 years), some when they are in their teens. But who knows what kids in Sweden will be playing in the national team (i e be the best)? I certainly can’t tell – so I have to assume them all to have the gene and teach them to have fun and enjoy handball (and life). Btw, if there would have been an award like Suckiest player of the year I’d won them all. I think this, the suckiness, is what perhaps makes me a good handball instructor today – I hope I am good at least. Arggrgrggg, more another day.

      *) being in the venue where they recorded Live at Pompeii last year really moved me. I showed the kids the movie and they thought it was cool. Cool? It awesome kids!!! They rented Pompeii to record a concert with no audience – can you get any cooler? That musc has been very appreciated by me since I was kid. Still remember playing those cassettes in my mum and dad’s car when I as about 8-9 years old :)

      • The relevance of your Pink Floyd interest is that every person in that class who might not have lots of experience hacking probably does have lots of experience with something. Somebody’s told them “You can’t get a job doing that” or some such thing, which is bologna. I always tell my students “You don’t have to be doctors; we need farmers, artists, librarians and musicians, too.”

        Hell, I am still an amateur Pink Floyd historian, and there are people who’ve made a living at it!

    • Have thought more about these:

      1) The misconceptions that students bring with them; and
      2) Some people are not interested in what you’re teaching

      …. I will really keep ‘em in mind next time.

  4. Pingback: Education. Nevermid – what was it anyway, pt I | hesa's Weblog

  5. Though i prepared a long answer based on a text i wrote before the text need some more work. My time is shopped up in to small parts between taking care of my kids and projects. So i decided to give the answer in parts giving me an possibility to complete a little bit at a time . This is my first part.
    Holistic
    In my opinion the most important part of teaching programming to beginners is to present a holistic view of the subject. I find it useful to try to prepare the students for what’s coming in an introductory lecture, trying to squeeze in as much of the course at once that can be presented in a clear way. Students have told me that this helps them to grasp the content of the course and be more prepared when reading up on the subject and starting with tasks. Though other students find such introduction overwhelming and have to be calmed in advance with the knowledge that everything will be repeated in a slower fashion and much more thorough.
    This holistic aproach can and should(imo) be repeated through out the course. By giving the holistic overview again and/or provide documents, images and lectures with a holistic presentation of the subject. Then each course part should be introduced in the same manner if the are big enough to merit such introduction

    • Nice.

      I guess for me math and hacking have always beautiful (as with music) something that need no background or motivational words, it is beautiful enough as it is. So I think I miss doing a holistic (why do I think about Knights of the Templar when I read the word holistic. Is it Umberto Eco?) approach which I easily imagine give results.

      My take, somewhat similar and yet different, is to let some of the exercises be bsded on a certain topic not het introduced. That is, give them som problems – bit not too many – where they do not have the means to solve them (easily). This makes the students (only my gut feeling backs this up) more alert next lecture when I introduce the new tools/skills to solve the problems from previous exercises.

      Hmmmm…. But when thinking about it I may actually do some kind of we!I holistic (is that the Freemasons then? I mean being “semi”) introduction to some topics. I introduce arrays by the example of having your friends (in a social media app) stored in some way for display on a web page. Storing them in separate variables will not do if you have many friends. Enter arrays. So short problem/motivation and in comes theory. Followed by code example. But I don’t do the big picture holistic (what will that be? Knights of the round table?)

      I will pencil in to my book on “do this next course” your thoughts. Thanks.

  6. I find it curious no mention of age throughout this dialog… I found teaching 2nd graders (7 year olds) programming was one of the most exhilerating and fascinating times during my teaching career. I could not keep up with their creativity, their demands, their hunger to know more! I was teaching a version of Turtle and they ate it up. I had to scramble around for the next platform that would keep them going and I settled on Scratch (from MIT). It was not what I wanted but the kids were happy and busy and learning and creating so … give the students what they want? Is that the whole answer? No. But it seemed to be a darn good start.

    • You’re absolutely right. I guess I either made the stupid assumption that teaching programming is done at university age or (equally stupid) that the word student implied university age. Either way – I errred.

      Some friends of mine have taught 8-13 year old kids programming using Scratch with a good result.

      Can you explain how you used Scratch? Did you introduce programming concepts before letting them do hands-on practice? ….

      • Stanford has a Java(or Java derived?) language/api named “Karel the robot” that allows for simple graphical programming similar to scratch in some ways, but aimed for university students just beginning to learn programming. As i remember it: Karel has Java syntax but leaves out some of the parts allowing a smother learning curve. This is followed up by moving towards Java.

      • I tested it my self a few years back. And recommended it to students wanting another go at the basics do not remember the result/feedback on that.. Though i never used it for a whole class it was not an obvious fit with Skolverkets view on how to learn programming. Though i think it looks good.

      • OK. Apart from the usual handball events this weekend I plan to check out Scratch so perhaps this tool too….

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s