Javier Tarí 25 Posted Tuesday at 11:40 AM (edited) Anyone else using the Claude Code software to program in Delphi? I'm not asking about using AI to ask stuff about Delphi (not Claude, not ChatGPT, not Gemini) If you are using Claude Code, please share anything useful for you on the topic My two cents: I'm using with it the Context7 MCP server, which is helpful I've made a "compile" bash command that takes care of compilation I've finally made an agent that uses the command, and returns the result (It helps keeping the context cleaner): Compilation Sucessful Compilation Sucessful but there are warnings that you MUST fix (and the list of warnings) Compilation Error (and the list of the errors) I'm trying to use DelphiLSP.exe through a MCP server, but with low success Edited yesterday at 11:03 AM by Sherlock corrected typo, for better search results Share this post Link to post
Des101 0 Posted Tuesday at 06:49 PM I've been using it with C++Builder for some time and love it. I'm on the max £150 plan and only use the Opus model. I haven't got around to setting up automatic compilation, but it's no big deal, I have CC running on WSL1/Debian so it's simple enough to just paste in any compilation errors, let CC fix them and just click to compile again. (actually my biggest bugbear is probably the cutting and pasting in the terminal, despite what it says, it won't use cntrl-c/v and I have to paste via the menu, I probably need to use a different terminal). Overall, I'm astonished at how well it understands my requests and is able to give me what I need. The results are rarely perfect, but I'm fine with that, the fact that it can get something to 80% complete by itself is good enough for me. I think the main trick to using it is to work out when it's probably reached its limits on a particular task, and rather than just keep asking it to fix things, realise it's time to jump in and do the rest yourself. Des Share this post Link to post
corneliusdavid 256 Posted yesterday at 04:06 AM I've got Claude Code installed on WSL2 (Claude helped me get there--it was quite a chore) but probably won't be using it much for Delphi. I support some web sites using the Hugo static generator so plan on getting my feet wet with that. Share this post Link to post
Vincent Parrett 853 Posted yesterday at 04:25 AM I've been playing with AI lately - if you can't beat them then join them 😢 My experiences are that the AI tools out there right now do not work that well for Delphi - they suffer far too much from library hallucinations (generate great code, if only the library existed!). I gave up and focused on some other projects/ideas On the other hand, if you want to create a React or NextJs application - they will do an amazing job. The main thing is to provide a good context to start with, use the AI to generate a Product Requirements Document - refine that before you have it start coding (and tell it not to start coding till you are ready). I'm still learning all this - but I was able to take a simple saas idea and spit out a working prototype in a day. I probably won't use the prototype - it generated Nodejs/Express/React code even though I told it it use asp dotnet for the backend - I'll recode it using some existing dotnet backend code (since nodejs is single threaded and I have background tasks) and iterate on the prototype front end React code. I will say the whole prompting experience is like looking over the shoulder of a junior dev - spending a day to get them to do a weeks worth of work. 2 steps forwards, 1 step back, over and over - it can be both exhilerating and friustrating at the same time. That 1 day chewed through my $25 Replit credit - so be prepared to spend. Will be trying claude code next - I have tried replit and bolt.new (good for web) so far, along with various others for basic chat stuff. 1 Share this post Link to post
Kas Ob. 152 Posted yesterday at 07:56 AM 2 hours ago, Vincent Parrett said: I've been playing with AI lately - if you can't beat them then join them 😢 Agree, also lately i am trying to get handle on some use of AI. But, here one incident with Claude just less than 2 weeks ago, (free Claude as i am not ready to join the mass hallucinations with money yet), i had this piece of code that i just optimized, four functions that calculate some variations of an algorithm, but it was mess in commented lines and the original implementation, so out of laziness i pasted it for Claude and asked it to format it and extract/keep the original algorithms as comments, and it did beautifully in seconds, i checked the commented lines and it is right and correct, replaced the original code and all looked fine, Next day and out of pure luck, i was looking on different place in that unit file, and dropped the new/modified unit against the old in BeyondCompare, also by pure luck i noticed small difference in those lines, Clause changed one constant from (-8.427913) to (-7.779733), returned to my question in its history and it is there, i have no idea why and from where that constant came, but that indicate to me it is way far from being trusted, the four functions each have 7 constants that i calculated/simplified, yet it decide to change only one. That is big red flag. Another story on the opposite side; two days ago there was a certificate expiration problem in this very forum, and i have used Tampermonkey and Greasemonkey for years now, yet it is pain in the back still for me writing a simple script, searching the net for long time and failure goes hand by hand writing script for TM and GM, anyway, i had a script that i did years back which pop a small notification when loading visiting a site and its certificate will expire within 10 days. So i went with Grok and asked for Chrome Extension to do the same, without providing my GM script, and it gave a full instruction and code for such extension, the extension didn't work as there was problem in manifest file, with 2 consequential questions and report of the problem the extension was running perfectly on my Chrome ( i don't really use Chrome it self but a fork called Supermium, the portable version), it was smooth experience and just saved me lot of time, just brilliant, and huge time saving. Both Claude and Grok fail with Pascal/Delphi in so many ways sometimes fundamentally, yet Grok is do evolve from question to another unlike Claude which revert and keep returning to the original mistakes, as example when i asked them both to extract test vectors from C files, the test vectors where huge and more than 1000 bytes in hex values, both replaced some values out of the blue, just single byte (hex value) is different, Grok remembered the one broken value i pointed to in later questions, Claude fixed it once and after a question it reverted to the wrong value, trying to correct it second time it did drop the whole approach of constant and tried to convince me reading the data from external file is better and correct way ! I tried only the free Grok and Free Claude, as for resources extraction as the best to my short experience with AI is perplexity, it give extensive resources and sources to read when asked. For now i am on the watcher bench, waiting for some real advancement when this hype frenzy start to calm down like its dust. 1 Share this post Link to post
PeaShooter_OMO 39 Posted yesterday at 10:31 AM (edited) @Kas Ob. It is like having a conversation with an old pal who you know is an "embellisher" or "exaggerator". You never trust what he says and always suspect a lie being told. That is counter-productive. I would rather do the work myself. I use AI as a glorified search engine and still I doubt the answers it gives. And I absolutely hate the assumptions being provided as facts. Many times I see the AIs do that. Edited yesterday at 10:33 AM by PeaShooter_OMO 1 Share this post Link to post
Anders Melander 2056 Posted 21 hours ago 18 hours ago, Vincent Parrett said: if you can't beat them then join them 😢 It sounds as if you've given up before the fight's begun - and a fight there will be. On many different fronts. So far I've read and heard endless tales of the efforts wasted on "ai". I'm sure it will eventually settle into something actually usable - if we can survive that long, but until then I'm running circles around the people that try to get ahead of the game "ai". The cake is a lie. 2 Share this post Link to post
Vincent Parrett 853 Posted 21 hours ago 10 minutes ago, Anders Melander said: It sounds as if you've given up before the fight's begun Not really - more a case of trying to better understand it so I can have an informed opinion. My experiences with ai so far - Delphi/c# meh - typescript/react/nextjs useful for prototyping or simple things. I'm about to dive into web design (looking to redevelop my website) to see if it can help. Share this post Link to post
Des101 0 Posted 20 hours ago (edited) 53 minutes ago, Vincent Parrett said: I'm about to dive into web design (looking to redevelop my website) to see if it can help. A little while ago, I asked CC to suggest some designs to update our website, starting with the hompage. On one of its suggested designs it created a panel which included:- Why Choose XYZ? • Over 30 years of experience in xyz software I was curious, as I didn't recall that information being on the website, so I asked where it had got it from. It told me that it had found a testimonial on the site that mentioned "We purchased the xyz system in 1994..." I was pretty impressed. Edited 20 hours ago by Des101 Share this post Link to post
corneliusdavid 256 Posted 20 hours ago 51 minutes ago, Vincent Parrett said: My experiences with ai so far - Delphi/c# meh - typescript/react/nextjs useful for prototyping or simple things. I'm about to dive into web design (looking to redevelop my website) to see if it can help. For me, I use AI with Delphi sparingly. But in two cases, it's helped quite a bit: 1) recalling seldom-used functions when I can't remember the right keyword but can describe the problem; and 2) writing unit tests. For web stuff, yes, it's great! The overall consensus, though is that it's not replacing our jobs any time soon: Measuring the Impact of Early-2025 AI on Experienced Open-Source Developer Productivity 1 Share this post Link to post
Lars Fosdal 1872 Posted 11 hours ago I've tried MS CoPilot and Google Gemini. Both are good for condensing documentation and explaining code. Writing code - not so much. I had a couple of PS scripts that I Gemini if it could optimize them to improve performance, and it sort of did, but it also changed the output from the script significantly . What helped the most, is that it showed me a bag of tricks for creating and updating structures that I didn't know of, and some new PS functions I had never used, which I could easily adopt to improve performance all over. To me, AI can be a sidekick for improving code, but I would not lean on it for creating new code yet. The amount of Delphi material available for it to learn from, is quite small compared to modern web stuff - hence I don't expect it to improve until the algorithms that AI picks up become actual abstract algorithm models in its "mind" and those models can be applied to various output languages, instead of just parroting of code it gleaned elsewhere. The way I see it, AI needs to mature past VLLMs+RAGs and use RACs (or whatever is next) to achieve algorithmic understanding before it can produce quality code. We are not there yet. Share this post Link to post
Die Holländer 90 Posted 10 hours ago AI models don’t “pick up” algorithms in the way humans do. They learn statistical patterns in data,not abstract algorithmic concepts. (only when explicitly trained or fine-tuned to do so) They generate outputs based on learned correlations, not by executing abstract reasoning. So, They don't "just parroting of code it gleaned elsewhere". One thing many people overlook is how important the prompt is. It’s not like using a search engine. The way you ask the question can strongly affect the quality of the answer. For example, if you want Delphi code, a smart way to prompt is: Start with Python, which the model knows well: “Write a Python function that [clearly describe the task].” Then ask to translate it to Delphi, (yes, its a language model..) “Now translate this Python function into Delphi (Object Pascal), using Delphi syntax and conventions.” Add context if needed: “Assume the Delphi code will be used in a VCL application. Use appropriate types and structures.” This helps the model give better results, even for languages like Delphi that have less training data. Share this post Link to post
Lars Fosdal 1872 Posted 8 hours ago Translation to Delphi might work - as long as the AI knows enough Delphi syntax, conventions and libs. Based on what people say about AI code gen "inventing" non-existant functions, I am not so sure it does. RACs are one of the suggested next step paradigms. Even RACs are quite limited, being based on a library of known algorithms - which of course may not be all-encompassing. Share this post Link to post
PeaShooter_OMO 39 Posted 7 hours ago 32 minutes ago, Lars Fosdal said: Based on what people say about AI code gen "inventing" non-existant functions, I am not so sure it does I might be missing what you mean but previously I told the "ai" which library I use which has extensive documentation and the ai would make up library functions out of thin air. Share this post Link to post
Sherlock 685 Posted 6 hours ago My last excursion to Google Gemini was successful at the end, but kinda bumpy still. I started out by asking Quote I want to protect a configuration file for my Delphi application on Windows against changes and unauthorized access. I was thinking about using encryption, but how should the password be protected? Which gave me three possibilities ask the user for the key, use hardware keys or DPAPI. It also explained (quite lengthy) what the pros and cons of each solution are. I was kinda looking for DPAPI anyway so I went for that with Quote Are there any ready-made components or units that use or facilitate DPAPI? That resulted in naming the API calls CryptProtectData and CryptUnptotectData stating they should be declared in Winapi.CryptDPAPI.pas or more general in Winapi.Windows.pas. The main advantage being the lack of a password entirely, everything being managed by Windows itself. It then presented me with some example code unit MyDPAPIUnit; interface uses Winapi.Windows, Winapi.CryptDPAPI, System.SysUtils; function ProtectData(const AData: TBytes; const ADescription: string = ''; AForLocalMachine: Boolean = False): TBytes; function UnprotectData(const AData: TBytes; var ADescription: string; AForLocalMachine: Boolean = False): TBytes; implementation function ProtectData(const AData: TBytes; const ADescription: string = ''; AForLocalMachine: Boolean = False): TBytes; and so forth. Of course a first compile with me integrating this into a test project failed, because there is no Winapi.CryptDPAPI. Quote In Delphi 12.2 the unit Winapi.CryptDPAPI does not seem to exist. I am a nice person, am I not? Well of course Gemini then said I was totally right, and that indeed everything required could be found in WinAPI.Windows. Then rambled on about why it got so confused, and basically blaming Embarcadero for not consistently placing specific API segments in their own units like has happened with WinAPI.Messages or WinAPI.ShellAPI. It then presented me with a corrected unit ready to be integrated into my project...or so it thought. In its implementation of ProtectData and UnprotectData it used a constant for a specific flag, and that did not go over well with the compiler: Quote Now Delphi says CRYPTPROTECT_LOCAL_MACHINE is an unknown identifier. What is happening here? Here is what it said then 😄 Quote My mistake! You're absolutely right, CRYPTPROTECT_LOCAL_MACHINE isn't an identifier directly declared as a constant in Delphi that would simply be found in the Winapi.Windows unit. I apologize for this inaccuracy. The flags for the CryptProtectData and CryptUnprotectData functions are defined in the Windows API as decimal or hexadecimal values. You can use these values directly in Delphi. It then fixed the unit by defining the needed constant correctly. But alas, more errors incoming. I'm still trying to be nice and perhaps lead the machine to realize its own mistakes 🙂 Quote What is CryptProtectData? Yeah, it did not react to that slight hint but gave me a crash course on DPAPI. Only after I wrote Quote Delphi reports that this is an undeclared identifier. basically rubbing its nose in the mess, it finally noticed and responded accordingly Quote You're absolutely right! I sincerely apologize for the ongoing confusion. I'm embarrassed that this bug persisted. It seems I was mistaken about the details of DPAPI constants in Delphi. OK, I thought, that looks good. But it took a bad turn quickly yet again, because it continued with the following Quote CRYPTPROTECT_LOCAL_MACHINE is actually not a fixed part of the Delphi declarations in Winapi.Windows. The correct way to set this flag is to use the decimal value 4 or the hexadecimal value $00000004 directly. and provided me with a "revised" version of the unit where the only correction was more comments, and the constant was now called CRYPTPROTECT_LOCAL_MACINE_FLAG. Oh, goody. Now it really should work, but I didn't bother with a test compile, I was still feeling merciful and wrote Quote It's about the CryptProtectData method, which is apparently unknown. I'm guessing by now it is trying to get rid of this issue as fast as possible, because the explanations and excuses are getting shorter and lamer Quote Okay, I understand the problem. I'm sorry this confusion continues. If CryptProtectData is reported as an unknown identifier, it means that the function itself isn't correctly declared in the Delphi units you're using, or that a necessary import statement is missing. Well, d'uh! So finally it comes up with the perfect reason: Quote The cause: API import in Delphi Delphi declares many Windows API functions in its Winapi.* units. For cryptography functions, including DPAPI, the key unit is Winapi.CryptAPI. It looks like my previous assumption that Winapi.Windows covers all cryptography functionality was incorrect. While Winapi.Windows contains basic Windows types and many general API functions, specialized areas like cryptography are often encapsulated in separate units. And follows up with the perfect solution for the home run: Quote The solution: Add Winapi.CryptAPI ✅ To use CryptProtectData and CryptUnprotectData and their associated structures (such as DATA_BLOB), you must add Winapi.CryptAPI to your uses clause. Note the proud addition of the checkmark, so this must be official... it even updated the entire unit. Now it must be right.... but wait, how did this get started again? Quote There is no Winapi.Cryptapi I'm getting pretty good at shattering this machines dreams. Quote You're absolutely right! My previous information was inaccurate on this point, and I sincerely apologize for the ongoing confusion. The CryptProtectData and CryptUnprotectData functions, as well as their associated structures such as DATA_BLOB, are not directly declared in Delphi in a unit called Winapi.CryptAPI. Instead, they are part of the basic Windows API declarations. In Delphi, these functions, although they are part of cryptography, are typically made accessible through an external declaration in one of the core units, since they are located in the Windows crypt32.dll. I believe it's on to something here Quote The correct procedure in Delphi To use CryptProtectData and CryptUnprotectData in Delphi, you must manually declare them as external functions imported from crypt32.dll. Here is the corrected and complete example, which should now work without the nonexistent units: This actually sound correct, so I gave the revised unit a go. And it worked as expected. So that was about an hours worth of work, then had a lunch break and came up with some ideas for improvement. So with renewed strength and the feeling of being on the home stretch I wrote Quote Please adapt the methods to encrypt and decrypt an object of type TFileStream It obliged gladly and even provided me with a sample snippet of how to call this glorious code, which it also explained in depth. Actually this could be a nice side effect of AIs, if one takes the time to really read all that jibber jabber. Buuuuuuuut, again, the unit would not compile because how the AI thought TFileStreams needed to be handled. Quote AStream.SetEndOfFile does not exist (I'm already out of patience...this short into the second half, oh my) Quote You're right again! My sincere apologies for the persistent errors in the code examples. I'm sorry I gave you incorrect information here. The SetEndOfFile method doesn't actually exist directly for TFileStream. It's a Windows API function that applies to file handles, and is typically achieved by setting the Size property of the TFileStream. It then went on and on and finally concluded that this wasn't even necessary because of how TFileStream.WriteBuffer takes care of that automatically. So that was needed to be done was to remove these erroneous calls to inexistent methods...Done, the newly improved unit was presented with a nice remark at the end Quote Thank you again for your patience and thoughtful feedback. I strive to make the information as accurate as possible. Yeah, we'll see about that, I have more nuisance to test you with Quote It would be useful if the UnprotectFileStream method could output a TMemoryStream Prompt answer Quote You have a good idea! It would actually be very convenient if UnprotectFileStream could directly return a TMemoryStream, as this would greatly simplify further processing of the decrypted data in memory without having to go through a temporary file. You see that too? Now it's just buttering me up! I sense troubles ahead. To my surprise, the new version worked right away. So I got bold Quote I would like to change the input for ProtectFileStream to a file name Just that one method...but Quote This is a very useful change! It's often more convenient to call a function directly with a filename instead of having to create a TFileStream first. I'll modify the ProtectFileStream and UnprotectFileStreamToMemory functions to accept a filename (string) as input. The functions will then internally create, use, and release the file stream. Grrr...at this point I was happy with the one change for the Protect method, and ignored the Unprotect. Copying only parts of the code now. It worked. Again I was provided with samples for calling and quite extensive explanations on the whys and hows. A neat learning experience I completed by asking some questions concerning this technique and security aspects (i.e. could one know how this file was encrypted?)) and possible issues when running this in a Citrix environment. I feel the answers given where quite good and sounded altogether correct. All in all this has been a pretty cool experiment with the free version of Google Gemini 2.5 Flash. I know there is a Pro version, but I'm not yet ready to spend money on that. Please note I did the session in German, so some translation errors might have slipped in either on my side or the AIs. The entire session can be viewed here: https://g.co/gemini/share/a6d5936220bf Share this post Link to post
Die Holländer 90 Posted 6 hours ago 1 hour ago, Lars Fosdal said: as long as the AI knows enough Delphi syntax, conventions and libs This statement suggests that AI knows Delphi in the same way a human programmer does by memorizing syntax, library names, and rules. But that's not how AI works. AI models don't think in terms of syntax or words. Instead, they process tokens which are small pieces of text (like parts of words, symbols, or code). During training, the model learns statistical patterns between these tokens. So, when you prompt the AI, it doesn't recall Delphi syntax. It generates output by predicting the most likely next token based on the prompt you gave and patterns it learned from training data. Just like AI doesn't understand English or Dutch, it doesn't understand Python or Delphi. It doesn't need to know the language it just needs to have seen enough examples to generate statistically likely and contextually correct output. In this way it can "inventing" non-existant functions. So, the quality of the output depends more on how much Delphi code the model has seen, how well the prompt guides the model and if the task is common or not. (Use translation if the task is more common in Python for example) Translation to Delphi might work well if the model has indeed seen enough Delphi examples and the prompt is clear. It doesn't rely on knowing syntax it relies on learned token patterns. Share this post Link to post
Die Holländer 90 Posted 6 hours ago 28 minutes ago, Sherlock said: The entire session can be viewed here: See how after this session Sherlock could basically craft one long prompt based on the entire session that might let the AI output the right code in one time.. Share this post Link to post
Sherlock 685 Posted 6 hours ago @Die Holländer That would be my ultimate goal. But this time I actually wanted to "grow" a project with the machine. Share this post Link to post
hsauro 43 Posted 3 hours ago I recently used a combination of Claude and ChatGPT to generate Delphi bindings for a C header file that had over 500 methods. Saved a lot of time. Still testing but no problem so far. Both AIs can process large amounts of material but ChatGPT lets you download the results in one file where as Claude has to chop up the code into sections because it outputs results via a browser window which is limited in length. I also got ChatGPT to create a convenient wrapper to the bindings. Share this post Link to post
Des101 0 Posted 3 hours ago 10 minutes ago, hsauro said: I recently used a combination of Claude and ChatGPT to generate Delphi bindings for a C header file that had over 500 methods. Saved a lot of time. Still testing but no problem so far. Both AIs can process large amounts of material but ChatGPT lets you download the results in one file where as Claude has to chop up the code into sections because it outputs results via a browser window which is limited in length. I also got ChatGPT to create a convenient wrapper to the bindings. Claude code makes it so much easier. It "lives" in your project, so it can see how everything fits together and adds/edits files in situ. For maximum effectiveness, use it with one of the max claude accounts and do everything with the Opus 4.1 model Des Share this post Link to post