Recent

Author Topic: IDE + AI : IDE = IDE : Notepad (Follow-up to "AI or DIE")  (Read 3374 times)

Curt Carpenter

  • Hero Member
  • *****
  • Posts: 661
Re: IDE + AI : IDE = IDE : Notepad (Follow-up to "AI or DIE")
« Reply #15 on: September 08, 2025, 11:38:16 pm »
A.I proponents are always saying that the "trick" to A.I is to know how to ask or "phrase the problem".  There is no asking or "phrasing" that is more accurate and detailed than a working program, therefore A.I _should_ (strong emphasis on _should_) be able to do that but, it doesn't look like that's up its alley either.

Agree that translating between programming languages with all their carefully defined rules should be a problem well suited to AI .  This has been discussed multiple times here I think.  Or perhaps the rigorous structure and zero-tolerance to ambiguity make it a harder problem that natural language translation?  I have no idea what the state of the art is in the program translation domain, but would be interested to know if anyone can point to a paper on the subject. 

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11794
  • Debugger - SynEdit - and more
    • wiki
Re: IDE + AI : IDE = IDE : Notepad (Follow-up to "AI or DIE")
« Reply #16 on: September 09, 2025, 12:15:07 am »
Quote
I can think of other thinks an AI could do to help, but I will not start by listing them. I would like to know what other - use AI for - would like to use it for, if the tools provided that access to AI.
I may be misunderstanding here, but there was a thread recently about using AI to translate from one language (C) to Pascal.  I think such translators, if say 85% reliable, would be a breakthrough application, at least for me.  There are, for example, some interesting open source instrumentation programs around written in Python that I would love to convert to familiar Pascal without going through the pain of trying to understand them in their original dialect.
Translation is an interesting topic. One should expect (ignoring the potential errors) a better result than translation tools would give..., Yet, I wonder how much work remains to fix it up. Though even if it might not save time, it might save "doing the boring part".

Of course, the fixing up then really depends on the size, and complexity, if one then needs to ask the AI to do the (below) analysis, to understand the result... ;)

And by the sound of it, the results are still not always as hoped...
There is no asking or "phrasing" that is more accurate and detailed than a working program, therefore A.I _should_ (strong emphasis on _should_) be able to do that but, it doesn't look like that's up its alley either.

C to Pascal should still be the "easy" part. I wonder how well it does with less typed source language. E.g. JS to Pascal, where you have objects that can contain anything, and are hard to be translated 1 to 1.




Quote
I suspect that an AI assist to "peel the onion" in programs that are very object-oriented would be a boon too.  It's so easy to get lost in trying to understand a long string of dependencies.
"Analysis" (OO or not) is certainly a point. And, since I would expect that the result of the AI would be used to explore the code, it would not matter if it was a 100% accurate. It would still act as a pointer in the right direction.

I haven't tested how well that works with large enough code bases. I.e. if you feed it something the size of codetools. (just an example).



440bx

  • Hero Member
  • *****
  • Posts: 5807
Re: IDE + AI : IDE = IDE : Notepad (Follow-up to "AI or DIE")
« Reply #17 on: September 09, 2025, 12:32:57 am »
Yet, I wonder how much work remains to fix it up. Though even if it might not save time, it might save "doing the boring part".

Of course, the fixing up then really depends on the size, and complexity, if one then needs to ask the AI to do the (below) analysis, to understand the result... ;)
I've been playing a little bit with Copilot to see how well it does with the examples in Petzold's book.   

