101

It obviously is possible to write almost any kind of application in almost any programming language, especially in such a powerful one as Lisp (be it Scheme or Common Lisp). But is it practical to use it for web development? If so, what should be a good starting point? Where can be found the proper resources (tools, libraries, documentation, best practices, examples, etc.) for a project of this nature?

5
  • 2
    Depends on what you mean by "practical." Possible, yes. Practical, probably not for most. Do you plan on having your site hosted? Are you going to operate your own dedicated box where you'll have root control? How much effort are you willing to put into it?
    – core
    Feb 20, 2009 at 18:47
  • Leonardo, I'm putting together a book on this subject now, and would like to get feedback from web developers that are interested in Lisp. If you want, can you please let me know how you came on the idea of using Lisp, and what you'd like to see in such a book? [email protected]
    – user62715
    Apr 5, 2009 at 22:28
  • @chris - I recently set up Scheme hosting for some of my side projects; it was easier than I thought it would be - gcbhacks.dreamhosters.com/scheme-web-apps
    – gcbenison
    Feb 27, 2012 at 20:15
  • 2
    Go read Paul Graham's essays. I doubt there is anything he missed in a discussion of using LISP for web applications, plus he's a great writer. paulgraham.com/avg.html his home page is: paulgraham.com/index.html Jan 29, 2015 at 18:20
  • Fellow googlers: there are more and up to date answers on the awesome CL list.
    – Ehvince
    Apr 26, 2017 at 9:11

11 Answers 11

81

Yes, web development is one of Common Lisp's strengths today.

  • As a web server, use Hunchentoot, formerly known as tbnl, by Dr. Edmund Weitz.

    You can run it as a back-end to Apache using mod_proxy as a reverse proxy, or as a stand-alone server.

  • Various HTML generation solutions are available, from PHP-style templates to Lisp macro hacks to XSLT. Just take your pick.

    HTML-TEMPLATE is one example.

  • Closure XML is available for XML parsing, serialization, XPath 1.0, XSLT 1.0. There is also Closure HTML for HTML tag soup parsing.

    (Full disclosure: I'm the maintainer of Closure XML and Closure HTML.)

  • If you like, Parenscript can make your JavaScript experience lispier, but you can also write plain old JavaScript yourself, of course.

    Another cool JavaScript enhancing solution in jwacs, which is written in Common Lisp and transforms JavaScript to add continuation support.

  • Web service projects might require an HTTP client in addition to a server.

    Drakma is the library to use for that today.

    PURI is useful for URI manipulation.

    And there is more! One starting point is cliki, for example cliki.net/web.

On the web, nobody knows your server is written in Common Lisp :-)

4
30

Web development in Common Lisp is both effective and fun.

Some examples:

CL-WHO allows you to write HTML without forgetting a closing tag ever again.

Weblocks lets you define forms declaratively with built-in validation:

