Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
[Teaching programming] Lesson one

[Teaching programming] Lesson one - lazyblog

I hate to use "teaching" and "lesson", but those are the easiest words that come to mind right now.

I will be teaching a friend of mine how to program, from zero to (hopefully) web dev so she can see if it could be something she would like to do for a living.

The book

To give her the basic concepts I am going to use The Little Schemer. I feel like it's excellent as it starts from the basics: "What is an atom?" in Scheme, building up to more complex but still approachable functional programming concepts like using functions as first class citizens and having clear in mind what's going in and what's going on, without any side effects in the middle.

The book also gives exercises so I could leave those out during the lessons and go through her solutions the next time.

Scheme is the language of choice, because it's perfect for the job, since it's a Lisp dialect it uses almost no syntax to introduce programming concepts, sure there are lots of (s and )s around, but how can you tell those are "lots" if you've never programmed before? One could argue about quotes quasi-quotes and the likes, but I think that's advanced material, something you don't need to learn at the beggining of a possible career in programming.

Racket

We will use Racket because of the tooling, Dr Racket is super easy to install and really immediate to use, without losing the power of having a REPL handy.

The method

I don't think rushing it it's a good idea at all, so I am not planning to do a fixed amount of pages / chapters over a certain period of time. I don't think it makes sense at all since we don't know each other skills for me in teaching something, for her in understanding what I'm trying to say.

We will go at the exact speed required for it to be an enjoyable experience.

I will try to keep a log of the difficulties we both encounter during the journey, also because I am expecting to learn an awful lot from the experience.

Lesson one, the feedback

We start from chapter one, the first line reads

Is it true that this is an atom? atom

it's self explanatory that we are going to cover the bases quite a lot.

It all went really smooth, I got just one small complaint about the parenthesis, but not really because of the amount, rather because of the uncertainty of where a scope ended. I briefly explained indentation and showed how the IDE, Dr Racket in our case, addresses the problem by showing you the scope and the balanced parens through highlighting.

She was really ok with dealing with atoms and lists, she just had a question about the difference between a primitive and a function, which I really couldn't answer in simple terms without bringing in more concepts.

I've found a couple articles explaining the difference, or rather, giving hints. As I've understood it primitives are implemented in the underlying system, while functions are built with the same constructs we program with.

I then explained to her why I chose a Lisp dialect instead of something more mainstream, I chose a slightly tortured example, but I think it made it clear enough for her:

public class Hello {

  public void (String[] args) {
    System.out.println("Hello World!");
  }
  
}

Also because she asked which language I started with, and I said that sadly it was Java. I proceeded to point out how many different things you have to show just to do simple stuff: public, class, three different kinds of parenthesis in different positions, ., and so on.

I was a pleasure seeing her appreciating the REPL in the lower part of Dr Racker, as she immediately understood it was going to be helpful to try out things while learning.

It was a bit weird at a certain point when we encountered

(((how) are) ((you) (doing so)) far)

and we were asked how many S-expressions were there. This is something I overlooked last time I've read the book, the answer is 3: ((how) are), ((you) (doing so)), far. I believe the reason is that you take the topmost ones, without going crazy with the nested levels, which is what me and her assumed.

At a point I saw her becoming to be a bit confused about the different laws of the primitives, even though she managed to get through the exercises almost flawlessly I wonder if there could be some kind of visual representation of these first few concepts I can show her. I am almost convinced there should be one, even just for the beauty of the language, it makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment