COMMUNITY

Could Haxe Ever Compile to Assembly?


(Zicklag) #1

Is there any reason that Haxe wouldn’t one day be able to compile straight to assembly? As far as I understand it you would need to implement some kind of LLVM so that you could compile it for different architectures, but I don’t see that as being impossible. I guess if you were going to do that you would have to do memory management yourself like you have to in C, but what if you had the option to use a built-in garbage collector if you didn’t want to manage memory manually. It is a cool thought. Obviously it might be a lot of work, but Haxe is just such a cool language that I can’t help but trying to figure out just how far you could push it. :slightly_smiling_face:

I’m just having fun brainstorming so don’t take me way too seriously, but are there any huge technical barriers to the possibility? I’m actually curious why C and C++ are some of only very few languages that do compile to assembly. Is it just really hard to do?


(Valentin Lemière) #2

There’s technically nothing that prevent haxe from compiling to machine code, or more reasonably to llvm.
But that wouldn’t be the easiest targets to make.
And it already does make native code through hashlink/c and hxcpp/c++ so you wouldn’t gain much with these targets.

And for manual memory management, while there’s nothing per se that forces haxe to be garbage collected, there’s also nothing in the language to do manual memory management. Also the std would be unusable since it assumes there’s a gc.

It’s not hard, but it’s a huge very specific problem that takes so much work that’s there is not a lot of reasons to do it again and again.


(Zicklag) #3

OK, cool, thanks for the reply. I have gotten more interested in languages in general lately and I am curious as to what’s out there and how things work. Haxe is, so far, my favorite language to actually program in. :smile: It is just so awesome.