haxe – what’s in it for you

The haxe community has been buzzing about it for some weeks, and a few days ago you could read in haxe 2.0.4 release notes that the experimental C++ compilation target was now included.

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 Javascript: Javascript suddenly became cool a few years ago and there are a huge number of samples, libraries and frameworks. There are even good tools for JS developers: Aptana and Visual Studio provide decent code completion and even interactive debugging. There are also plenty of other compilers to JS like GWT, Java2Script, Script#, JSC, Jangaroo… which integrate in the usual top quality IDEs. At least haxe could win some developer hearts if it was easy to plug in a cool library like jQuery.

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

haxeI believe haxe is still very much for the courageous coder. But you are courageous, isn’t it?

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?

8 thoughts on “haxe – what’s in it for you

  1. Hey Philippe – ‘Right-On-The-Money’!!!

    I am a vb6 (wanting desperately to be an ‘EX’-vb6) developer with a little C and AS experience. Some of my apps (vb) use complete/partial Flash interfaces and I make huge use of third-party components and code-snippets that are widely available – even for some ‘less than common’ functionality. Some are commercial, some are free … some are open-source and some are not. BUT – I can almost ALWAYS find a solution to my client’s need quickly and cost-efficiently without having to ‘re-invent the wheel’ or having to develop any low-level functionality myself. This, ofcourse was the magic of vb.

    Now that vb is dying and I (and my clients) am looking to spread my wings into other OS (namely Linux … and perhaps MAC), I have been searching for THE technology to back, learn and implement for my future dev. I have searched high … and I have searched low … and I have ‘re-searched’ (parden the pun).

    In my searches I have found some interesting projects (like KBasic), but none have proved to be as flexible, capable, exciting, … and promising as haXe. But alas, your three-point comments of the areas in which haXe is lacking, is absolutely ‘spot-on’.

    I believe that ONLY haXe can take me (and probably millions of other vb6 developers) where I want to go in the future. But the issues that you raised NEED to be addressed (urgently)… so PLEASE come on Nicolas. Under-the-hood, this vehicle (haXe) is brilliant. Now, if we can simply create some effective/efficient controls (point-and-click, for this day-and-age please) for ‘driving’ this powerfull beast (and perhaps some nice ‘creature comforts’ like WYSIWYG GUI IDE), then haXe will be unstoppable.

    Even if some of the ‘niceties’ must come at a price. As nice as it is (and I am always imensely greatful) to find free tools, components, tutorials, etc., I have often been quite happy to pay for very resonably priced tools that have helped me to do my job confidently and efficiently and cost-effectively.

    IMHO haXe is THE best software infrastructure for web/desktop, cross-platfom development. The development community at large (that is, those of us (developers) that are not as gifted or super-human as someone like Nicolas) is desparate for a dev platform that has the POWER and FLEXIBILITY of haXe with the ease-of-use of vb6.

    Also, over a decade ago, I began to learn vb with a book ‘Learn Visual Basic in 21 days’. The first original project that I tackled, after reading that book for 21 days (mostly between 03h00 and 07h00 in the mornings, while holding down another unrelated job), ended up developing into a control app for a specialized building-management system that managed all the lighting for one of the largest, most prominent buildings in the city that I live in, for almost a decade. Can we have a ‘Learn haXe in 21 days’ please?

  2. Hi Philippe, and thanks for taking time writing about haXe, although it’s not entirely positive 😉

    First a little correction : we didn’t have any hidden agenda when making MTASC. It was just for the sake of “giving back” to the open source community, since we were using already many open source tools. You can read more about it on this post.

    Also, while I can agree that haXe is a little rough on the edges, things have been improving greatly in the past months. Of course, we are still lacking in the documentation area, but there are many very good quality libraries available in haXe. Complaining about lack of haxelib categories is a bit unfair : there is nothing equivalent in AS3, no central library repository and no easy way to find libraries (apart Google, which haXe also support :D)

    As you also know, some people such as Michel are doing great work at supporting haXe IDE plugins, for example for FlashDevelop3, and so far the end-users have been very happy with it.

    Anyway, I feel comfortable with constructive criticism, especially since I know that all the issues that you talk about are currently being addressed 😉

  3. Hey Nicolas,

    I wasn’t too serious about the “hidden agenda” of mtasc 😉

    You’re right, I didn’t emphasize how unique haxelib is in the development world.

    However my concern is that the haxelib page is a somewhat long list of cryptic project names without any organization. How can I know what the projects do? are they Flash or JS or Neko related? Could there be a list of the projects with their description? And maybe some per-platform filtering so people don’t miss the hard work exposed in this lib.

  4. haxelib website is just a very small frontend, it’s not meant to provide all informations.

    You can use ‘haxelib search ‘ to look for a given project and ‘haxelib info ‘ to get informations about a specific project. However, this is not very practical. One might prefer to build an UI frontend on top of the haxelib commandline tool. I actually suggested Michel to add it to the haxePlugin for FD3.

    Want to contribute ? 🙂

  5. I think that the versatility of programs is a strong point of haxe. I’m very interested in neash and nme for example, as they could help me debug my code in neko and then deploy it in flash without a glitch.

    Some more work seems to be mandatory in that area though. In particular, I’m still having difficulties in handling the assets in an unified manner. I know this is worked on currently, but it still doesn’t work for me.

    My overall feeling is that haxe is neat and that this is the hacking frontier I want to be part of currently. Also, do not forget that when you want to produce flash from a linux box, haxe is about the only solution you have. And that’s the only *free* solution…

  6. Hi Philippe,

    I know, this article is about haXe and Your whole site about AS, but You mentioned “Unity3D”. Did You try it out ? Seems interesting, but, Jesus, so expensive…. !

Comments are closed.