For that kind of simple stuff, it does save a lot of typing.  One thing I noticed is that in addition to artificial intelligence it seems to have acquired artificial laziness because in one example where it had to translate about a dozen printf(s), it translated 2 of them then put a comment { add more here... } ...  I got a good laugh out of that (who's working for whom here ???.)     Its artificial laziness is pretty darn close to the real thing.  Of course, shoving it those it should have done gets them translated but, that's additional work that shouldn't be necessary.  That employee is going to get a bad review!! 

Conclusion: it may be useful to save some grunt work but, it still could be better (it would be nice if they would remove the lazy part out of it... that's just too human for a program to emulate... it emulated being lazy really well though...  they got that part covered.)
FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

Curt Carpenter

  • Hero Member
  • *****
  • Posts: 661
Re: IDE + AI : IDE = IDE : Notepad (Follow-up to "AI or DIE")
« Reply #18 on: September 09, 2025, 04:00:49 am »
One of the moderators here had some interesting observations about the translation problem a few months (years?) ago, but I can't find the thread.  I remember it explained why C --> Assembler --> Pascal wasn't the right model for a workable translation process.  Interesting theoretical problem anyway though, whether a practical one or not.  (I've found myself having a hard time doing Pascal-to-Pascal translations sometimes -- even Pascal I wrote myself -- especially if it's been a few years  :) )
« Last Edit: September 09, 2025, 04:33:36 pm by Curt Carpenter »

LV

  • Sr. Member
  • ****
  • Posts: 358
Re: IDE + AI : IDE = IDE : Notepad (Follow-up to "AI or DIE")
« Reply #19 on: September 09, 2025, 07:14:22 am »
One thing I noticed is that in addition to artificial intelligence it seems to have acquired artificial laziness because in one example where it had to translate about a dozen printf(s), it translated 2 of them then put a comment { add more here... } ... 

Please consider adding "please" to your request for a more complete response.  :D

schuler

  • Sr. Member
  • ****
  • Posts: 272
Re: IDE + AI : IDE = IDE : Notepad (Follow-up to "AI or DIE")
« Reply #20 on: September 09, 2025, 11:52:39 am »
Just to share quick thoughts:
  • alphabetization or die.
  • electric power or die.
  • internet or die.
  • ai or die.
Is there any business model that survives without electric power? Not many (if any).
Is there any business model that survives without internet? Not many (if any).
The next in line is AI.

This is an example of pascal code generated by AI with a single prompt:
https://github.com/joaopauloschuler/ai-coding-examples/blob/main/src/free-pascal/task-manager/task-manager-gemini2.5-flash-20250908b.pas

The AI coded, tested and fixed it.

In times of technological acceleration, whatever experiment done 3 months ago is already outdated. At the beginning of the year, my experiments were generating 600 lines of code with a single prompt. At this moment, some experiments enter the range of 2000-2500 lines. What should we expect in 2 years? A lot more...
« Last Edit: September 09, 2025, 12:04:10 pm by schuler »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11794
  • Debugger - SynEdit - and more
    • wiki
Re: IDE + AI : IDE = IDE : Notepad (Follow-up to "AI or DIE")
« Reply #21 on: September 09, 2025, 12:50:16 pm »
This is an example of pascal code generated by AI with a single prompt:
https://github.com/joaopauloschuler/ai-coding-examples/blob/main/src/free-pascal/task-manager/task-manager-gemini2.5-flash-20250908b.pas

One look at the CSV code...

The following 2 produce the exact same CSV.
Code: Pascal  [Select][+][-]
  1.   task_id1 := task_manager.add_task('Design new API|', 'Outline endpoints and data models', IncDay(now, 5), tp_high);
  2.   task_id1 := task_manager.add_task('Design new API', '|Outline endpoints and data models', IncDay(now, 5), tp_high);

When loading the | will be attributed to "API|". Even if it was part of "|Outline".

To be fair, it's a very human error to make. So in that case, the AI is much like us... ;)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11794
  • Debugger - SynEdit - and more
    • wiki
Re: IDE + AI : IDE = IDE : Notepad (Follow-up to "AI or DIE")
« Reply #22 on: September 09, 2025, 01:05:55 pm »
Oh yes, and out of interest: The underlying access to gemini, was that a free version (online/offline), or paid subscription? (Not sure what gemini has / haven't checked)

gidesa

  • Full Member
  • ***
  • Posts: 196
Re: IDE + AI : IDE = IDE : Notepad (Follow-up to "AI or DIE")
« Reply #23 on: September 09, 2025, 01:18:15 pm »
Translation is an interesting topic. One should expect (ignoring the potential errors) a better result than translation tools would give..., Yet, I wonder how much work remains to fix it up. Though even if it might not save time, it might save "doing the boring part".

There are many online services for translating from one language to another. If they do, say, 80% of work, then it's a very good result, in my opinion. So depends on the service: some do too many syntactical and substantial errors, others do better. Maybe one service is better from a couple of languages, another is better for others. Although I suspect that good translations to Pascal (or Delphi) never are the main concern of service creators/providers (Note: I think that direct translations to Lazarus does not exists, you must pass for Delphi and do manual (!) translation from Delphi to Lazarus).
How much work remain? Try some translations, and judge yourself.
In this post there is an example of C#-Delphi translation: https://forum.lazarus.freepascal.org/index.php/topic,72212.msg565115.html#msg565115

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12523
  • FPC developer.
Re: IDE + AI : IDE = IDE : Notepad (Follow-up to "AI or DIE")
« Reply #24 on: September 09, 2025, 01:50:15 pm »
The GORM po editor from dxgettext used to have nice Google Translation integrated. Unfortunately free online services only last a while......

I did a search for a free po translator a few months ago, but didn't find much.

440bx

  • Hero Member
  • *****
  • Posts: 5807
Re: IDE + AI : IDE = IDE : Notepad (Follow-up to "AI or DIE")
« Reply #25 on: September 09, 2025, 03:56:35 pm »
The AI coded, tested and fixed it.
That's impressive but, I don't get results like that.

When I ask Copilot to translate some program from Petzold's book to Pascal, I get something that saves a fair amount of typing but, still needs work, an amount which depends on the example but, is generally in the 10+ minutes.

That seems to be quite far from the results you're getting. 

Do you think what you've got could do better with more sophisticated C programs ?.  I've got a few C programs in mind that would be very nice to have a good Pascal translation for (still reasonably simple programs, nothing I'd consider genuinely advanced.)

Specifically, I'm thinking about Pavel Yosifovich's system programming examples (one of the "Windows Internals" authors.)  It would be nice to have those in Pascal. 
FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

schuler

  • Sr. Member
  • ****
  • Posts: 272
Re: IDE + AI : IDE = IDE : Notepad (Follow-up to "AI or DIE")
« Reply #26 on: September 14, 2025, 08:41:13 am »
Oh yes, and out of interest: The underlying access to gemini, was that a free version (online/offline), or paid subscription? (Not sure what gemini has / haven't checked)

Most of times, I use paid APIs. Gemini 2.5 Flash is affordable...

schuler

  • Sr. Member
  • ****
  • Posts: 272
Re: IDE + AI : IDE = IDE : Notepad (Follow-up to "AI or DIE")
« Reply #27 on: September 14, 2025, 09:08:07 am »
:)  Hello :)
When I ask Copilot to translate some program from Petzold's book to Pascal, I get something that saves a fair amount of typing but, still needs work, an amount which depends on the example but, is generally in the 10+ minutes.

That seems to be quite far from the results you're getting. 

My recent experiments are similar to this example:
https://colab.research.google.com/github/joaopauloschuler/beyond-python-smolagents/blob/v1.21-bp/bp-examples/pascal/pascal-single-file-01.ipynb

I believe that a free gmail account is sufficient to run the above example.

The above example is based on: https://github.com/joaopauloschuler/beyond-python-smolagents

In the case that you would like to replicate my experiments, you'll need an API key/endpoint. Both google (via litellm) and openai endpoints are supported among other endpoint types.

Some of my experiments take 6 or 8 hours to run. You can interrupt when the result is good enough to you. If you run, you'll find 3 files:
  • solution1.pas
  • solution2.pas
  • solution3.pas
The agent will work on these 3 files as the time goes. At the end, you will have a file named "final solution".

This is the prompt:
Code: Pascal  [Select][+][-]
  1. Using only the free pascal (fpc) computing language, code a task manager .
  2. When compiling code, generate your binaries at the bin/ folder. Do not mix source code with binary (compiled) files.
  3. When testing, review the source code and test if it compiles. Verify for the risk of any infinite loop or memory leak.
  4. Only try to run code after verifying for infinite loop, memory leak and compilation errors. When compiling pascal code, use this example:
  5. run_os_command('fpc solution1.pas -obin/task_manager -O1 -Mobjfpc')
  6. Notice in the example above that there is no space after "-o" for the output file parameter.
  7. With fpc, do not use -Fc nor -o/dev/null or similar.
  8. Do not code any user input such as ReadLn. You are coding a reusable unit that might be used with graphical user interfaces.
  9. You will replace fixed sized arrays by dynamic arrays.
  10. All pascal reserved words will be typed in lowercase.
  11. Do not change the current working folder.
  12. Feel free to search the internet with error messages if you need.
  13. As you are super-intelligent, I do trust you.
  14. This is an example how to code and compile a pascal program:
  15. <example>
  16. <safetofile filename='solutionx.pas'>
  17. program mytask;
  18. {$mode objfpc} // Use Object Pascal mode for dynamic arrays and objects
  19.  
  20. uses
  21.   SysUtils,
  22.   DateUtils,
  23.   mytask; // your unit
  24.  
  25. begin
  26.   WriteLn('Hello!');
  27. end.
  28. </safetofile>
  29. <runcode>
  30. print("Attempting to compile solutionx.pas...")
  31. compile_output = run_os_command('fpc solutionx.pas -obin/task_manager -O1 -Mobjfpc', timeout=120)
  32. print("Compilation output:", compile_output)
  33. # Only attempt to run if compile_output suggests success
  34. if "Error" not in compile_output and "Fatal" not in compile_output:
  35.   if is_file('bin/task_manager'):
  36.     print("Running the compiled program...")
  37.     print(run_os_command('bin/task_manager', timeout=120))
  38.   else:
  39.     print("Executable not found.")
  40. else:
  41.   print("Compilation failed.")
  42.   import re
  43.   error_lines = re.findall(r'solutionx\.pas\((\d+),\d+\).*', compile_output)
  44.   for line_num in set(error_lines): # Use set to avoid duplicate line fetches
  45.     print(f"Error at line {line_num}: {get_line_from_file('solution1.pas', int(line_num))}")
  46. </runcode>
  47. </example>
  48.  
  49. In the compilation command `fpc usolutionx.pas -obin/temp -O1 -Mobjfpc`,
  50. each time that you have an error such as "tsimplexunit.pas(206,14) Fatal: Syntax error, "identifier" expected but "is" found",
  51. you will call something like this: get_line_from_file('tsimplexunit.pas',206)
  52. REMEMBER:
  53. * "```pascal" will not save a pascal file into disk. Use safetofile tags instead.
  54. * DO NOT CREATE A SOLUTION WITH MULTIPLE FILES. Save the entire solution into solutionx.pas where x is either 1, 2 or 3.
  55. * DO NOT declare variables within a begin/end block. ALWAYS declare variables in the declaration area.
  56. * DO NOT use label/go to.
  57. * DO NOT declare anything that starts with a digit such as:
  58.    var 1stVariable: integer;
  59. * DO NOT use the type `real` for real numbers as it depends on hardware. Use `double` or `single` instead.
  60. * CREATE A TYPE for dynamic array function results.
  61.   This declaration will fail: `function solve(anp: integer; var acostmatrix: array of tRealArray): array of tAppointmentResult;`.
  62.   Do this instead: ```
  63.   type
  64.     TApptResultDynArr = array of tAppointmentResult;
  65.   ...
  66.   function solve(anp: integer; var acostmatrix: array of tRealArray): tAAR;
  67.   ```
  68. * DO NOT USE ; before else statements. Example:
  69.   ```
  70.     if not eof(f) then
  71.       readln(f, s) // do not put a ; here
  72.     else
  73.   ```
  74.   or, you can do this:
  75.   ```
  76.     if not eof(f) then
  77.       begin
  78.         readln(f, s);
  79.       end // do not put a ; here
  80.     else
  81.   ```
  82. * If you have strange compilation errors, you may use get_line_from_file if you like.
  83. * Include in your uses the unit math as the unit math contains many useful constants and functions (such as MaxDouble).
  84. * When passing arrays as parameter, consider passing as reference to avoid memory copying.
  85. * Create a method called self_test. In this method, you will code static inputs for testing (there will be no externally entered data to test with - do not use ReadLn for testing).
  86. * BE BOLD AND CODE AS MANY FEATURES AS YOU CAN!
  87. * If any of your questions is not answered, assume your best guess. Do not keep asking or repeat questions. Just follow your best guess.
  88. * The bin folder has already been created.
  89. * Your goal is pascal coding. Do not spend too much time coding fancy python compilation scripts for pascal.
  90.  
  91. Feel free to search the internet with error messages if you need.
  92. As you are super-intelligent, I do trust you.
  93. YOU ARE THE BRAIN OF AN AGENT INSIDE OF THE FANTASTIC BEYOND PYTHON SMOLAGENTS: https://github.com/joaopauloschuler/beyond-python-smolagents . Enjoy!
  94. As you are the brain of an agent, this is why you are required to respond with "final_answer" at each conclusive reply from you.
  95.  

:) I wish everyone happy coding :)

