Why ActionScript 3.0 should be your first programming language
Last week, a Twitter friend asked about learning programming and where to start. I suggested ActionScript 3.0, but 140 characters isn't enough to explain why. That's what blog posts are for.
ActionScript sounds like a weird choice, right? It's client-side, not server-side. You can't connect to a database or create files on the fly without some sort of middleware. And why would I suggest that budding programmers learn a dying language? HTML5, CSS3, and JavaScript are going to (eventually) take over the world, right?
That stuff is true, or will be in the near term. Yet I still think ActionScript 3.0 is worth learning, and that it's a great starter language for budding developers. Here's why.
- ActionScript 3.0 is syntactically similar to other C-style languages. Curly braces rule! Semi-colons are awesome! Getting comfortable with how AS3 looks and works will make PHP or Java less intimidating.
- ActionScript 3.0 is strongly-typed. Strongly- (or strictly-) typed languages enforce rules for variable behavior. It's particularly useful when debugging, and will help you understand what different variable types are and how they work across languages.
- ActionScript 3.0 is Object oriented. Objects are at the heart of several programming languages, and supported in several more. Getting comfortable with how OOP works in AS means it is easier to understand how it works in JavaScript, Ruby, PHP, and Java. In fact, ActionScript is in some ways similar to Java in how it's structured.
- ActionScript 3.0 is a dialect of ECMAScript. So is JavaScript. It's remarkably easy to switch between the two, which brings me to my next point.
- ActionScript 3.0 and Flash documents have a Document Object Model (DOM). Think of a Flash FLA as an HTML or XML document and ActionScript as the JavaScript that manipulates it. If you're comfortable working with ActionScript objects and hierarchy, learning how to manipulate the HTML DOM is a breeze (and vice-versa).
- ActionScript 3.0 supports Local Shared Objects, which is similar to HTML5 storage, and other key-value based datastores. Yep. Local storage "super cookies" have been available in Flash for years now. Learning how to use them in Flash and ActionScript will help you transition to an HTML5 future. What's more, key-value datastores are the next wave of databases. The data structure for a “NoSQL” store is similar to those for a local shared object.
- ActionScript 3.0 supports event-driven programming. Event listening and handling is critical to game development or interactive experiences in which the sequence of user input can't be (or shouldn't be) controlled. Knowing how to generate, add and remove elements from the stage, or when an item can be safely garbage collected are portable concepts that you can learn with ActionScript.
My point with this post isn't to start a language holy war. I'm not even sure I like ActionScript, plus my first programming language was actually PHP. Still I recognize that the way ActionScript works and as importantly, how it's used provides a nice foundation for beginning developers.