Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling Lisp from Ruby/Rails?

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

like image 895
tjr Avatar asked Oct 29 '09 16:10

tjr


3 Answers

There are a couple ways that come to mind:

  1. Execute the lisp program with Process. Communicate with the Lisp program via standard in, and have the Lisp program output its result over stdout.

  2. Do the same thing as above, but communicate via named pipes instead. Have your Ruby code write data into a named pipe, then have the Lisp program read from that pipe, and write data out over another named pipe which you then read with your Ruby app. The Lisp program can either run in the background as a daemon that checks for data on its incoming pipe, or you can fire it up as-needed using Ruby's command-line utilities (as above).

  3. Find a Ruby-Lisp bridge. I have no experience with such a bridge (nor do I know off-hand if one even exists) and I think the above 2 mechanisms are easier, but your mileage may vary.

like image 196
mipadi Avatar answered Sep 25 '22 05:09

mipadi


Another simple way is to have Lisp running a HTTP server and contact Lisp from the outside via HTTP requests.

like image 35
Rainer Joswig Avatar answered Sep 24 '22 05:09

Rainer Joswig


CL-JSON supports JSON-RPC. It's very easy to set up with a web server such as Hunchentoot to have a Lisp-based web service that anything that speaks JSON-RPC (e.g. this) can use.

like image 40
jlf Avatar answered Sep 25 '22 05:09

jlf