JavaScript as a First Programming Language

Share this on...Tweet about this on Twitter0Share on Facebook6Share on Google+10Share on LinkedIn2Share on Reddit0Digg thisEmail this to someone

Amongst software developers, there are a few perennial arguments: the best operating system, the best text editor, and the best programming language are some of the biggest. It’s our version of “Coke vs. Pepsi” or “Ford vs. Chevy”. As STEM education has become a hotter topic, another debate has increased in popularity amongst the computer science crowd: what is the best programming language for beginners? The title of this post reveals what we chose, but if you attended Learning JavaScript with Minecraft last weekend (or considering attending next Saturday’s session) you might be curious why we went with that particular language.

But first, let me back up a step. If you don’t know anything about programming, your first question may simply be why should kids learn a programming language at all?

The benefits of learning how to program a computer

The popular answer these days, especially amongst the larger organizations pushing STEM education, is that the demand for programmers is growing and that computer science is a high-paying career field.  That’s true, but one could make a similar argument about nurse practitioners and pharmacists.  Glaziers and plumbers are in high demand as well, and their incomes aren’t offset by potentially massive college loans.

However, if we only did things that would likely tie in to our adult careers, few kids would ever play football or chess, go fishing or camping, play an instrument, collect coins, or bother with drawing or painting.

Programming a computer (or coding, as it’s more informally known), isn’t for everybody.  Like crossword puzzles, some people find it incredibly frustrating or boring (or both).  But for others, it becomes an engaging pursuit that challenges their creativity and knowledge.

Programming is, at its heart, the process of solving a problem with a finite set of resources.  The challenge (and fun) comes in not only finding a solution to that problem, but coming up with the most elegant solution that works the fastest or operates in the simplest manner.  Failure is frequent — written code seldom works exactly as intended the first time — but it is seen as a learning process leading to success.

In short, it can become a passion that drives kids to further self-improvement and learning.  Along with it comes knowledge of why computers work the way they do and the self-confidence that they can be masters of the technology rather than subject to its whims.  Even if they go on to do completely different things as adults, these are useful skills and lessons.

Choosing a programming language

Hundreds of programming languages have been developed since the mid-20th century.  Many are incredibly specialized, intended only for a specific type of machine or task.  Some languages have changed so much over time that programs written in their earliest versions are no longer compatible with their current implementation.  Finding a practical starting language usually boils down to looking at which ones are the most widely used and have the greatest amount of learning resources available.

A look at one survey of programming language popularity, the TIOBE Programming Community Index reveals a list of heavy hitters: C and its variants, Java, C#, PHP, Python, Visual Basic, JavaScript, Perl and Ruby.  Other surveys use different methods to determine popularity and have different results, which only further clouds the issue.

The C programming language is consistently in the top 8, along with Java and Python.  All are used throughout the computer industry: in financial and scientific institutions, in gaming, in the defense industry, and in the telecommunications and aerospace fields.  Universities usually select one of the three for their Programming 101 course.

Our choice, JavaScript, is all over the charts: ninth place in one survey, 12th in another, 7th in a third and second place in a fourth.

A Process of Elimination

In my opinion, two things are critical if you’re teaching something: applicability and engagement.

Applicability is straightforward: is this topic something that will be of use to the student?  If you’re looking at programming as a path to a STEM-related career for your child, any of the previously-mentioned programming languages would work.

Engagement is getting the student involved in the learning process: it’s hands-on, active participation.  The sooner a student goes from listening to doing, the better.  Lectures are fine for college students, but any parent can tell you that they’re the quickest way to sap the life out of a kid.

Any serious course for first-time programmers, regardless of language, is going to start with a boring explanation.  Even if you gloss over most of the technical jargon at first, at a minimum you’ve got to get the students to the point where they can reconstruct everything they need outside of the classroom, so they can experiment, play and review what was previously covered.  If you don’t allow students to have that independence, you’re doing them a disservice.

For languages like C and C++, that involves covering the installation of compilers (which convert human-readable code into something the computer understands) and development tools (which make  code easier to read and write).  For a 9-year-old, you might as well be discussing home loan rates and stock prices; she’s daydreaming about something far more interesting.  A 16-year-old isn’t too far behind her.   You’re no longer engaging them, and getting them back will be much harder.

