digitalmars.D - D and AI
- Lars Johansson (32/32) Feb 11 I’m learning D, and as an experiment I asked Claude.ai to convert
I’m learning D, and as an experiment I asked Claude.ai to convert
a C connector to SAP ERP system to D. Claude started by saying
converting C to D is easy. I pointed to the C github library.
Claude then requested the needed SAP resources from me, and in
minutes created a DUB project, with a makefile and documentation.
There were one bug, a string conversion Claude told me was not
handled in the C connector, but by the callers of the C
connector, Claude did a fix and the D connector run flawlessly.
Without my request Claude created some testcases.
I then asked Claude to parse an XML file to set up a SAP RFC
call. Not only did Claude do this but he understood by the XML
structure to create a simple workflow engine without me asking.
Claude first created his own XML parser, I told him to use DXML
instead which he did. Now I have a primitive workflow engine that
can extract (and possible update) data from SAP.
I asked Claude how he did the conversion.
“No tools — I did it manually by reading the C header
(sapnwrfc.h) and translating by hand based on my knowledge of
both C and D type systems.
The mapping is mostly mechanical: typedef → alias, C enum → D
enum, C struct → D struct, function declarations get extern(C)
linkage. The main decisions were SAP_UC (C char16_t) → D wchar,
opaque handles → void*, and callback function pointers → D
function pointer syntax.
The wrapper layer (Connection, FunctionModule, etc.) was
modeled after X's extension architecture — same class hierarchy
and method patterns, just expressed in idiomatic D with RAII,
exceptions, and UTF-8↔UTF-16 conversion.”
Claude did not use any help from BetterC or any of those
tools they are for humans not AI.
I now have an D SAP connector which I have no use for, it was
just an experiment. In total there is 75K D code.
Feb 11







Lars Johansson <lasse 11dim.se>