HParker / dotal

Dotal Language
46 stars 0 forks source link

Self Hosting vs. implementing compiler in Uxn? #2

Open HParker opened 1 year ago

HParker commented 1 year ago

I would love if I could run the compiler in Uxn. I don't have a clear idea what the best path for a language like dotal to do this is. I am open to ideas, but right now the "nicest" solution I can imagine would be to self host the language. I am open to ideas opinions and other solutions I haven't considered.

marzhall commented 1 year ago

To add what pops into my head: thinking from the top, at the end of the day there needs to be uxn binary that compiles dotal.

The two main ways of getting that at the moment:

Here, I think the question is "is compiler-writing is in the set of things dotal should make easy?"

If so, then this is a perfect chance to apply dotal to its first serious test as a language, giving you a project against which to refine the language. That's a big part of why so many languages choose to self-host.

If not, then the question becomes "which approach means I get to my end result more easily and with more maintainable code."

In deciding this, there's a hidden danger in using dotal here: if you choose to use dotal despite compilation being a task for which you don't intend dotal to be used, you may end up making changes to dotal's specification to make the self-hosting work easier - potentially overcomplicating the language for your desired use case.

That said, this is only if you limit yourself to the available tools. IIUC, you're currently building with gcc. You have the option of extending a C compiler to output to uxntal. (Worth checking - there may be other people already working on this).

Those are my thoughts on what to weigh, at least. Hopefully it adds some context you may not have thought of.

HParker commented 1 year ago

You have the option of extending a C compiler to output to uxntal

I am actually really interested in this solution since it could theoretically make lots of other things possible. I worry that some things would be prohibitively difficult to port, but this is something I have never tried!

I think the answer to the question,

is compiler-writing is in the set of things dotal should make easy?

My answer right now is, very likely no, it does not need to make compiler writing easy, however I think self hosting as worked out well for Fennel which is a similarly small language. My feeling right now is if we reach a point where it seems easy to self host, we should, but today is probably not that day.

The other big thing am considering is how are things like liveness analysis and other more "expensive" optimizations going to run in Uxn? I am sure it is possible, but I really enjoy pretending I have infinite memory.