You probably know that haxe can be used as an alternative to AS2 and AS3 for Flash development, but you would definitely be missing something if you limit this powerful language to “just Flash”…
So how did haxe get to be able to compile as C++ and why is it a big thing?
If you are young you may only have heard a bit about haxe’s cool Flash features, in particular its unique Flash 10 memory access – the memory model which powers Alchemy, so haxe can be as fast as Alchemy without the crazy C compilation and wrapper stuff. haxe’s Flash target also features some cool esoteric stuff like runtime bytecode compilation, scripting in haxe, etc.
However haxe is not only about Flash, haxe is a multi-target language, that is it also “compiles” to JS and PHP. So what is so hot about C++? Nobody cares less about C++ than Flash developers (except for some Alchemy hacking that is), but this means that in the near future you should be able to create iPhone apps in haxe. Yeah, “native” iPhone apps in haxe, with a nice AS-like managed language.
So how did we get there?
A geek story
If you have been a serious Flash dev a few years ago (around 2004-2005), you were probably using mtasc, the mighty Actionscript 2 compiler which put Macromedia to shame by being about 100 times faster. Some would say that mtasc was the best thing which could happen to Flash, but retrospectively I think this is a bit exaggerated: mtasc was mostly used by Eclipse and/or command line geeks. Who cares about them in a FWA-ruled world of Flash?
Nicolas Cannasse, the creator of mtasc (and only developer) actually had little interest in AS2. So why did he developed it? I may be wrong but I think it was an opportunistic move to promote his company and to eventually give him a chance to get a wide audience interested in his original language – this is the dream of every language creator. The compiler was not developed “from scratch” as he had already created for his company, Motion-Twin, a compiler for a completely original and private language*. So technically mtasc was a “dumbed down” (ie. adapted to AS2) version of this creation.
* There is little information available on MotionTypes but for what Nicolas described, it sounds very much like haxe…
When Adobe changed the game
Mid-2005 Adobe assimilates Macromedia. Some said it was driven by fear (of Microsoft) but it proved to be a good business decision, creating a strongly integrated platform to compete with Microsoft and Sun.
6 months later we learn that Macromedia had designed a new language, a new VM and a new display model for the Flash player. Adobe, now owning the technology did the right thing: offer a free Flex SDK which eventually would be open sourced. It was like a brilliant move, but nowadays you don’t impress anybody with a free SDK, every idiot and his mom know that if you don’t offer a free SDK or API nobody will want to date you.
After a few months, most AS2 projects were dead, it was AS3 in every heads. Everyone had already forgotten all the hard work spent in AS2 libraries, tools and compilers. New AS3 libraries and frameworks were spawning every day on google code.
Still in 2006 Nicolas announced that mtasc will never-ever-not-even-for-money support AS3. He had decided there was no room for two AS3 command line compilers. “My proposal is then a new language that will support several platforms”, he said.
And haxe was born
At first mtasc fans were intrigued, weighted the pros and cons, then most of them turned back to Flex, the shiny new enterprise version of Flash, specially designed to fit in their trusted Eclipse setup, including a new painfully slow java compiler to plug in their ant tasks.
haxe failed to convince as it couldn’t quickly oppose appropriate:
- tooling – you can’t be popular without a good IDE and workflow,
- interoperability – who wants to reinvent the wheel?
- learning material – where do I start?
Nicolas is a game creator and what I call an extreme geek. And it looks like the biggest part of haxe loyal users are also either game developers, or extreme geeks: both are likely to be happy writing everything from scratch (even though there are now a few haxe libraries it is still very limited and not even categorized) and compiling from the command line.
Even if haxe was a brilliant language with a compiler on steroids, it just couldn’t compete with Adobe’s Flex framework, builder, documentation, samples which were already invading the Flash world.
haxe VS the world
haxe VS Flash: AS3 is a reasonably good language, with good tooling (Flash Pro, Flex Builder, FlashDevelop) and many good quality libraries and frameworks. haxe was long unable to efficiently leverage existing AS3 code (and it is still a complex operation) and there is still no decent GUI component set. When haxe will support SWC libraries I believe it will get some momentum in the Flash community. Come on Nicolas!
haxe VS PHP/.NET/etc: this is an area where haxe could shine if it had more examples and documentation. haxe has a good templating system which is being used in high traffic websites (in particular Motion-Twin’s popular games). Now it even can “compile” to PHP so it’s easy to deploy on a cheap shared hosting. Ruby On Rails became cool thanks to sexy tutorials showing how to do a complete simple project step by step – this really could sell haxe on the server.
haxe VS C++/iPhone: I believe Flash developers could get into haxe just for the iPhone target. But beware of Mono: Unity3D is already there and Mono/MonoTouch is coming, and it offers a good IDE, managed languages and compatibility with the official Interface Builder. It must be noted that haxe for iPhone is still very early and it needs polishing to make it a viable solution. Oh and it should happen while people still care about doing iPhone apps 😉
haxe VS the client: haxe is still a hard sell to a client – at least this would be my biggest problem (along with the difficulty of having my team to learn haxe and new workflows). Last time a client got our sources he asked: “where are the FLAs, we require that you provide FLAs” (it was compiled with the Flex SDK). Sigh.
haxe and you
Eventually interoperability will improve and porting AS3 code to haxe can be mostly automated. Also tooling is getting decent (hint: especially FlashDevelop) and the documentation is getting better so learning haxe is now more accessible.
Maybe the time as come to learn a new language which will make you a more versatile coder?