I heard Jeff Atwood say something offhand on a podcast to the effect of ‘if you can’t think of at least five things you hate about the language you’re using, you aren’t thinking about that language deeply enough’.
I thought that was probably true. And that five is probably a pretty low bar. But, I couldn’t think of any… so here is an attempt to make a list of at least five things that [annoy me | I hate] about ActionScript, over time. It will double as a list that shows how blatantly ignorant I am about the thing I make my living with.
I’m up to two things, so far.
I’m up to three things, so far.
I’m up to four things, so far.
Woohoo! I made it to five (not including the eight others brought up by Big Coat).
- No String method to convert “true” or “false” to Boolean. Not even a StringUtil method. Incidentally, there is a Boolean.toString() method that returns “true” or “false”, as appropriate.
- Interface methods must be implemented in the public namespace.
- The name() method of the XML object returns a QName object (typed as Object, though…), and not the node name. You have to explicitly call .toString() on xmlNode.name() to get a String representation of a given XML node’s name. If you do that, though, and the node has an explicitly stated namespace, you will get the fully qualified name.
Really, what you want to do is use localName(), but this returns an Object, rather than a String, as well.
Interestingly, the .localName property of the QName object returns a String.
So, instead of just typing .name() and getting the node name (or .name, would be cool, or .nodeName), you have to do one of the following:
- xmlNode.name().toString() (if the given node has an explicit namespace, you will get that, as well)
- QName(xmlNode.name()).localName
- xmlNode.localName().toString()
Wouldn’t it be better if name() was called qName()? And/or if there was just a localName property that gave you a string of the node name? Or, forget having a localName member, and bring back nodeName. Let localName continue to be a member of the QName object, which you access through the XML object’s qName member.
- If an XMLList contains only one child, I would really like it if you could access it like: xmlData.book, rather than xmlData.book[0]. Similarly, if xmlData.book contains 0 nodes, you will still get a value of 1 for xmlData.book.length().
- Pushing elements into a declared, but undefined, Array will fail silently. Maybe it’s cheating to blame the language for not being smart enough to correct – or at least point out – my idiocy.
Are you kidding? What about the fact that TextField.text can’t be set to a number or object, only a String (unlike trace() for example, which will toString() anything you throw at it)? There is no logical reason for this and it’s a pain in the a**. There are tons more annoying things than you mentioned, listed here:
http://blog.iainlobb.com/2009/11/10-things-that-annoy-me-about.html
And a here’s a total rant on the subject that puts your piddly whinging to shame:
Rage Against the ActionScript Machine.
Awesome! Now I’m up to twelve things! Thanks Big Coat.
I clicked on that Rage Against the ActionScript Machine link whole-heartedly. Ahhhh……