Java and C# are slightly less off-putting since a couple of downloads will get both the language and a development tool to program in.  Both, however, require a subsequent discussion about how to use the development tool and a cursory discussion of object-oriented programming.  Again, you’ve probably lost most of your kids (who are wondering why it’s taking so long for them to do something), and if you’re teaching C# your students have to own a computer running Windows unless you want to make set-up even more complicated.

Visual Basic presents a similar problem to C#: a longer development environment discussion and students are restricted to computers running Windows.  Its ease of use is offset, in my opinion, with its increasingly niche applicability as a front-end builder for Microsoft Office applications and other business software.  Snooze-time for kids.

PHP, though widely used, is almost exclusive to website development so it loses out in terms of applicability to other languages.  Ruby is in the same boat; though the language has made great strides in breaking away from the web-only paradigm, that’s its specialty.

Perl I’ve rejected outright, mostly because Perl code looks like a cat has walked across your keyboard.  I say this with love: Perl was one of the first programming languages I ever learned, and I still have a first-edition copy of Programming Perl by Wall and Schwartz on my shelf.  It’s powerful, but not at all welcoming to the age range we’re teaching.

That leaves Python and JavaScript.

So why JavaScript?

Both languages do very well amongst programmers in debates over the ideal first language for kids.  Neither language requires a compiler, so the kids are spared a few minutes of that discussion.  A simple text editor (found on any operating system) is all one needs to write the code, so the development tool lecture has been avoided.

Python is used all over the place: in standalone programs, in web applications, and embedded in other programs.  It enjoys tremendous popularity with programmers, even among those who primarily use a different programming language in their day-to-day jobs.  It excels at number-crunching and text parsing.

JavaScript has gone from an underpowered web browser capability in the mid-90s to a solid  programming language today.  It can be found powering Web sites, running behind the scenes in games and graphics software, and even running directly on hardware.  Its wide adoption online and evolution in both browsers and servers even has led to it being called the lingua franca of the web.

Both languages also have their disadvantages.  Python, for instance, is very picky about whitespace (tabs and spaces in the programming code).  JavaScript lacks some features found in other languages that are particularly of use to larger or advanced projects.  Neither one is a dealbreaker for kids learning to code, though we did take into account the frustration of dealing with the former.

With both languages being about equal in terms of applicability and ease of use, we looked more closely at engagement: once you’ve got everything ready to go on a student’s computer, what then?  Every Python tutorial aimed at kids I’ve come across essentially covers the same thing: do some math and print out some words to a command-line interface.  That’s solid stuff for teenagers with a desire to code, but is it enough to capture the attention of younger kids?

On the other hand, there is ScriptCraft, an add-on to the popular building-block/adventure game Minecraft which allows aspiring programmers to construct massive structures and change existing gameplay by using JavaScript.  A dozen lines of code can create a massive amphitheater with a fireworks show: something that would take a player hours to build by hand.

JavaScript’s ease of implementation, coupled with its widespread use and the ability to tie it to a game that is wildly popular with kids pushed it ahead of Python.  It’s applicability is a twofer: the kids start learning the syntax of a widely-used programming language, and they get bragging rights when they tell their friends about the cool stuff they’ve done with it.  Despite our rocky start during last weekend’s session, we got a lot of positive feedback that makes me think that we’re on the right track.

After ScriptCraft

Obviously, at some point building things in Minecraft via code will lose its luster.  What then?

Fortunately, we have a lot of options.  Depending upon student interest, there are a couple of different directions we could go.  We could look at using JavaScript in the web browser, to build Mad Libs games and make use of some of the fantastic drawing libraries to build truly jaw-dropping graphics.  We could go in the direction of server-side processing, using node.js to build web servers or even a smart TV platform with a Raspberry Pi.

The great thing is, nothing prevents students from going on to learn Python — or any of the other aforementioned languages — once they have a pretty good handle on JavaScript.  Most of the concepts learned in JavaScript (like variables, functions, loops and arrays) are applicable to other programming languages, in the same manner that learning about the concepts of verb tenses and pronouns in English can still be useful when learning Spanish.

After all, if a bad first-programming-language experience could wreck a potential programmer for life, the industry would be dead by now.

Article Name
JavaScript as a First Programming Language
Many programmers have an opinion about which programming language students should start with. Here's what we decided upon, and why.
Social tagging:

Leave a Reply