I have two code files: one written in C ++, and the other in Common Lisp. There is a certain functionality implemented in the Lisp code base that I would like to get from my C ++ code. I was looking for an interface of external functions to call Lisp functions from C ++, but could not find them (I found FFI for another direction mainly). So I decided to implement some form of RPC that meets my requirements:
both codes will run on the same computer, so the ability for remote calls is not important.
the input from C ++ will be a Lisp-style list, which will be used by the function from the Lisp code for input.
this call will be made 1000 times per code execution, so performance for a remote call is critical.
So far, I have learned from various resources on the Internet that possible solutions are:
Sockets - configure an instance of Lisp code that will listen for function calls from C ++ code, run a function on a given input, and return the result in C ++.
XML-RPC - configure the XML-RPC server on the Lisp side (this will be easy since I use Allegro Common Lisp, which provides an API that supports XML-RPC), and then use one of the many XML-RPC libraries for C + + for calling on the client side.
The pros and cons that I see with these approaches are as follows:
Sockets are a low-level construction, so it seems to me that I will need to do most of the connection management, read and analyze data on sockets, etc. by yourself.
XML-RPC, , , , HTTP, UNIX. , , XML-RPC , .
- ? XML-RPC RPC? , , . .
EDIT: . f, Lisp ( , ++ ). L1 L2. , :
- L1 L2 ++ Lisp ,
- f Lisp L1 L2 ++,
- ++ .
L1 L2 :
L1 - , 100 , 3-4 .
L2 , < 10 , 3-4 .
, RPC, , 100 /1000 . while ++-, . , 10 -100 . f : . , . , .