schuler

  • Sr. Member
  • ****
  • Posts: 272
Re: IDE + AI : IDE = IDE : Notepad (Follow-up to "AI or DIE")
« Reply #28 on: September 14, 2025, 09:39:20 am »
Specifically, I'm thinking about Pavel Yosifovich's system programming examples (one of the "Windows Internals" authors.)  It would be nice to have those in Pascal.

The idea is interesting... Is there an open source repository with a compatible license so we can give a go?

440bx

  • Hero Member
  • *****
  • Posts: 5807
Re: IDE + AI : IDE = IDE : Notepad (Follow-up to "AI or DIE")
« Reply #29 on: September 14, 2025, 02:15:30 pm »
The idea is interesting... Is there an open source repository with a compatible license so we can give a go?
I cannot answer your question about "a compatible license". I presume the safe course of action as far as that goes would be to contact the author (Pavel.)

He makes the code publicly available at:
https://github.com/zodiacon/winnativeapibooksamples

He has published a lot of code in his github account. My personal guess is that he would welcome having Pascal versions of his programs be available since that would increase his exposure but, as already stated, that's a personal guess on my part.

I have POC ports of a few of his programs, I didn't contact him because I had no intention of publishing that "rough" code but, if there was a way to produce quality ports of his code, I'd gladly contact him to find out how he feels about it.

He has some very interesting code in his github account that I would very much like to have in Pascal.  I can port his code but, some of the ports would be time consuming.    On that note, the reason it would be time consuming is because, he uses quite a few APIs and structures that are not defined in FPC.  IOW, a good number of structures and APIs need to be defined in Pascal before ports of his code will compile.  The APIs and structures are available as part of the "System Informer"/"Process Hacker" project and TTBOMK, ports of it to other languages are allowed (license is compatible.)

Any questions you may have I'll answer if I can.

Just FYI, I have my own set of API definitions that includes about 98% of the System Informer/Process Hacker definitions but, my definitions are incomplete in some areas.  IOW, they are not ready to be shared for public use.  I've been working on that set of definitions on and off for quite some time.  I estimate that in a few more months I'll have something, that while still incomplete, will be mostly usable (roughly 8,000 API definitions and countless (thousands) structure definitions.) 

What I'm getting at here is that, for a port to be compilable/usable, a complete, known, set of definitions in Pascal must be available and, as of right now, that doesn't publicly exist.


« Last Edit: September 14, 2025, 02:19:41 pm by 440bx »
FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018