Recent

Author Topic: Can /my/ AI help me with pascal coding?  (Read 1527 times)

cdbc

  • Hero Member
  • *****
  • Posts: 2716
    • http://www.cdbc.dk
Can /my/ AI help me with pascal coding?
« on: April 04, 2026, 05:15:54 pm »
Hi
I guess I'll begin, 'cause I was curious about my new subscription with "SuperGrok", so I asked it:
Quote
Hey Grok, #cdbc here; Look mate, we've just got a new forum section on https://forum.lazarus.freepascal.org/index.php/topic,73827.0 , where we're discussing Pascal, Object Pascal and collaboration with AI, what do you think about that? is that something for you, coding in Object Pascal with FPC compiler and Lazarus IDE?
This was the answer, I'm sharing it for the others who might consider this particular AI:
Quote
Hey cdbc! Nice to see you popping in with the Pascal crew. 😊
I just checked out that new forum section (the "Board rules" thread you linked). It's a smart move by the admins—keeping things focused strictly on Pascal/Object Pascal work while explicitly opening the door to practical AI collaboration. Things like:

Which AIs are good at learning or generating Pascal code
How to prompt for specific FPC/Lazarus workflows
Existing agents or tools for Pascal/Lazarus (or even written in Pascal)

They’re basically saying: “Bring your concrete examples and Pascal problems, leave the general AI hype/philosophy at the door.” That’s a healthy, productive approach for a technical forum.
Is coding in Object Pascal with FPC and Lazarus something for me?
Absolutely, yes — I’m more than happy to dive in.
I can:

Generate clean, idiomatic Object Pascal code (Free Pascal dialect, with {$mode objfpc}, {$H+}, etc.)
Help with Lazarus-specific stuff: forms, components, LCL, packages, cross-platform gotchas (Windows/Linux/macOS), debugging tips
Review and refactor existing code
Explain FPC compiler switches, generics, RTTI, interfaces, anonymous methods, etc.
Assist with integrating modern things (REST, JSON, databases, graphics, threading) while staying true to Pascal’s strengths (speed, clarity, native compilation)
Brainstorm architectures or help debug tricky issues

I’ve seen from the broader Lazarus forum that people are already experimenting with AIs (ChatGPT, Claude, local Ollama setups, even early IDE plugins), so having a dedicated space for it makes sense. Pascal is a great language for AI-assisted development because it’s explicit, readable, and the compiler is brutally honest—perfect for catching the subtle mistakes AIs sometimes make.
...So now I've got some 'xperimentin' to do over easter  :D
Regards Benny

Added: First order of business, is to get to grips with all the nooks and crannies in 'fpGUI' framework, as it has a lot of cool features under the hood  ;D
« Last Edit: April 04, 2026, 05:22:47 pm by cdbc »
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12288
  • Debugger - SynEdit - and more
    • wiki
Re: Can /my/ AI help me with pascal coding?
« Reply #1 on: April 04, 2026, 05:26:44 pm »
Quick remark. Above post can stand.

People replying should consider the following: Don't just post AI generated text "what each AI says about other AI"

Post your own experience on what result you got using which AI trying to get help with Pascal.

cdbc

  • Hero Member
  • *****
  • Posts: 2716
    • http://www.cdbc.dk
Re: Can /my/ AI help me with pascal coding?
« Reply #2 on: April 04, 2026, 05:34:55 pm »
Hi Martin
Duly noted. It was just that 30$ ...are 30 bucks a month you know and it was an answer to one of the questions in your list...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

cdbc

  • Hero Member
  • *****
  • Posts: 2716
    • http://www.cdbc.dk
Re: Can /my/ AI help me with pascal coding?
« Reply #3 on: April 07, 2026, 02:03:36 pm »
Hi
Right, I have to say, that after trying out the paid version, apart from researching new stuff, where AI wins hands down, I can do the coding better & quicker myself, than with keeping an eye on an /apprentice/, so I canceled my subscription again, wasn't worth the 30$/month...!
I guess - the research, the free version can do for me...  ;D
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

eny

  • Hero Member
  • *****
  • Posts: 1665
Re: Can /my/ AI help me with pascal coding?
« Reply #4 on: April 07, 2026, 02:58:48 pm »
Results are a bit of a mixed bag.
But I got some useful feedback the other day from the big (free) gpt chatter about USB HID interfacing.

