Caltrain.com written in EMACS Lisp?

Maybe Give that EMACS a try again…

I don’t know why but I have had Lisp on the brain for the last few days. I think it was because I was thinking of switching back to emacs. How many times have you heard this story. “I used to use Emacs, but then after switching computers, I lost my .emacs file so I just switched back to Vi.” That’s me. After one quick look at the ubuntu app search, I found that they are on EMACS 21 and the world and all their new goodies (Rails on EMACS are on EMACS 22. After about 20 minutes of that thought, I happily went back to using Vi. When I have a spare week, I’ll spend the time re-introducing myself to EMACS and it’s internals… or so I thought.

LispBox & Web Serving

Later on that evening, I did read a blog entry on some lisp programming that pointed to Peter Seibel’s LispBox. Aha. He gets it. I don’t want to screw around figuring out stuff… I want a one click install to the magical lisp stuff. I’ve tried to setup EMACS in the past to have all the bells and whistles necessary to do C++ work. That isn’t an easy task. This was not going to be like that, so I gave it a try. Specifically I tried the Allegro Install since the disclaimers said it would have the most magic. I don’t mind commercial software and I want to see the polished tools.

I ran the software. Very nice. It has the famous SLIME extension to EMACS already lit up. It definitely had that feel like… this isn’t your normal Editor/IDE environment. I’ve used EMACS in the past, this was a bit slicker. It reminded me a lot of the Smalltalk browser/eval system. This might be a little bit like what those old Symbolics guys would rant about. After I got over appreciating that, I immediately went to the chapter in his book on web programming. I tried out the examples. I got some web pages to serve and then after noticing the time, pretty much stopped there.

irb

I needed to get back to work on some other stuff, and that whole experience was fun for about 20 minutes. The next step for me is to spend some time learning about this particular REPL environment. I’m just not even remotely familiar with it to be productive.
I need to learn the Ruby equivalent of…

“what is that Ruby method on a string?? hmm.. I’ll just do.
irb
“”.methods.sort
Oh yeah, that is the one.”

Done. This is not a Lisp failure, this is a me failure. I just need that tool in my tool chest before I spend any more time on this. Until then, it is good to know, though, that when I have the time, the environment is there waiting for me… all set up and ready to go.

Thought. Is there a Rails for Lisp?

My curiosity from the web exercise did leave me with a question. Was there an equivalent of Rails for Lisp. I’ll bet with a completely dynamic environment like this, there has to be something like Rails.The web stuff in the Practical Lisp chapter was pretty barebones. Any good web development framework today needs to be on par with Ruby on Rails. After a little searching, I found a few scraped together libraries. None were top-to-bottom frameworks. There were lots of posts on the Reddit ‘fiasco’. There are also a lot of good posts on Erlang which does have a Rails like framework called ErlyWeb (more on that later). There is also Arc… but we’ll have to wait until that comes out to see if that is going to be interesting. Nope, it doesn’t look like the community has anything yet.

Hung Up on Threads Again

One interesting thing to note. The lisp community (like a few other languages) seems to be hung up on having a multi-threaded lisp implementation for web serving. Why? If the LispBox sample is any indication, only a few of the frameworks were capable of performing the samples in the book. Also, from the Reddit fiasco posts, there was mention of the servers having deadlocking issues. Why are they hung up this? Do they really want to follow in Java’s footsteps on this? Unfortunately, this isn’t a ding on Lisp. A lot of languages have problems with the hosting environment. The only major one that doesn’t is PHP. In an old post on PHP, I elaborate a tiny bit on the benefits of the PHP multi-process model.

For the Lisp situation, I don’t know enough to understand why most of the web stuff requires a multithreaded common lisp system. Is it the sexiness of having all the data available as shared state? Maybe the warmup time for the runtime is quite high. More likely, it is the memory footprint. I took a look at mod_lisp, and it just uses sockets to communicate to a long running process. I think the community should look at multi-process based solutions if they want to have scalability and reliability. They could then use any of the runtimes that they have available right this moment.

Back to the Real World

Anyways. I resumed my work back in the real world. Towards the end of the day, however, I was scanning one of the iphone dev groups and found this post by Jesse Andrews. The subject was about a caltrain schedule app for the iphone. That sounded interesting and I could actually use it. So I checked out the post. As I got to the bottom of the post, he mentions that he found some “hunks of lisp” in the html of the site.

What? Lisp? Again :-) I got excited and raced to do the ‘view source’ on the page. What would it reveal about the framework that they used for their site??

(while (re-search-forward "</th><td" nil t)
  (backward-char 3)
  (save-restriction
    (narrow-to-region (point) (progn (end-of-line) (point)))
    (goto-char (point-min))
    (let ((s '(1 1 3 2 3 2 3 2 2 3 2 3 2 2 3 2 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 2 3 2 3 2 3 2 2 3 2 3 2 2 1 1 1 1 )))
      (while s
        (re-search-forward "\\(<td[^<>\n]*>\\)\\([^\n<>]*</td>\\)")
        (replace-match (format "\\1<!%s-%d%s->\\2" "-" (car s) "-"))
    (setq s (cdr s)))
      (or (looking-at "</tr>") (error "Foo")))))

I’m not a lisp expert but that sure looks like EMACS lisp. So this doesn’t count as a lisp site. It might qualify for a daily WTF, though.

Hmm. Still, maybe I should look at EMACS again. :-)

This entry was posted in General. Bookmark the permalink.

6 Responses to Caltrain.com written in EMACS Lisp?

  1. Kim says:

    Emacs can run anything else, so why not a web site :-)

  2. joe says:

    Two common lisp web frameworks I know of: Uncommon Web, and this new one the defmacro guy’s working on: http://www.defmacro.org/ramblings/weblocks-demo.html

  3. Diogo says:

    It isnt properly emacs lisp. It could be, but it could be simply and abstraction layer on top of Common Lisp. Both Emacs-Lisp and Common Lisp give you the tools to create a completely different language on top of itself.

    In this case, looking at rhe name of the functions, it sure looks like it, but then again, you can’t be exactly sure unless you check up on it or ask someone.

  4. moo says:

    that just looks like some inline sexps to muck about with html.

    not that there’s any reason not to write webserver in elisp though: you could probably patch emacsclient to pass environ variables, and then use it for CGI dispatch. evil!

  5. Chris Barts says:

    It’s only evil if Emacs lives solely in the ‘text editor’ box in your mind. However, that’s never been a good way to think about Emacs. Emacs has always been a computing environment (something more immersive than a shell, but less hardware-oriented than an operating system) where the organizing metaphor is ‘editing a buffer’. That buffer can be a file, a directory, a sound file, or just about anything else. Of course, what Emacs really is is a Lisp compiler and bytecode interpreter (with a garbage-collection system to help things along). Thought about in that light, running a website on it is much more comprehensible.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>