Several years ago (2019) I tried for the first time to see if I could write a client in Prolog for the BaseX XML database. That first attempt failed at that time because I was unable to set up an http connection.
Before starting that project, I had first implemented the full server protocol in R (see RBaseX). At that time, I had very little experience with XQuery. However, I noticed that both Prolog and also XML/XQuery handle the concept of ´database´ differently than traditional relational databases and that led me to the personal question of whether combining Prolog and XQuery has advantages.
From experience with RBaseX, I knew that once you can set up a connection, further implementation of the protocol is relatively easy. So my idea then was that it might be better to first set up that connection in C++ and then continue using that connection in SWI-Prolog.
The work on the C++ connection has now resulted in a shared object library that is on Git since yesterday (GitHub - BenEngbers/libBasexCpp: C++ client for BaseX).
Now before I start working on ProBaseX again, I have some questions.
In your opinion, does it make sense to put energy into this project? Is there a need to link Prolog to XQuery?
If you guys think this project makes sense, are there any concerns I should consider?
My idea now is to implement a bridge to the shared library from swipl. However, I have very little experience with C++ and no experience using the swipl C++ interface. Are there any points I should consider when implementing the shared library?
I guess that can all work and surely if you publish this as a pack you’ll make some people happy. You could also consider the Janus Python binding, which may make your life a lot easier (assuming there is an XBase binding for Python).
Whether you need Xbase to start with is another issue. SWI-Prolog can parse XML and xpath/3 can be used as the basis to define quite nifty queries on the parsed XML. That has limited scalability as there is no indexing involved, so it mostly applies to relatively small collections of not really big XML files. Other people have converted XML to a series of Prolog predicates and query that. That too can be an attractive approach. It all depends on how much XML you have and what you want to get out of it.
I see on BaseX’s site that there is a Python implementation of the server protocol but at first glance I can’t really judge whether it is as complete as my C++ (or R) implementation. And besides, that would require me to learn yet another programming language…
I have previously worked with xml and xpath/3 in SWI-prolog and seen that it is useful in its own right. The advantage I see for now in using BaseX is that BaseX is really a database built for large files. Moreover, the latest version of that database works with XQuery 4.0. The latter seems like a big advantage to me.
In my old age, I still enjoy programming and experimenting. So I think I will work on this after my vacation anyway. And of course, as a retiree, I have all the time
If you want your C++ code reviewed (especially if it uses SWI-cpp2.h), or advice on the best way of doing something, just ask; the offer also extends to Python code (I used both of these a lot for 10 years at Google; I had “readability” status, so I read a lot of other people’s code). Caveat: I’ve been away from Google for 7 years and have only partially kept up with the new features in C++ and Python.
Also, you can do worse than follow the Google style guide for your programming language.
As a retiree, I have the freedom to arrange my time as I see fit. This is nice but it does become increasingly difficult to pay sufficient attention to all activities at the same time. Trying to simultaneously learn Japanese, learn to play jazz guitar, learn C++ to work on a database client and also devote enough time to my family is difficult. ;). As a result, I have spent little time on Prolog in recent years.
I enjoy figuring out all kinds of things on my own. But I also know by now that I should ask for help in time when I don’t know how to proceed. So I really appreciate the offer to help when I have problems with something.
I hope to contact you soon not only for troubleshooting but also for discussing the right approach to work.
I think we got the message
Actually I quite envy you being a retiree (whatever you retired from) and (though not one yet) I try to behave as one as much as I can