Learning a programming language

I recently took my first computer science class, and was interested to see how my classmates handled learning Java, which was, for many of them, their first programming language.

I had already been programming for a few years, and was always glad to help the others.  As expected, the most common mistake was syntax, like forgetting a brace, type, or semicolon.  They also hadn’t yet learned to read compiler errors, causing me to become an expert in leaving my chair.  Beyond that, the main obstacle was thinking in the procedural style so they could answer the critical question, “How do I say that?”

I think the class would’ve been more successful if we started with a language like Python.  I’ve always wondered whether having a first language with types was a good or bad thing, but I think Python’s intuitive style would be a great benefit.

What makes more sense to a beginning programmer?

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

Or:

print('Hello, world!')

The main problem with the first is the illusion of complexity.  It is a very simple program, yet the sudden suffusion of alien syntax, words, and operators obscures the true meaning:  Print “Hello, world!”  To really understand the whole of it, one must know classes, access specifiers, static methods, types, and object-method dereferencing.

Language learning seems to rely on moving mechanisms from our frontal lobe into their better-suited locations.  Imagine how difficult it would be to speak if you had to consciously think about moving your mouth and tongue, and simultaneously construct the grammar for your sentences out of conceptual goop!  In the same way, a programmer has to fluidly identify the real problem they’re trying to solve, formulate a solution, translate it into a given language, and type it, often all at the same time.  It seems a bit harsh to ask beginning programmers to learn such a heavy-handed syntax before learning how to think like a programmer.

A common issue I noticed with the students and syntax was learning how to manipulate data structures.  Consider the following for-loop in Java:

for (int i = 0; i < 10; ++i)
{
    System.out.println(i);
}

with this Python equivalent:

for i in range(10):
    print(i)

Because too much time was being spent learning how to make a for-loop and wondering why programs including one didn’t work properly, it took too long for the students to grasp a deep intuition of how to represent and transverse data, and, sadly, some never really did.

All in all, I think we (or at least I) would’ve appreciated the class more had we learned Python first.  I’ll just keep solace in the idea I might teach a programming class someday.

Advertisements
This entry was posted in Programming languages. Bookmark the permalink.

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s