Actionscript 3 vs Haxe: Which to chose for new Flash project?
Asked Answered
R

5

26

I am in the planning stages of a new Flash game project and was wondering which language would be better to use? I already have a strong understanding of Actionscript 3, and have not worked with Haxe yet, but I have read the language reference docs and it seems that Haxe has some of the features from my other favorite languages, C# and Ruby.

So my question has two parts:

1) Can Haxe interop with flash components (swc files)? Like for instance if i use the Flash IDE to skin some controls, can i import those controls and use them in Haxe?

2) Are there any performance benefits to the Haxe compiler? or any gotchas?

Romeliaromelle answered 25/6, 2009 at 16:4 Comment(2)
I'd love to know how this goes. I've been tempted by haXe a few times. Even have the haXe/Neko book. Now that it compiles to PHP and C++ (as well as Neko, ActionScript, and JavaScript), I'll probably find an excuse soon to try it.Tremor
you should also check out FPOD: code.google.com/p/fpod ... it offers some nice extra features ... and join the mailing list ... there tons of useful infos/news and everything there ... and help, of course ... :DEffable
B
14

1) Yes, and no. As of 2.03 Haxe can export SWCs. This means you can write your code in Haxe , compile to a SWC and then utilize that SWC with Flash. Right now Haxe does not support SWC input, only output (though I believe they are working on this).

2) Yes, there are benefits to using Haxe - unlike Adobe's compilers Haxe actually does some optimizations during compilation (this has been a major bone of contention in the community for a while). In addition, Haxe utilizes some "hidden" new bytecodes that came into being with Flash Player 10 that currently neither Flash or Flex utilize - only Adobe's Alchemy (which cross-compiles from C/C++ source into SWCs).

The only "gotcha" that I know of is that it's kind of bizzaro ActionScript - things are just enough different that it will trip you up a fair amount. That being said, with features like generics and faster code that's small price to pay!

Beseech answered 25/6, 2009 at 18:32 Comment(3)
Thanks for the info. I am definitely interested in designing my game with generics in mind. Though the current lack of support for reading SWCs is disappointing, i am sure i can work around it. Perhaps there are native haXe libraries that provide the same functionality of some of the adobe as3 core libs i've been using.Romeliaromelle
for 1) you could use also as3 written swcs in haxe. there is a compiler flag to use them as external libraries.Beg
A swc is just a zipped up SWF with other data. It is quite possible to use swfs with Haxe. There is an example here: haxe.org/doc/flash/aswingas3?lang=en and here: haxe.org/doc/flash/flex?lang=enWeldonwelfare
E
7

You can find a lot of helpful stuff on lib.haxe.org ... (checkout haxelib for that matter (a bit like ruby gems, one could say)) ... there's also an AS3 to Haxe converter ... so could try translating relevant parts of the corelib to Haxe ... some manual fixing will be required though, i guess ... when it comes to controls, just check out the Haxe gui libraries ... there's a couple of them floating around the web ...

Now Haxe pros: a good thing about Haxe is, that the compiler is much faster, so you don't spend a lot of time compiling ... seriously, it makes a difference ...

Also, Haxe is a much richer language, as branden already implicitely stated ... I just wanna add, you should really check out enums ...

Still, the best thing about Haxe is, that when i comes to write a server, you can stay with the same language, plus things like Haxe remoting make your life super easy ...

There are some AS3 pros, but the thing is, that most of them are just related to the fact, that if you try solving problems in Haxe the way you would in AS3, the language seems quirky and shows unexpected behaviour at runtime ... if you stay strict and typed, everything turns out perfect ...

Hope that helps ... ;)

greetz

back2dos

Effable answered 26/6, 2009 at 19:51 Comment(1)
wow, thanks for the info on haxe remoting. i also found out about SPOD, which looks like a really nice ORM to use in conjunction with neko server. I think i just solidified my technology choices :)Romeliaromelle
T
2

New release of Haxe today. Adds official target of C++.

So now you can target ActionScript and C++ with the same source.

Tremor answered 27/7, 2009 at 1:7 Comment(0)
T
2

NME improves on Haxe's cross-platform support to provide a single API for Windows, Mac, Linux, Android, iOS, webOS, Flash and HTML5 applications without fuss.

The Haxe compiler is notably faster than MXMLC, especially if you are used to compiling from the Flash IDE, instead of an IDE that hosts the Flex compiler shell, like FlashDevelop. As mentioned, there are also a number of added language features, like iterators, typedefs, structs, macros and other nice-to-haves.

The great thing is that since you can always target Flash, there's little risk. The Haxe language is very similar, and if you don't mind supporting a single platform, you can target all of Flash's supported features. However, to the degree that you stick with NME's cross-platform API, you can experience huge performance and feature benefits for mobile and desktop platforms, or experiment with HTML5 support.

Lastly, there's a SWF library that makes it possible to access SWF content from C++. This has always been possible on the Flash target, of course, but soon it should be reasonable to be able to define an interface in the Flash IDE, and use this in mobile or desktop C++ applications as well as the Flash/AIR target.

Terr answered 7/2, 2012 at 5:53 Comment(0)
T
1

1) You can include one swf library (instead of a swc) while compiling using the -swf-lib compiler argument and if you need more than one lib you can merge multiple using the swfmill tool. There's an example of this in the Haxe docs.

2) Branden answered this one perfectly :) Although I might add that one feature that does improve performance, in flash applications especially, is "inlining". Since Nicolas (the creator of Haxe) added even more byte code optimizations on inlined functions. And there's also even more of those optimizations planned.

Trigger answered 22/8, 2009 at 11:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.