Does MXML get compiled down to as3 and then converted to flash bytecode? Also, is there a significant performance penalty to compiling mxml vs compiling as3?
views:
457answers:
3Flex - AS3 vs. MXML - Is there a compilation speed difference, and how does the mxml compiler work?
Yes it boils down to AS3, most, possibly all MXML components are just a tag version of an AS3 class.
There is no raw difference in compile times, however, because MXML requires the Flex framework, MXML projects do take longer to compile.
So... in a way, MXML is slower, but not dramatically so.
This is a bit of a correction of Jasconius.
All MXML functions as a form of pre-compiler directive to generate a Class. mxmlc.exe will convert it to a series of temporary .as files before running the final compiler. Actually, you can see how the compiler does this by using the instruction keep-generated-actionscript.
Because this is a two-step process, this will mean that it will always take longer to compile something written with MXML. But, even on slower machines and large projects, that will not cause significant difficulties -- the real problem comes in converting everything into bytecode. But, this is not without benefit.
The major bonus of the MXML syntax is that it is easier to read, it is easier to conceptualize, and it is easier to debug. It also makes it much simpler to separate form and content. Any time you might loose in the compilation process, you will gain back ten-fold while programming.
A simple hello world application in flex will be more than 100k in flex compared to a couple of kbs in a pure AS3 project. This is because flex compiles a lot of dependencies into your swf. So yeah, there is a penalty in terms of bandwidth required.
Compile a simple flex app after adding -keep
to additional compiler arguments field in the project|properties|flex compiler and then check the autogenerated folder named generated
in your source folder to see the stuff that the compiler generates.