Monday, April 16, 2007

Javascript as a Learning Language

A popular question is what language to start with when teaching a novice how to program. I've seen C and C++ dismissed as too complex and I agree. Java / C# are usually passed over because of all of the explanations necessary for Hello World. I agree with this too because you'd have to tell the student to ignore import, static, void, arrays, braces and explain what the Console is. Usually the next things considered are Perl, Python, Ruby and Bash. I'd go with Javascript.

First, good tools are very easy to obtain. The novice is probably using Windows and would need to download the script interpreter. All you need for HTML and Javascript is a text editor that colorizes such as Crimson Editor or Programmer's Notepad. Running the test involves double-clicking on the HTML icon on the desktop which is not intimidating at all.

Teaching JavaScript allows you to start with HTML, which is very easy to learn. It's easier to understand markup because it's easy to look at the HTML and see "The quick brown and then fox is surrounded by strong and then jumps over the lazy and then dog is surrounded by em which means emphasis." You get to make something cool very quickly when the teacher goes into colors, backgrounds and images.

This leads well into JavaScript. There's an instant UI using the alert, confirm and prompt functions. There's very little syntax that needs to be explained to get started and nothing needs to be skipped. "The tag is called script because we're going to use JavaScript. We're going to alert the user by telling them a number. Type alert(16)."

One day I'd like to put together a "Programming from Scratch" series of screencasts, but I doubt that I'll be able to do it soon.

No comments: