perivam : Vamsi's Writings

Remember, ActionScript is ECMAScript

Before you choose Flex over Silverlight for your next project, remember that ActionScript, the language that Flex applications are written in, is ECMAScript. Silverlight is written in C# (although, it compiles to CoreCLR, not the .NET CLR). This means that you are stuck with the good parts and the bad parts of the language during your development. If your language’s holy grail book is titled JavaScript: The Good Parts, you need to be afraid. Very afraid. There have been many debates over Flex vs Silverlight and the general focus is on the UI widgets available, the community support and how many users will have your runtime already installed. But I will focus on the programming language that is used for the development of these RIA applications. How can you write maintainable, (mostly) error free, scalable and extendible applications if you are crippled by your programming language?

Both JavaScript and ActionScript are dialects of ECMAScript, the standard that (the early) JavaScript eventually evolved into. Both the languages share the decisions that were taken during the standardization. A lot of bad parts have been included in ECMAScript for backward compatibility. Let me talk about JavaScript from now on, because I am familiar with it. But a quick RTFM tells me that I won’t be far off from ActionScript. For instance, variables in ActionScript have function-level scope, not block-level scope, just like JavaScript. Also, variable declarations are hoisted, which means that you can read or write to a variable before it is declared, as long as it is declared before the function ends. Again, something that JavaScript has.

Although I am a huge fan of JavaScript, I don’t think it is suited for enterprise (read Indian code factories) development. JavaScript has bad parts and awful parts that you need to avoid. You have to be careful while programming in JavaScript. You need to think about the language as much as you have to think about your system design and architecture. If you are coming from a C++ or a Java background, which is typical with enterprise developers, working with JavaScript is doubly dangerous. It looks like C, runs in very error tolerant environments (web browsers) and does not have classes. When you see syntactically similar languages, it is natural (but clearly disastrous) to assume semantic similarity. But JavaScript is Lisp in C’s clothing.

C# on the other hand, is a widely used enterprise language and eventually, after giving thousands of interviews, the developers will know that methods are non-virtual by default. In general, the language does not have bad parts, only good practices. It stands on the shoulders of giants such as C++ and Java. As I already mentioned, I love JavaScript and I believe every developer should truly learn JavaScript. But before you pick Flex over Silverlight, remember that ActionScript is ECMAScript and consider the implications.

Leave a Reply