I was working on an interface between a truck driving game (-'s SDK) an some external displays and buttons via an ESP32.
For these (hobby) projects I always use Lazarus/Freepascal.

I got the raw version already working with UART communication from FP to the ESP.
But I wanted to replace it with USB/HID communication for more stability and speed.
So that required some USB black magic on the ESP and FP.
And in the end I got it working with the code snippets and libraries that were given.
For FP I was pointed towards https://github.com/dioannidis/HIDAPI.pas, which was the final piece of the puzzle.
All posts based on: Win11; stable Lazarus 4_4  (x64) 2026-02-12 (unless specified otherwise...)

schuler

  • Sr. Member
  • ****
  • Posts: 282
Re: Can /my/ AI help me with pascal coding?
« Reply #5 on: April 07, 2026, 04:42:35 pm »
Regarding the main question: "Can /my/ AI help me with pascal coding?", in order of price:

1) GitHub copilot CLI: about US$10/month.
2) Claude Code: about USD$20/month.
3) My own BPSA (https://github.com/joaopauloschuler/beyond-python-smolagents) paired with Kimi-K2.5, MiMo-V2-Pro, GLM-5, GPT-5.4 or Claude-Sonnet-4.5.

BPSA is the most expensive. BPSA is also probably the only coding tool tested with pascal. It does very large portions of code. These are examples:
* https://github.com/synopse/mORMot2/pull/455
* https://github.com/wp-xyz/jpmMath/pull/7

BTW, I am testing BPSA at the task of porting non visual open source code to pascal. If you would like to submit an idea (a repo for testing), feel free.
« Last Edit: April 07, 2026, 06:43:57 pm by schuler »

MathMan

  • Sr. Member
  • ****
  • Posts: 482
Re: Can /my/ AI help me with pascal coding?
« Reply #6 on: April 07, 2026, 04:52:30 pm »
<snip>

BTW, I am testing BPSA at the task of porting non visual open source code to pascal. If you would like to submit an idea, feel free.

What about this https://core-math.gitlabpages.inria.fr/

Might be a challenge though.

Regards,
MathMan

schuler

  • Sr. Member
  • ****
  • Posts: 282
Re: Can /my/ AI help me with pascal coding?
« Reply #7 on: April 07, 2026, 05:20:43 pm »
@MathMan,
Assuming that we will port only the 32 and 64 bits versions of core-math to fpc, in your opinion, how would the fpc community benefit from it?

I am asking because I assume that you have already thought about it.

MathMan

  • Sr. Member
  • ****
  • Posts: 482
Re: Can /my/ AI help me with pascal coding?
« Reply #8 on: April 07, 2026, 08:15:28 pm »
@schuler

Just to let every reader in on what CORE-MATH is about. The library provides implementations of elementary function (sin, cos, etc. - off and above IEEE-754 Std. requirements), correctly rounded for all rounding modes - t.i. exact to the unit in the last place (ULP). In addition the implementations are fast <= comparable to Intel lib/gnu lib etc. Finally they have been integrated into several run-time-libraries already, if I understood correct.

My thinking was that a Pascal version maybe can replace the existing implementation of the elementary functions in the FPC RTL. This is quite old, and as far as I can tell never got aligned to recent advancements in function approximation theory & practice. However - more work than simple translation would be required to integrate this into the FPC RTL.

Starting with 32 & 64 bit (Single / Double) would be ok, I think. I had some discussion with one of the CORE-MATH devs working on the Quadruple / 128 bit part, as I did some manual translations to Pascal there. However - it will probably take some further years before full set of correctly rounded functions will be available.

Caveat - before you start you might want to contact the FPC dev team if this would be welcomed.

MathMan

PS - sorry for the late response, but I was out for lunch.

PPS - I just threw this into the ring, because I know it to be non-trivial and you were explcitly mentioning "non-GUI".

nanobit

  • Full Member
  • ***
  • Posts: 184
Re: Can /my/ AI help me with pascal coding?
« Reply #9 on: April 08, 2026, 09:59:53 am »
However - it will probably take some further years before full set of correctly rounded functions will be available.

For users it would be much more practical if CORE-MATH would provide also fallback routines if correct rounding is not achieved yet.
FPC needs all math functions (corresponding to libm).

MathMan

  • Sr. Member
  • ****
  • Posts: 482
Re: Can /my/ AI help me with pascal coding?
« Reply #10 on: April 08, 2026, 11:14:54 am »
However - it will probably take some further years before full set of correctly rounded functions will be available.

For users it would be much more practical if CORE-MATH would provide also fallback routines if correct rounding is not achieved yet.
FPC needs all math functions (corresponding to libm).

Hm, maybe I did not clarify enough. For 32/64 (correctly rounded) libm equivalents are available. It's only the 128 bit stuff that is not (yet). As I'm not involved in this project I can not comment on why CORE-MATH choose this approach. My assumption is that 128 bit stuff is taken from libm (or equivalent other libs) and only what is available in CORE-MATH is replaced - but this is only a guess.

However - I think we are digressing from the intended topic of this thread and maybe should start another if you want to continue?

schuler

  • Sr. Member
  • ****
  • Posts: 282
Re: Can /my/ AI help me with pascal coding?
« Reply #11 on: April 09, 2026, 09:27:43 pm »
@MathMan,
Quote
Starting with 32 & 64 bit (Single / Double) would be ok, I think.

I'll test BPSA with this task.

domasz

  • Hero Member
  • *****
  • Posts: 624
Re: Can /my/ AI help me with pascal coding?
« Reply #12 on: Today at 08:36:35 am »
BTW, I am testing BPSA at the task of porting non visual open source code to pascal. If you would like to submit an idea (a repo for testing), feel free.

1) ZSTD - it would be nice to have a fast compressor in pure Pascal:
https://github.com/facebook/zstd

2) BZ2 - it's the last popular compressor we don't have in pure Pascal. We have a decompressor but not compressor.
https://github.com/libarchive/bzip2
We have gzip/deflate/inflate/zip, tar, lzma, lzh/lha but not bz2.

cdbc

  • Hero Member
  • *****
  • Posts: 2716
    • http://www.cdbc.dk
Re: Can /my/ AI help me with pascal coding?
« Reply #13 on: Today at 08:59:28 am »
Hi Dr. Schuler
...If you're aiming high, then migth I suggest, you have a go at SQLite3, it's public domain and I've heard that someone has already done for commercial use... Would be nice to have an open source one too  8)
I know a lot of folks here in this forum are using SQLite3 in their projects...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

 

TinyPortal © 2005-2018