I've got a simple question. Suppose some simple lib written on c. Did I understood correctly that alchemy compiles it AS3 before compiling it to swf. If so, will the lib be slower or faster in comparison with the same lib written on AS3.
2 Answers
No, Alchemy does NOT compile to as3, it functions as a bridge to c/c++ code. So AS3 can utilize the functions written in C/C++ AND thus benefit from the high performance with a minimal degradation. So it will be just a really small fraction slower...

- 2,647
- 3
- 25
- 30
-
You're completely wrong. Alchemy uses the C/C++ front end of the LLVM compiler to convert that C/C++ code to LLVM IR, then performs LLVM op on that code, and uses a custom AS3 back end for the LLVM compiler to output actionscript 3 OR actionscript 3 bytecode which is then compiled down by a customized version of the actionscript 3 compiler. – Apr 24 '11 at 16:17
Alchemy use a modified actionscript compiler that allow the use of new operation who speed up memory access or allow sign extension to deal with C type.
It compile to SWF or SWC format but you have an option to see the as file genereated
Internally Alchemy emulate a processor (it seems to be an X86 proc) and have a library that replicate some of the core C lib such as Malloc, Free, etc...
So you will see a speed gain if your library use memory a lot but otherwise, as it compile to bytecode and emulate the C lib you can see a gain loss.
You will not see in the current state the same speed as your C code.

- 15,702
- 1
- 39
- 39
-
1Alchemy doesn't emulate an X86 processor. The C code compiles to as3 bytecode. However, it *does* emulate the C runtime, with its own memory space and virtual file handles. – paleozogt Apr 19 '11 at 21:23
-
@paleozogt not a full processor but state, register(eax, ebx, ...) stack via ebp, etc... – Patrick Apr 19 '11 at 21:36
-
so you say some big computations(e.g working with image) will work faster if it's done via Alchemy? – Eugeny89 Apr 20 '11 at 09:57
-
The big gain is bypassing the internal garbage collector AND the fact that the C/C++ is converted to LLVM IR, and then benefits from LLVM's optimization techniques, finally spitting out AS3 bytecode. So you have a directly accessibly bit of ram for the alchemy portion of your code through ApplicationDomain.domainMemory. http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/ApplicationDomain.html#domainMemory – Apr 24 '11 at 16:15