Recent

Author Topic: Ask AI to make fast HEX to byte converter  (Read 266 times)

backprop

  • Guest
Ask AI to make fast HEX to byte converter
« on: July 19, 2026, 11:52:25 am »
Ask whatever AI to make fast HEX to byte converter in FPC with respect of whitespaces, comma, including proper handling invalid characters and odd nibble counts cases, handlind input from buffer and files/streams and you will get miltiple "ingenious" versions and at end useless and overcomplicated slow code and a lot of wasted time. But first you need to "teach" it elementary things about Pascal syntax,  semantic, practice and optimization...

That much about "AI", simple optimization and fairly common task.
« Last Edit: July 19, 2026, 12:16:13 pm by backprop »

LemonParty

  • Hero Member
  • *****
  • Posts: 618
Re: Ask AI to make fast HEX to byte converter
« Reply #1 on: July 19, 2026, 12:44:44 pm »
By the way, I was trying to make AI work with assembler.
Gemini few month ago show clear missunderstanding of assembler code.
You can only get consistent results from AI when you ask questions about well known themes otherwise the results are disappointing.
Vibecoders generate thousands of lines of code but the question about quality of this code is open. Is this code uses optimal algorithms? Is this code uses additional memory?
I don't know for sure, but I have feeling that most code generated by AI has an average quality. The reason for that is that AI itself was studied on averege code.
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

paweld

  • Hero Member
  • *****
  • Posts: 1701
Re: Ask AI to make fast HEX to byte converter
« Reply #2 on: July 19, 2026, 12:51:56 pm »
In the attachment, you'll find what Claude (Fable 5) generated. The only change I made was to remove the absolute path to the file in the “hextest.pas” file, because in my environment (Windows 10), the “/tmp/” path doesn't exist and the program was crashing.

As a prompt, I pasted the text of your post, which is:
Quote from: backprop
make fast HEX to byte converter in FPC with respect of whitespaces, comma, including proper handling invalid characters and odd nibble counts cases, handlind input from buffer and files/streams and you will get miltiple "ingenious" versions and at end useless and overcomplicated slow code and a lot of wasted time. But first you need to "teach" it elementary things about Pascal syntax,  semantic, practice and optimization
I received a reply in less than 10 minutes
Best regards / Pozdrawiam
paweld

LemonParty

  • Hero Member
  • *****
  • Posts: 618
Re: Ask AI to make fast HEX to byte converter
« Reply #3 on: July 19, 2026, 01:11:58 pm »
paweld, from first sight a good code. That is nice that AI know how to use advanced records. And also nice that it uses enums.
Is Fable 5 the best current model on the market?
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

paweld

  • Hero Member
  • *****
  • Posts: 1701
Re: Ask AI to make fast HEX to byte converter
« Reply #4 on: July 19, 2026, 01:23:08 pm »
From Anthropic - yes. I don't use any others AI, so I can't say. I also rarely use Claude, mainly Sonnet 4.6 for JavaScript and for help with Linux configuration, so I can't say much about how it handles Pascal.
Best regards / Pozdrawiam
paweld

 

TinyPortal © 2005-2018