Next week I'm presenting all that is shiny and new in RAD Studio 13 in Ljubljana. As the presentation will be in Slovenian language, so is the next of this post ...
The Delphi Geek
random ramblings on Delphi, programming, Delphi programming, and all the rest
Thursday, October 16, 2025
Friday, August 08, 2025
Delphi and AI [9]: Guided writing
Some time ago, I tried using AI to write a blog post, but things didn’t go quite as planned. For my second attempt, I aimed to do better. I focused on a single engine—OpenAI—and used it in a more granular way. Instead of simply saying, “Write me an article about...,” I started with basic introductory questions, then asked it to write the article, and finally requested improvements where I felt the draft was lacking. The end result was quite satisfying.
This article is my analysis of that process. If you’re only interested in reading the transcript, you can find it here.
Thursday, July 24, 2025
Integrating LLM engines in your Delphi app with Chatterbox
But the real changes happened under the hood.
I’ve refactored the codebase to fully separate the AI client logic from both the UI and the network layer. And what does that mean for you? It means you can now use the Chatterbox AI libraries directly in your own code.
Let me say that again, loud and clear:
You can now use Chatterbox AI libraries from your code!
To test this, I created a very basic demo called EngineDemo. And naturally, for this announcement, I had to explain how the demo uses the Chatterbox libraries.
Since this was a brand-new development that the AI had no prior knowledge of, I decided to revisit an experiment I mentioned in a previous post—one that was only partially successful. This time, I took a different approach. But more on that in the next post.
For now, take a look at what ChatGPT had to say on the topic. Just keep in mind: this wasn’t a simple “click and publish” process. ChatGPT and I had a long back-and-forth, and the result of that collaboration is the article below.
Sunday, July 13, 2025
Delphi and AI [8]: Write me an article about ComputeCore
This was supposed to be an article comparing three major AI players in their ability to write technical articles. In preparation, however, I made some mistakes ... :(
When I prepared for the initial article, I asked them to fetch the data from https://github.com/gabr42/ComputeCore/blob/main/ComputeCore.pas and write about it. (See the end of this article for the initial query and results.) At that moment, however, that link was not public yet. All three AIs ignored that and happily wrote about the code they knew nothing about. It was only Claude that complained about the bad link but I missed that while checking the results.
So I decided to rerun the experiment on all platforms. I started by asking the engines the following question:
Can you accesss https://github.com/gabr42/ComputeCore/blob/main/ComputeCore.pas and provide an overview of the code in one paragraph?
Can you accesss https://raw.githubusercontent.com/gabr42/ComputeCore/refs/heads/main/ComputeCore.pas and provide an overview of the code in one paragraph?
Analyzing the answer shows that the answers were not done purely on the basis of the linked code. Both Claude and Gemini have included details that they got from my previous article on ComputeCode.
In the answers below I marked hallucinated misinformation with red and information that was obviously retreived from different sources with blue.
Saturday, June 28, 2025
ComputeCore - A Simple Parallel Task Framework
Today, I want to talk about a small multithreading kernel (framework, library, or whatever you want to call it) that I've recently helped develop for the Spring4D project.
ComputeCore is a lightweight parallel processing framework for Delphi that lets you easily run CPU-intensive tasks across multiple threads. Its goals are straightforward: to run (possibly compute-heavy) tasks concurrently, allow tasks to spawn child tasks, and expose a very simple interface for the caller.
It will eventually be published as Spring.Threading, but until that happens, we can examine the almost-final version at https://github.com/gabr42/ComputeCore. In Spring4D, it will run the parallel implementation of the new sorting algorithm, but that doesn't mean it is only useful for one specific job! It is indeed a completely open (although intentionally simple) framework that can be used for your projects too.
[This article was written with the help of an AI. My next article will explain this decision and the writing process.]
Friday, April 04, 2025
Run your Delphi programs in a browser
Next Wednesday I'll be talking about Delphi and TMS Web Core in Ljubljana. As the presentation will be in Slovenian language, so is the rest of this post.
Sunday, February 02, 2025
Delphi and AI [7]: How good are local DeepSeek models (for Delphi)
Due to potential privacy concerns with DeepSeek servers (we’re unsure if the data sent over the paid API is kept private), I looked into some smaller DeepSeek models available on the Ollama.com site. These models use less complex AI with fewer parameters than the online version, but they might still be good enough for an average Delphi programmer. We’ll see.
For testing, I used a powerful RTX 4090 card with 24 GB of memory. If your graphics card has less memory, your selection of useful models will be more limited.
I asked all models the same two questions: one on a general programming topic and another specific to the FireMonkey platform. The first question was:
"I have a multiline string containing newline ASCII characters (TMemo.Text). I want to change it to a single-line string with only printable ASCII characters. I could do that with BASE64 encoding, for example. I would, however, like to keep the text as much readable as possible by "encoding" only non-printable characters. Is there a simple way to do that?"
You can check Codellama’s response in an older post (Codellama being the only local model I had tested so far): Delphi and AI [5]: Encoding Multi-line Strings.
Last week, I asked the same question to the online DeepSeek-Reasoning model. Check the answers in this post: Delphi and AI [6]: DeepSeek-Reasoning Model.
The second question was:
"How can I copy text to clipboard in a Delphi Firemonkey application?"
Read here for Codellama’s response: Delphi and AI [4]: Device-ndependent clipboard.
The answer from the online DeepSeek-Reasoning model can be found at the end of this post.
Let’s see how the models are performing! As always, full logs are available on GitHub.
Thursday, January 30, 2025
Chatterbox v0.2 - Now with DeepSeek support!
As I’m writing this, a new Chatterbox release is available on GitHub. As with the initial release, you can either download the source and recompile it or grab an executable (Windows, 32-bit) from the release.
(If you have never heard of Chatterbox, you should probably read the initial release article.)
The biggest change since v0.1 is support for DeepSeek AI.
Friday, January 24, 2025
Delphi and AI[6]: DeepSeek reasoning model (Encoding a multi-line string)
An interesting AI has just appeared on my radar - DeepSeek. It exposes a "normal" chat model deepseek-chat and a "reasoning" (that's the interesting part) model deepseek-reasoning. While working on DeepSeek support for the Chatterbox (more on that in few days) I thought it would be interesting to ask the "reasoning" model the "multi-line string encoding" question that every other AI has failed.
Warning: DeepSeek privacy policy states: "When you use our Services, we may collect your text or audio input, prompt, uploaded files, feedback, chat history, or other content that you provide to our model and Services." Don't send any private or proprietary information in the chat!
The log is provided on GitHub.
Just as a reminder, the question was:
"I have a multiline string containing newline ASCII characters (TMemo.Text). I want to change it to a single-line string with only printable ASCII characters. I could do that with BASE64 encoding, for example. I would, however, like to keep the text as much readable as possible by "encoding" only non-printable characters. Is there a simple way to do that?"
Sunday, January 19, 2025
Delphi and AI[5]: Encoding a multi-line string
Recently I had to convert a multi-line string into a single-line string value for storage (ignore the 'why' of it; let's just blame it on a legacy code). My first idea was to do a Base64 encode of the string, but I was in a mood for some fun and so I asked my friendly AI helpers:
"I have a multiline string containing newline ASCII characters (TMemo.Text). I want to change it to a single-line string with only printable ASCII characters. I could do that with BASE64 encoding, for example. I would, however, like to keep the text as much readable as possible by "encoding" only non-printable characters. Is there a simple way to do that?"
Let's see what they came up with!
Full transcripts, as usual, are on GitHub. This time I had also created a program containing all implementations.
Sunday, January 05, 2025
Delphi and AI [4]: Device-independent clipboard
While working on Chatterbox I ran into number of problems, most of them caused by my limited knowledge of device-independent programming with Firemonkey. One particular challenge was copying data to the clipboard - something that is AFAIK available on all supported platforms. So I asked my friendly AI helpers:
"How can I copy text to clipboard in a Delphi Firemonkey application?"As always, all logs are available on GitHub.
Wednesday, December 25, 2024
Delphi and AI [3]: The meaning of Christmas
It's the time of the year to be merry and have fun, so no code today!
I've decided to ask our future AI overlords about the meaning of Christmas. The Delphi way, of course!
Today I'm posting just the answer I liked the most. You can read the others on GitHub.
Happy holidays, fellow programmers! And remember - Delphi, it is the way!
![]() |
As befits an article on AI-generated content, the image was created by Midjourney. |
Tuesday, December 17, 2024
Delphi and AI [Intermission]: Introducing Chatterbox
t’s great that Embarcadero has added an AI Chat window to RAD Studio, but let’s be honest—the implementation is lacking. As one participant at a recent workshop noted: “It looks like someone wrote it two hours before the release.” Sadly, I have to agree. The AI Chat feature is practically useless if you intend to use AI for anything more than a quick demo.
That’s when I started considering better ways to interface with LLMs. Instead of searching for an alternative, I decided to build my own AI chat interface. It’s called Chatterbox, and it’s fully open source. You can find it on GitHub under a “do with it (almost) whatever you want” license.
To start using Chatterbox, you can either build it from source or download the precompiled EXE from GitHub (currently available only for Windows 32-bit). The app is written with FireMonkey, so—at least theoretically—it can also be built for macOS, iOS, Android, and Linux. However, I haven’t tested it on platforms other than Windows.
To build Chatterbox, you’ll need the following libraries: Spring4D, DCPCrypt2, and TAES. Links to these dependencies are included in the README file.
Wednesday, December 11, 2024
Delphi and AI [2]: Clipboard Monitor
While preparing for my Delphi and AI workshop, I decided to keep a log of all my interactions with AI helpers in a file for later analysis. Initially, I searched for an existing utility to log clipboard changes to a file (and I found one), but then I thought—why not ask the AI helpers to help me create one? After all, it’s not a big problem: set up a timer, check if the clipboard content changes, and log the content to a file. What could be simpler?
I posed the same question to all five engines:
"I want to create a Delphi application that would monitor clipboard content (on Windows) and append clipboard content to a log file each time the clipboard has changed (and has a text inside)."
Let's see how they performed!
Logs and code are available here.
Saturday, December 07, 2024
Delphi and AI
Recently, I led a workshop in Slovenia where we explored the current state of AI in relation to Delphi programming. (A note to participants: the slides are finally online—apologies for the delay!) The initial results were, let’s say, interesting enough to warrant further study.
Now, let’s see how today’s "state-of-the-art" AIs perform with Delphi programming!
The contenders are:
- OpenAI with the o1-mini model (my testing suggests that it gives better results than chatgpt-4o)
- Ollama with codellama:13b model (the largest model I can run on my NVidia 4090)
- Gemini with gemini-pro (currently pointing to gemini-1.5-pro)
- Claude with claude-3-5-sonnet-latest (at this moment this resolves to claude-3-5-sonnet-20241022)
- CoPilot via Microsoft Edge (I use it a lot and I like it for general-purpose questions with googlable answers)
Tuesday, November 19, 2024
RAD Studio 12.2 and AI helpers
This is an invitation to the workshop in Ljubljana next week. As the session will be in Slovenian language, so is this invitation ...
|
Friday, April 05, 2024
Delphi and Python, working happily together
Next Wednesday, 10th, I'll be talking about Delphi and Pyhon in Ljubljana. As usual for Slovenian workshops, the talk will be in Slovenian language so I'll continue this invitation appropriately ...
|
|
Saturday, December 02, 2023
Learn all about RAD Studio 12 in Ljubljana
Next week I'll present all about the new RAD Studio 12 in Ljubljana. As usual, the presentation will be in Slovenian language and so will be the rest of this post ...
Friday, July 21, 2023
CQLBr for Delph/Lazarus
It is so nice when you see how a small idea grows into a nice, rounded project!
Years age I wrote a unit that allowed you to write SQL statements as Pascal code (GpSQLBuilder). This has allowed me to write a code like this:
query := CreateGpSQLBuilder;
query
.Select.All
.From(DB_TEST)
.OrderBy(
query.&Case
.When([COL_2, '< 0']).&Then(COL_3)
.&Else(COL_4)
.&End);
It was a small project with minimum support -- as long as it generated SQL code that I've needed, I was fine with it. Much of the SQL language support was missing, there was no support for different SQL dialects and so on ...
Luckilly, Isaque Pinheiro liked the idea and converted it into a full-fledged library with support for multiple SQL dialects, much more complete SQL language support, units tests, installer, a ton of samples and more.
Sunday, July 09, 2023
Delphi High Performance, Second Edition
The second edition of my book Delphi High Performance is now released! Get all 452 pages of Delphi goodness with two new chapters and all the updated and improved content at Amazon or at Packt Publishing!
Wednesday, June 21, 2023
Delphi High Performance, encore!
It is so interesting to publish a book for the second time. In a way it is similar to reviewing and fixing old code--you go from "well said, old man!" to a "what the #$%! were you thinking when you wrote that" in a matter of pages. It also helps if you do pair-programming have great technical reviewers that help by pointing out the latter and add frequent "this may be obvious to you but I have no idea what you've just said" comments.
Big thanks go to Bruce McGee and Stefan Glienke for improving this book! It would be worth at least a half "star" less without them.
Update: The book is now available on Amazon and Packt Publishing.
Tuesday, May 16, 2023
International Pascal Congress in Salamanca
Friday, November 25, 2022
"Design Patterns", rescheduled
For the last Delphi meeting in Slovenia this year we have organized a small workshop about Design Patterns. As usual, it is intended for Slovenian programmers and will be given in the Slovenian language.
Sunday, October 16, 2022
"Design Patterns" workshop in Ljubljana
For the last Delphi meeting in Slovenia this year we have organized a small workshop about Design Patterns. As usual, it is intended for Slovenian programmers and will be given in the Slovenian language.
Tuesday, May 17, 2022
We'll meet again (finally)!
After two long-distance years we are finally moving back to normality, starting with a Slovenian RAD Studio meeting next Wednesday in Ljubljana.
Po dveh letih virtualnih konferenc vas končno spet vabimo na srečanje v živo! Za izgovor za druženje si bomo ogledali novosti v RAD Studiih iz zadnjih dveh let (10.4, 10.4.1, 10.4.2, 11, 11.1), predvsem pa bomo dogodek izkoristili za klepet ob hrani in pijači in ponovno spoznavanje.
Pridružite se nam 25. maja ob 9h! (klikni za več podatkov in prijavo)
Thursday, October 14, 2021
Slovenian Delphi 11 Webinar
Just a short notice for Slovenian readers - In case you missed it, next week you'll be able to join a Slovenian webinar about Delphi 11.
Wednesday, February 10, 2021
Readers-writer lock - Part 4: Improving TLightweightMREW
While the TLightweightMREW is quite handy, it is not perfect. There's a weird assymmetry in it. On all operating systems that Delphi can compile for, read locks are reentrant (recursive) while write locks are not. In other words, if a thread already owns a read lock, it can call BeginRead again and it will succeed. Write locks are different. If a thread already owns a write lock and calls BeginWrite again, it will either deadlock (on Windows) or raise an exception (on other supported platforms).
This is, however, relatively simple to fix. I have implemented a simple wrapper for the TLightweightMREW lock in TLightweightMREWEx. This new record uses internal TLightweightMREW to provide locking and adds some simple logic to implement write lock reentrancy. The implementation and accompanying test program rwReentrantWriter can be found at https://github.com/gabr42/examples/tree/master/Reader-writer%20lock.
Monday, February 08, 2021
Readers-writer lock - Part 3: Some numbers
In order to convince you that a readers-writer lock is not a stupid idea, I should finally show some numbers. In this article I'll present a minimalistic (but still real-life) example which allows us to compare different locking solutions.
All code from this article is available in project rwLock at https://github.com/gabr42/examples/tree/master/Reader-writer%20lock
Tuesday, December 08, 2020
Readers-writer lock - Part 2: Implementation
In the previous installment I introduced the idea of a readers-writer lock. Today I'll look into readers-writer lock implementations (yes, multiple) that are available in the Delphi run-time library.
Sunday, November 08, 2020
Readers-writer lock - Part 1: Why?
One of the pleasant surprises in Delphi 10.4.1 was the addition of a new readers-writer lock implementation TLightweightMREW. While it was probably not noticed by most of the users, I was quite happy to see it implemented.
So now you are asking yourself - what is this readers-writer lock and why am I so happy to see it in Delphi? Well, I'm glad that you're asking! Let me explain ...
In multithreaded programming (as most of my horror stories start), we frequently run into a problem of resource sharing. Two threads want to modify a shared resource at the same time and that can cause many problems, from information being overwritten to corrupted data and program crashes.
To fix this, we add resource protection. Usually that is just a critical section (typically through a TCriticalSection wrapper), or Delphi's TMonitor. Sometimes, however, protecting resources with a simple critical section causes an unnecessary performance drop, and that's when a readers-writer lock (may) come into play.
Saturday, May 30, 2020
OmniThreadLibrary 3.07.8
Version 3.07.8 is mostly a bugfix release. It fixes few small bugs and enables support for Delphi 10.4.
You can get it now on git, download the ZIP archive, install it with Delphinus or with GetIt (in few days).
For more information, visit OmniThreadLibrary home page or write your question on the forum.