Barriers to learning programming

I’ve been studying my musical “programming lesson” from yesterday’s post, and trying see it with a fresh pair of eyes. I’m trying to imagine what it would be like to look at that code if you had never before seen JavaScript.

I notice that some of the programming constructs are unnecessarily mysterious. That is, they do something simple, but you wouldn’t know it just by looking at them.

For example, look at these two lines of code:

      for (i = 0 ; i <= 7 ; i++)
         play(1/4, i);

All the first line does is count upwards: 0,1,2,3,4,5,6,7. Which is a pretty simple operation. But that would not be at all obvious to somebody who had never before seen JavaScript.

The problem, I think, is that a language like JavaScript is designed to be very flexible, so that experts can do all sorts of advanced things with it. Which is great if you are an expert, but not so great if you are a beginner.

Breaking that first line down into its component parts:

  i = 0   says “Start by setting the value of variable i to zero.”
  i <= 7 says “Keep looping while i is not more than seven.”
  i++       says “Each time through the loop, increment the value of i.”

Once you understand that, it’s not so bad. But getting past that is a lot to ask of somebody who is just beginning to learn programming.

I love the flexibility of JavaScript. But I wish there were a way to learn it that didn’t create so many barriers to entry for the beginner.

One Response to “Barriers to learning programming”

  1. fabio says:

    The ‘for’ construct can be weird (and where does this ‘i’ come from anyways ?). Maybe functional style programming, and in this case the `foreach` construct, can be more natural and flowing for beginners ?

    There is a few interesting frameworks for programming music (see, most based on functionnal friendly idioms that can be worth looking at !

    Actually in js implementing a “range” function might even solve that.

Leave a Reply