Monthly Archives: July 2008

Learning to Program

Teaching computer science is something that I think about occasionally, and as such I am interested in different stiles of books and tutorials. I have even recently considered writing some programming tutorials, just for the exercise it would be to me.

Yesterday, I came across an essay from Peter Norvig, who I respect as a leader in the Computer Science community, entitled, “Teach Yourself Programming in Ten Years.” I love the way he discusses all the books with titles like “Teach yourself x in 21 Days” or “Learn x in 24 hours.”

As he points out, clearly such a title is woefully inaccurate, and yet seems to be the trend in much of the computer world. And the question he asks at the beginning is one that begs discussion: Why is everyone in such a rush?

We live in a society where no one wants to work or wait for anything. Our world has become saturated with “fast food,” “on demand,” and “get rich quick.” What we need now more than ever is a call to perseverance, hard work, and study, and to change our way of thinking to include duties rather than rights, responsibilities not entitlements, and respect over popularity.

Perhaps the quest to “Think Originally” should really be a return to so called “outdated” thoughts and values.

Learning to program certainly falls into the category of things that can’t be picked up in a short amount of time. Sure, one can quickly learn the basic syntax of a new language, and some people never get past this point, but to really understand how to program well enough that you can say you’ve “learned” it will take a even a good student years of hard work.

Javascript Parsing URL Parameters

Passing URL parameters on the query string is very standard, and yet Javascript doesn’t give an easy way to access them, leaving each of us to have to re-invent the wheel ourselves. This puts us each on a google search to try to find a good function. I found one at:

Kudo’s to “lobo235” for putting this out there.

I figure I’ll post it here to increase the amount of “good” functions that show up in searches.

Function to parse the query string in javascript using regular expressions:

function getUrlParameter(name)
    name = name.replace(/[[]/,"[").replace(/[]]/,"]");
    var regexS = "[?&]"+name+"=([^&#]*)";
    var regex = new RegExp( regexS );

    var results = regex.exec( window.location.href );

    if(results == null)
        return "";
        return results[1];