views:

1203

answers:

6
+14  Q: 

Lisp+PHP ?

At the moment I use PHP for almost everything I develop for the Web but its linguistic limitations are starting to annoy me. However, as I developed some practices and maintain some PHP libraries that help me a lot, I don't feel I'd be ready to just switch to LISP throwing away all my PHP output. It could even be impossible on the servers where all I have access to is a regular LAMP hosting account.

Ergo, my questions are: Could LISP code be just combined with PHP one? Are there solutions for side-by-side LISP/PHP, interface for their interoperability or perphaps just an implementation of one for the other? Or is it a mutually exclusive choice?

+5  A: 

It's not a mutually-exclusive choice, you can run both on one system, in the same way that perl and php (for example) are run side-by-side on many systems.

There's a good post here on a similar topic, which suggests using sockets to communicate between both languages -

If you want to go the PHP<->Lisp route the easyest thing to do would be to make PHP communicate with your Lisp-process using sockets.

http://php.net/manual/en/ref.sockets.php

http://www.sbcl.org/manual/Networking.html

This approach does still leave you with the potential added complexity and maintenance issues you get from having 2 languages in your project, but might be a fit for your particular use case.

ConroyP
+1  A: 

Unfortunately I can't think of any libraries for that, however I was in a similar situation, where I had PHP code, but got tired of "trying" to code logic(game logic) in PHP, so I used PHP sockets to connect to Lua, thus now I program all the serverside logic in Lua and use PHP(LAMP setting) as my frontend server.

Hope that helps.

Robert Gould
+4  A: 

You would most likely not want to write code in PHP once you've started developing in Lisp. (New capitalization since circa 80s, by the way)

Hunchentoot is a popular server that gives you the basics in terms of connecting dispatchers to requests. There's a series of screencasts on writing a reddit clone at LispCast.com

UnCommon Web (sounds like a pun on Peter Norvig's description of Scheme in PAIP) is from what I can tell a more complete framework based heavily on the idea of continuations, much like Seaside for Smalltalk.

Weblocks is yet another continuation-based web framework that looks nice. The author (at defmacro.org) writes good articles, and I like what I've seen in the sample app for Weblocks.

Mikael Jansson
Not tooth, as in bite, but toot, as in honk.
jfm3
+2  A: 

I'm in pretty much the same situation at the moment. I have a lot of PHP under my belt, but the language really begins to annoy me. I have experimented with different languages, but have tinkered a lot with scheme recently, and I'm contemplating a gradual switch. Maybe we should start a user-group or something?

Coming from a PHP background, you're probably used to working with a thin level of abstraction to the HTTP protocol. I think this is something that actually makes it easier to transition into a new language; Especially one, where there isn't one dominant framework. In this way, PHP and the Lisp community have some similarities (But so does other fragmented open source platforms, such as Python and Perl).

One problem with Lisp is that there are so many to choose from. I have decided that I prefer Scheme over Common Lisp, so that narrows it down a bit. After some experimenting, I'm now focusing on plt-scheme, which seems to be the one Scheme with most momentum. Amongst other things, it has a web-server bundled with it.

troelskn
+1  A: 

I recommend you to give a try at Weblocks.

badlambda
The URL should behttp://common-lisp.net/project/cl-weblocks/
Friedrich
A: 

For normal web page development in PHP, Ive made a lib called xilla_tags.

Overview here

There are also some good techniques on Jacob Hanssens bitchware site.

gord