Started Pascal target :)

I think a Lazarus-compatible Freepascal target would be awesome. Leveraging the UI capabilities of Lazarus would add a lot of value to the Haxe eco-system, in my opinion.

Maybe I better stop then.
I’m not getting anywhere anyway.
I’m too stupid, and the code is almost completely undocumented.

Programming a compiler is not an easy feat, but with focus and failing fast and often and learning from the mistakes, you can do it. The key here I think is to think of it in terms of small experiments/prototypes.

Forget perfection, it can’t be attained.

Forget style/aesthetics, it can always be improved later.

Learn to accept failure as a way to learn and get feedback, correct course, pivot, etc and not as an inherently negative thing.

Divide in manageable specific outcomes and and Focus on getting something working towards them. This process is often quite organic and you’ll find yourself correcting the route quite often, and that’s fine. It’s a creative process and it’s a bit chaotic at first.

Again, don’t try to create something perfect, and don’t worry about code aesthetics, nobody will judge you (I won’t, and if someone does, just give two f***s and carry on) within the community, on the contrary, they will be glad you’re taking the leap to help and might even jump in to help later.

It all seems so pointless now.
Nobody will use this, ever.
Why would they?
And as I said: I suck as a developer.
I've been programming since I was little (about 50 years ago).
First thing I made was TRON on a ZX Spectrum, in Assembly.
It worked, and boy was it fast…
Since then I've been trying and failing at everything programming related.
I've been stuck in Delphi land, and on Windows, for a long time since then, and it's been my downfall.
I don't know Linux, and that makes me a pariah.
I feel a fool for not knowing bash, or Vim, or Emacs.
I'm completely out of touch with the reality of "cool" developers, I should just quit now, and that's what I'm doing:
I quit.

Man, don’t be so harsh on yourself. It seems you have super high expectations from yourself. Just doodle around to see where you can get. This all is not about being cool / smart, but just see it as exercise to learn something new and try to enjoy the process. I know it’s hard to keep up with everything, but fairly I think everyone struggles with that. I do too and I know that sometimes suggests me everything seems pointless. But that’s not true. So far you already did some stuff, so you progressed. Also, there are not much people who dare to try to get the compiler running anyway, and it is complicated stuff (well maybe not for those who work with it for years, but you shouldnt compare yourself with them anyway) Look at the stuff you can do, not what you seemly think you can not. In the end, when you look back, you will notice you did things you never realized you could ever do.

5 Likes

Which target would you suggest instead?

Maybe no body would use it, but why care?
Programming can be for fun. If you think a Pascal target would be awesome, go for it.
But of course, if you lose interest already (or when you do one day), just do something else.
As long as you’re not trying to get paid or something.

If you want to do something useful to others, there are plenty of things to do other than writing a new target.
There are 855 open issues in our repo at the moment for you to fix.
Or you can write something, maybe a library, or some tools, or a tutorial, or another game (I like playing Haxe games).

3 Likes

I do recommand you try some ocaml before doing the target, or some other compiler work.

Understanding the type system, how to do (recursive) function and call them, making/looping on lists, counting stuff, finding what the keywords means.

Then you’ll have a lot less things to worry about when using it :wink: good luck!

1 Like

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.

cheers, Adrian.

1 Like

FreePascal does support Variants, though:
http://wiki.freepascal.org/Variant

Many thanks :slight_smile:

1 Like

where i can download this version for haxe to pascal 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 :slight_smile:

PS: I can recommend this Ocaml online course

3 Likes

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.

@Matt

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.

Microbenchs: https://benchmarksgame-team.pages.debian.net/benchmarksgame/faster/fpascal-gpp.html

Here are some more resources to take a stab at for learning Ocaml:

https://learnxinyminutes.com/docs/ocaml/

http://dev.realworldocaml.org/
https://ocaml.org/learn/tutorials/99problems.html

Good luck!

2 Likes

Oh, many thanks!

Very useful indeed :slight_smile:

1 Like

Ah, my this far only commercial software was created in Delphi 5… Would love to see a pascal target!

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.

Just my 2 cents, of course.

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.

I understand, but let me make a crude comparison:

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.

1 Like

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.

If you want to go pure Haxe , then start using a macro based Pascal generator \o/

Nice examples of creating generators using just Haxe macros here: Proposal to facilitate creation of new targets - #11 by mark.knol

1 Like

No, Simon is right.
Maybe it’s better if I start contributing in different ways, like e.g. to existing Haxelibs, or new Haxelibs, etc.

2 Likes