Calling Lisp from Ruby / Rails?

How can you call a Lisp program from a Rails application? ... For example, let the end user enter a block of text in a Rails web application, have text processed by the Lisp program, and return the results to the Rails application?

+7
ruby ruby-on-rails lisp
source share
4 answers

Another easy way is to start Lisp HTTP server and contact Lisp from outside through HTTP requests.

+9
source share

There are several ways that come to mind:

  • Run the lisp program with Process . Communicate with the lisp program using standard input, and the lisp program prints the result to stdout.

  • Do the same as above, but share named pipes . Let your Ruby code write data to a named pipe, then lisp reads from that pipe and writes data to another named pipe, which you then read in your Ruby application. The lisp program can run in the background as a daemon that checks the data on the incoming channel, or you can run it as needed using the Ruby command line utility commands (as described above).

  • Find the Ruby Bridge - Lisp. I have no experience with such a bridge (and I don’t know if it exists), and I think that these two mechanisms are simpler, but your mileage may vary.

+11
source share

CL-JSON supports JSON-RPC.It is very easy to set up a web server like Hunchentoot to have a Lisp-based web service, which is all that JSON-RPC says (like this ).

+4
source share

This will depend on how often this happens.

  • If it is once in the blue moon, then just run the backquote command, which starts the lisp interpreter, or pops up and writes to it.
  • If this happens all the time, you will need to have lisp already running, so then the question is how to communicate. Any of the interprocessor mechanisms will work, but I would suggest a TCP socket for development, testing, and production flexibility.
  • If this happens a million times a day, but the lisp toy is good enough, just implement lisp with Ruby classes. This was done as chapter 8 of the Ruby Practical Projects.
+2
source share

All Articles