« GalaxyGoo In The Local News | Main | Today's the day »

Flash8 wishes? Abolish post-colon syntax!

Matt Voerman has posted his wish-list for Flash8: RocketBoots.

This has inspired me to write a quick note about something that has bothered me since the release of Flash MX 2004.

I'd like to see post-colon type syntax abolished from AS.

In my opinion, this statement

var type varName;

is a much better way to write a statement than the post-colon syntax way of

var varName:type;

To me going from most general to most specific is the more logical syntax, and less mentally jarring to read.

Imagine if we mixed up how addresses are written on postal mail.

Somebody Smith
123 Some St.
someTown, someState

might be rewritten something like

Somebody Smith
someState, Some St (123)

Yuck! Mixing up the order of specificity makes the brain sort through the convoluted structure for information, instead of making it easier to quickly find.


Unfortunately, that wasn't a MM choice, it is the standard they are going by.

I don't like it too, especially as it doesn't follow the traditional C/C++ style of declaring variables that we're inherited from the days of yore which I grew up on.

But, alas, Keith is right. It's part of the proposed ECMAScript Edition 4 standard, which Actionscript 2.0 is based upon, so I'm expecting it will stay with us for some time to come, especially as it's likely to become ratified by the ECMA at some point.

Maybe an alternative possibility is to look into third-party SWF compilers like Robin Debreuil's C# compiler for SWFs. As the SWF format is defined at present, there's no particular reason why Actionscript should be the only programming language that can be compiled into SWF bytecodes. It'll just have to take some talented programmers willing to do the work to port another language over to the Flash virtual machine.

I've a strong suspicion that if there were to be a decent Python compiler and a Parrot cross-compiler for the SWF format, we'd have a much more interesting Flash development world. ;)

But.. but... Pascal looks like that! It's just something that, eventually, you get used to looking at.

However, it makes you think - how many of the design decisions made in the Flash 4 days get in the way of progress in the future? The whole post-colon syntax looks a like like object access in Flash 4 - so they made the "var" required to differentiate AS2 from Flash 4 AS 1. MM writes the Flash Player to be backwards-compatible.. but how long until they run into something that they simply can't implement without reworking everthing.

Will we ever see a Flash 7 and below player, and a Flash 8 "all new" player? Probably not.. but definitly a lesson learned - try to be as flexible as possible because you never know what the future will bring.

I almost wish they'd make a "uber player" that drops backwards compatibility (no looking back, just looking forward), integrates with the OS better (think Java applet vs. Java application - file access, net access, etc), and takes advantage of 3d hardware. Ah, but to dream...

i definitely agree with you here darron... but it might be a bit of a myopic view... and of course, u do state that u r dreaming on this one; people don't suddenly port what they had in the past to conform to new standards (because development takes time and money)... so that if MM decided to drop a non-backwards compatible player, they shd be worried about rate of adoption and such; it's one of the headaches M$ is going to have to deal with come longhorn/avalon... because they are sort of dropping backwards compatibility... M$ might be able to weather it OK (M$ is MUCH bigger than MACR)

On topic though, post-colon isn't so bad afterall if you get used to it... don't misunderstand me here... i was quite vocal on my dislike for this feature early when it was introduced... but the poitn is, if you were not used to the "Type type" type way of coding, then the "type:Type" way of coding isn't so bad afterall... it's the same number of chars, albeit the placement of players here diffs....

...i've been doing a fair bit of dvelopement between java and flash and on a few occassions I'll use either of those methods in the wrong place, but all in all, i don't think it's really been anything to write home about... so that, if most developers have had my experience, then you could call this feature trivial...

... there's another side to this; not everyone who codes AS2 (and so probably had to switch over from AS1) is like most of the people reading this post; meaning, "post-colon" might actually be their first dive into strict-typing; they might not take it so lightly if MM introduced something in one version and said "hey, we messed up on this (not really) because our hands were tied, but we are righting it now (not really, yet again) so SWITCH!"

- eokyere

My hope is, that we will see a few more compilers for different languages to swf. There has been one to compile java to swf, Robin Debreuil started one to compile C# to swf, Alex Bradley wrote Kinetic Fusion, which also extends AS2 a little bit with things like const and final. Imho we are still in stoneage of tools, but it looks like it is getting better. And finally you will be able to choose the language you like most. Kristin probably will choose Mathematica :)

Colin Moock in his Essential ActionScript 2.0 says:

"Embarassingly, this is a decision based purely on a historical standards committe vote - this seemed like a good idea at one time. There is no technical reason for using [post-colon] syntax, but its too late to reverse it now(implementations using this syntax have already shipped), even though most of the people involved with it admit the syntax is a mistake."

Too bad, MM getting stuck with a bad syntax just for the sake of adhering to a standard. While there are other instances where ActionScript 2.0 does not follow the ECMAScript 4 specifications strictly, they are mainly for keeping everything compatible with AS 1.0. I think the [post-colon] syntax is just here to stay...

Or maybe in the next version ECMAScript will just get rid of the post-colon syntax... Then everyone will be happy :-)

I've been thinking that a nice solution would be for MM to allow for both syntax in the authoring environment. Should be easy enough to implement. Even a handy tool that would convert one syntax to the other would be nice. This would make it easy to share source code with folks who prefer "the other" syntax.

I like the post-colon syntax! Pascal does the same thing and I feel more comfortable reading this syntax than the C syntax.

Also, data typing is NOT required! How can the compiler distinguish a non-typed variable and a typed a variable if the C++ syntax is used?

var myVar;
var myType myVar;

hotFusion, i would assume if the Pascal-like syntax is (and I don't think it would be) abolished for the java/c-like syntax, then the var keyword gets dropped too... even with the current syntax, it is redundant, as [public|private] foo:FooType should be enough to say you are declaring a "var"