fusionlanguage / fut

Fusion programming language. Transpiling to C, C++, C#, D, Java, JavaScript, Python, Swift, TypeScript and OpenCL C.
https://fusion-lang.org
GNU General Public License v3.0
1.74k stars 55 forks source link

Transpile to cito #80

Open hovi opened 1 year ago

hovi commented 1 year ago

This discussion is more of a brainstorming session than addressing a specific issue. I have been experimenting with ChatGPT to generate reliable code through a semi-automated TDD process that incorporates feedback loops. The system works quite well for Python, and now I'm exploring the possibility of adding more languages.

However, the success of this approach depends heavily on how well the language model understands the programming language in question. It works well with Python, likely because the model has the most extensive knowledge of Python among all languages. Another challenge is that adding more languages necessitates language parsing, splitting tests into separate chunks, handling imports, running tests, and other complex tasks.

I'm curious if there's a way to convert this code to Cito (from any "known" language) and then obtain multiple possible implementations "for free." How is the AST represented in Cito? How difficult would it be to load an external AST into Cito? Which language is the closest or has the most features similar to Cito? Does this idea even make sense?

pfusik commented 1 year ago

Interesting idea! We also have https://github.com/pfusik/cito/discussions for such discussions.

I'm curious what kind of code you are generating with ChatGPT? I personally wouldn't trust it if it fails at basic math. :)

Transpiling from Ć is possible because it was specifically designed for it. I don't believe in transpiling the other languages to Ć, unless it's a small subset of the language. Someone already tried and failed.

The AST is implemented in Ć https://github.com/pfusik/cito/blob/master/AST.ci It describes the code in Ć. Instead of emitting the AST objects you can simply generate *.ci source code.

hovi commented 1 year ago

Thanks, I checked all the links you mentioned.

Yeah it sometimes generates gibberish, but you can basically do a lot to eliminate by this feedback loop:

It's obviously not ideal and can still lead to broken code (sometimes it tries really bizzare things trying to fix tests if output temperature is high), but works pretty well.

ghost commented 11 months ago

@pfusik Should this issue be closed? You closed my issue! I don't know why you decided to keep such issues floating for so long! Do you plan to keep it open indefinitely?

pfusik commented 11 months ago

@iahung2 This is brainstorming on a major feature, perhaps a whole new project. I myself do not know how it can be done. I'm open for more comments.

ghost commented 11 months ago

@iahung2 This is brainstorming on a major feature, perhaps a whole new project. I myself do not know how it can be done. I'm open for more comments.

You closed a lot of my issues as not planned. I think this very issue should be closed as not planned.