(defview signup (:type form :caption "Sign up")
  (username :satisfies #'valid-username)
  (password :present-as dual-password :parse-as dual-password)
  (receive-newsletter-p :present-as checkbox :parse-as predicate))

It also supports AJAX in a fully automatic manner, falling back to normal links if the browser doesn't support it.

cl-prevalence is an incredibly simple alternative to SQL.

Quite a lot of people are using these technologies lately for mission-critical applications -- with success.

Most important CL open-source projects in fact do have excellent community support.

19

There are some web frameworks out there for web development. Have a look at:

If you want well supported lisp tools then you'll need to pay for them. There just isn't a very big community around the open source tools so they don't have the same level of documentation/adoption as, say, Django on Python.

Here are some commercial lisp products:

Its also worth noting that Reddit was initially built in Lisp, but the authors later migrated to Python, citing a lack of well used and documented libraries. (link)

2
  • He does say that libraries were the "biggest issue", but right before that he said "reddit would not run on my Mac"; at the time, there was only one threaded CL for the Mac, which couldn't run their low-level socket code. That sounds like at least as much of a dealbreaker.
    – Ken
    Feb 17, 2009 at 21:43
  • 3
    I'm a big Lisp fan, it's replacing Python for me. But I work in C++. I can find other Python programmers who will understand Python prototypes, but until the present Lisp revival has more success, I can't use it at work without endless questions "why didn't you use Python or Ruby?"
    – Aaron
    Feb 24, 2009 at 18:02
11

I can't speak to other frameworks, but I've had very good luck using Hunchentoot for a webserver (it works fine on its own, or you can put it behind Apache). What really makes it shine (this will probably come as a shock to some) are the libraries!

  • Use CL-WHO to write effortless HTML in a lisp-style syntax
  • Parenscript allows you to write code that compiles to javascript
  • For database connectivity use Postmodern to talk to PostgreSQL

What I really like about using CL for the web is that you can tweak it all as it is running. You always have a REPL up and running your server code, you can then connect to that REPL and change or inspect how the code is working, all without having to stop anything. I've redefined functions while the site is running, the next time the function is called, it simply picks up the new code and works.

2
  • 1
    Are you aware of anything that will make LISP interfaceable with MongoDB? Sep 30, 2017 at 4:26
  • 13 years later I have to say that this post aged like a fine wine. I am in a need of a GUI for an application (written in Common Lisp) which can be run on both Windows and Linux, locally and client-server. I unfortunately don't have enough time to make multiple native clients or bother with Qt/WxWidgets. React.js and alike were too bloated. Cl-who + Parenscript were just fine, even in 2022 where this stack is quite "ancient". CL has enough power to compensate for the simplicity of these libraries.
    – eMko
    Jun 6, 2022 at 20:16
9

To further help dispel the myth that there are no Lisp web frameworks, here are ones that have not yet been mentioned:

Obviously a lot of people seem to think Lisp is good enough for writing a lot of web frameworks.

I don't use or endorse any web frameworks. I prefer to build web applications by combining together orthogonal tools (David Lichteblau has mentioned some good ones) using design patterns in a way that is actually appropriate to the application you are building, and that is the approach I recommend. Common Lisp provides both a wealth of such tools, and an unmatched ability to combine them.

Adam Petersen published an excellent introductory tutorial for how to start building Lisp web applications in this style last year:

http://www.adampetersen.se/articles/lispweb.htm

8

I think one can say yes without much hazzle.

  1. one of the first HTTP server was cl-http

  2. The scheme people around DrScheme have spent a remarkable amount of time on it:

  3. www.franz.com runs on their own Webserver (AllegroServer) and webframework (webactions)

  4. If you are in doubt check the common lisp packages from Edi Weitz. They usually work.

So yes one can do "serious" web-programming with Common Lisp. I for my part am currently undecided to follow some Common Lisp route or Ruby on Rails. I prefer both over anything .NET....

4

Paul Graham's company Viaweb wrote a product in Common Lisp that subsequently became Yahoo Shops. Apparently Yahoo subsequently re-wrote it in C++. There are quite a few web resources for Lisp progamming.

3
  • 1
    If that's true about Yahoo, some might see this as a failure of CL as a web language. But I would see it as a success of CL as a web prototyping language.
    – gcbenison
    Feb 27, 2012 at 20:17
  • 4
    I would hardly consider the rewrite a failure, as Paul Graham said himself in the notes on Beating the Averages: "In January 2003, Yahoo released a new version of the editor written in C++ and Perl. It's hard to say whether the program is no longer written in Lisp, though, because to translate this program into C++ they literally had to write a Lisp interpreter: the source files of all the page-generating templates are still, as far as I know, Lisp code."
    – protist
    Apr 1, 2013 at 12:14
  • viaweb was not prototyped in common lisp in order to rewrite in another language, c++. it is intended by the producers of it to be written and run in lisp due to various obvious reasons stated by him, languages power, rapid , yes prototyping, and rapid production, he knew lisp very well etc. they run it with the version they have written in lisp, parts of it was in lisp actually. after ahooacquired it they have according to rumor rewrited it, i am not sure. it is the choice of the acquirer, thye could even wirte in vbasic, or pascal fortran.
    – sçuçu
    Feb 8, 2014 at 15:14
2

You can find some stuff about tooling for Lisp web applications in this question.

It might also be worth having a listen to Stack Overflow Podcast 27 where the Reddit guys talk a bit about their experience of runnig a website on Lisp (and their switch to Python).

2

Opinions vary. The common wisdom is: Better use a different language, or rather a different web stack, such as LAMP, .NET, Ruby on Rails, Java. The well-known successful web project in lisp was Paul Graham's ViaWeb. Reddit was initially implemented in lisp, but then switched to python. If you do decide to use lisp, try Seibel's book: Practical Common Lisp.

3
  • 1
    Any chance your could add a little more FUD to your post?
    – jrockway
    Feb 17, 2009 at 19:25
  • @Yuval is right. This is common wisdom. Reddit did switch. I think the post is asking whether there's any truth behind that common wisdom.
    – Steve Rowe
    Feb 18, 2009 at 6:32
  • 1
    @jrockway and Steve Rowe - Common wisdom is there for a reason. I do not think this is FUD. I have not heard about a successful web site written in LISP since ViaWeb. Please do correct me if I am wrong. I believe programming language should be used according to their merits, rather than ideology.
    – Yuval F
    Feb 19, 2009 at 7:50
2

Looks like a lot of Orbitz was or is written in LISP.

0

Have a look at Allegro Common Lisp. It has some libraries, including a web server, specifically for web development.

Not the answer you're looking for? Browse other questions tagged or ask your own question.