November 19, 2009

Как программировать скоростные сервера в Лиспе

17 Ноября я презентовал мои идеи о конструкции скоростных серверов в Лиспе Монреальской группе программистов Scheme и Лисп.

Идеи презентации исходят из моей экзаменации веб-серверов Antiweb и TPD2 (смотрим презентацию Джона Фремлина о TPD2 Шибуйским Лисперам здесь). Один недостаток обоих серверов - довольно наивный подход к конкуренции и синхронизации. Я решил конструировать новый веб-сервер на базе этих примеров и размышлений, HTTP DOHC (DOHC - Dual Overhead Camshaft, когда в двигателе автомобиля двое распределительных валов в головке цилиндров - имя выбрано из за связанной двойной системы демультиплексирования в сервере).

Планирую дальнейшее развитие HTTP DOHC в полноценный веб-сервер, с интерфейсом схожим с Hunchentoot 1.0.

Ещё хочу обратить внимание - освободилось личное время для коммерческих проектов. Пишите на если есть что интересное.

November Montreal Scheme/Lisp User Group presentation

On November 17, I gave a presentation to the Montreal Scheme/Lisp User Group about developing high-performance network servers in Lisp. I looked at the lessons to be learned from existing Common Lisp web servers, notably Antiweb and TPD2, tried out some of the ideas in my own new under-development web server HTTP DOHC along with some new ideas about threading and concurrency, and put the results of my findings into the presentation.

If you're interested in the topic, you should also watch John Fremlin's TPD2 presentation to the Shibuya Lisp user's group.

I plan on making HTTP DOHC a full-featured Common Lisp web server with an interface that's somewhat compatible with Hunchentoot 1.0.

In other news, I now have time available for contract work. Get in touch at

Шаблоны и генерация кода

Читатели Russian Lisp Planet уже знакомы с системой archimagа cl-closure-template. Повторять все подробности не буду, но сделаю несколько комментарий о этом подходе к шаблонам.

Главное что надо заметить - cl-closure-template является не системой шаблонов, а системой генерации систем шаблонов. Это примерно та же разница между любым парсером, и парсер-генератором yacc. Если посмотреть на диаграмму систем шаблонов на Википедии, то по сравнению cl-closure-template берет шаблон как параметр и выдает программу, которая берет дату и производит документ.

Такой подход дата генерации истинно Лисповский, и имеет множество превосходств над обычными системами шаблонов. Например можно совместить его с Common Lispовской системой reader macros и получить полноправные новые правила синтаксиса (так сделано в CL-INTERPOL и uri-template). Или пропустить генерированный код через систему трансляции типа Parenscript и получить возможность использовать те же самые шаблоны в разных языках программирования, как и делается в cl-closure-template и uri-template. Так же открывается возможность использования методов частичной эвалюации (partial evaluation) для генерации оптимизированного кода.

November 18, 2009

Templates and code generation

Earlier this month Google released Closure Templates, a new templating library intended for generating HTML. Who cares? I personally dislike HTML templating, and avoid it whenever possible in lieu of s-expression based generation tools like CL-WHO. At first look, Closure Templates didn't seem to be anything new or useful.

The one thing that makes Closure Templates somewhat interesting is that the library works in both Java and JavaScript, so you get client and server-side templates in one place. I did a similar thing with uri-template by having the URI template expand into code that executed in both Common Lisp and JavaScript via Parenscript (here I have to state that despite being an author of a templating library, I still dislike templating libraries and even find my own creation annoying at times).

About a week after Closure Templates was released, Andrey Moskvitin (archimag) wrote an implementation in Common Lisp (interesting note: it took him only five days and 1/15 the number of lines of code as the original). The resulting system, cl-closure-template, similarly generates JavaScript via Parenscript.

I still didn't understand the motivation. Yesterday, Andrey was kind enough to explain it. Those pampered by web development in Common Lisp using s-expression HTML generation tools simply don't encounter the problem of trying to fit HTML templating onto the paradigm of incremental page updating via AJAX. So if you want to build an AJAX web application and use HTML templating, give cl-closure-template a try.

[Blog metanote: if you're reading this blog through its feed, you will shortly see this post show up in Russian. a CONS is an object which cares is now syndicated on Russian Lisp Planet, and I'm going to be writing Lisp-related posts in Russian as well as English. All such posts will be tagged 'lisp-ru'. Filter out that tag if you don't want the Russian version of the posts to show up in your feed reader.]

November 5, 2009

Recruiting Puzzles

One of the most interesting parts of Peter Seibel's Coders at Work (see my review on Slashdot) was Peter Norvig's discussion of the Google programmer hiring process.

The impact of a bad hire on a programming team can be extremely negative - vastly increased code maintenance costs and reduced morale and productivity. "Hire slowly" is now becoming an ingrained mantra in software companies. Despite this, effective processes for evaluating candidate programmers still seem to be little known.

Interview puzzle questions (made (in)famous by Microsoft) as a tool in the hiring process came up in Norvig's interview. Not surprisingly he is against the idea. For a while puzzle questions were a fad in programmer interviews, based on the (unfounded and unverified) assumption that they were a predictor of coding prowess.

To examine why puzzle questions are a dumb idea, you need to look at the objectives you are trying to fulfill when hiring programmers:

  1. Hire someone who is good at programming.

  2. Hire someone who is good at programming as part of your team.

There is no need to resort to unrelated tasks with a low degree of correlation to see whether someone will help fulfill these objectives. A candidate can be assessed directly and efficiently by inviting them for three hours of pair programming.

Why are you still wasting time asking how many golf balls can fit in an airplane?