I think object pascal is a good target for several reasons:
It might open Haxe for a total different community of developers. Pascal is still strong in the desktop application direction, database developers and the like.
freepascal and delphi are lightning fast in terms of compilation speed and the generated native code is quite good optimized.
there are zillions of GUI components written for lazarus and/or Delphi.It is very hard to use them from C/C++.
of course such a target is a challenge:
pascal code is not garbage collected. It is difficult to combine garbage collected code with non garbage collected code in a reliable way. So you need to write a GC for the Haxe/pascal target (or use the boehm gc)
pascal has no real closures like Haxe. But that shouldn’t be too difficult to solve
all the dynamic stuff in Haxe need to be implemented for pascal
many more…
if you have spare time for such a project - do it ! you will learn a lot and if it works, there will be users for it.
maybe you should look at the craxe project GitHub - RapidFingers/Craxe: Haxe to nim transpiler
this guy tries to create a transpiler from Haxe to nim written in Haxe. This way is maybe an easier way to start with a new target.
@Matt people doubting about your project isn’t a good measure of usefulness - find people buying into your project, do a small POC and spell the benefits.
If anything, the insane speed of Pascal compilation and runtime speed, and the RAD are interesting features. Also maybe I can get my brother interested in Haxe eventually (he’s “circular” on http://forum.lazarus.freepascal.org).
Ultimately the journey matters and it sounds like a cool thing to do
Lol, bit early for that!
I merely was able to get the sources to compile, and then to prepare the compiler for a new target.
The actual target generator itself still needs to be implemented.
I’d also like to encourage you to continue on with this endeavor. Freepascal’s compilation times are fantastic and would align well with Haxe’s goal of fast to-target compilation times.
I’ve gotten stuck at the OCaml stuff…
Cannot get my head around it, I’m simply too stupid to understand functional programming (well, too stupid for anything beyond the now-common map / filter etc stuff, anyway).
Maybe once Haxe gets rewritten in a language that doesn’t require me to turn my brain inside-out - like hopefully, maybe -in Haxe itself (!), I will try again.
I actually think this is a very important point:
Yes, the fact that Haxe is written in OCaml makes the compiler very, very fast; but at the same time it limits the team working on the Haxe compiler to a very limited in-crowd.
And frankly, to me, it also comes across as a bit defeatist: it’s like saying: “we need OCaml for the speed, because Haxe cannot possibly produce executables that run this fast”.
I would rather have a Haxe that is potentially a bit slower but much more prolific and widely used, than an obscure Haxe that is blazingly fast but that hardly anyone uses.
The thing is that the code style of the compiler probably wouldn’t change much. It would still be very functional (Haxe has ADTs, pattern matching etc too after all). It’s just the syntax would be more familiar in Haxe. Being familiar with macros and Haxe’s AST actually helps a lot.
All that being said, I say this as somebody who’s not a big fan of OCaml either. Haxe-in-Haxe would still be much nicer to work with, even if only because of IDE / debugging support.
Suppose I have an Hungarian poem in front of me, and its translation in English, done by a skilled translator.
The style would very probably be the same, or very similar.
The meaning would be the same, or very similar.
The feelings they invoke in Hungarian and English readers, respectively, would be the same, or very similar.
But for someone who doesn’t understand Hungarian, if said English translation doesn’t actually exist, then all this is hypothetical.
I feel like I would have to learn Hungarian (i.e., OCaml), a language notoriously hard to learn, just to be able to do something that I’m perfectly capable of doing in English (i.e., Haxe): to contribute to a piece of writing (i.e., the Haxe compiler).
I’m sure learning OCaml – if I would be capable of this at all – would be a transformative experience.
But I’m old and don’t want to spend months, just to be able to then start contributing.
Maybe decades ago I had that patience and brainpower, but not anymore.
Let’s be real here: You fail to understand the architecture (due to impatience or whatever) and blame the language it is written in.
Haxe-in-Haxe isn’t going to happen anytime soon. So if you want to write a real Haxe target, you gotta man up and deal with OCaml. Rambling on the forums isn’t going to get you any closer to that goal.