» tagged pages
» logout
Lisp
Return to Lisp

Planet Lisp

(or Cancel)

(Editing anonymously: to be credited for your changes, login or register a new account)

other page actions:

Tags Applied to this Topic

1 person has tagged this page:

Lisp Wiki Pages

Planet Lisp

Michael Weber: Erlang meets Lisp (again)

Lisp Logo (by Conrad Barsky)

There seems to be an interesting attraction between Erlang and Lisp and several times it has been tried to marry them, in different ways. Bill Clementson wrote about it already in his article Concurrent/Parallel Programming - The Next Generation. Here is an updated list:

  • ETOS, an Erlang to (Gambit) Scheme compiler, dating from 1997, was probably the first attempt to combine Erlang and Lisp. One of the things that came out of ETOS is Marc Feeley's paper A Case for the Unified Heap Approach to Erlang Memory Management.
  • Erlisp was another attempt, this time in Common Lisp. It's a (partial) reimplementation of the Erlang concurrency model. I don't think anybody is working actively on it at the moment.
  • CL-MUPROC is a Common Lisp library which strives to offer some of the multiprocessing abstractions found in Erlang, very much in the same way as Erlisp. It implements some of Erlang's fault-tolerance mechanisms, but not yet distributed operations.
  • Distel, a distributed Emacs Lisp with Erlang-style processes and message passing, and the Erlang distribution protocol, originally developed by Luke Gorrie of LtU, SLIME, OLPC, and other fame. Some time ago, Bill Clementson wrote a nice article about Distel.
  • Termite, another Erlang-like distributed programming system, this time written in Gambit-C Scheme.
  • Lisp Flavoured Erlang (LFE) is a Lisp syntax front-end to the Erlang compiler by Robert Virding (one of the inventors of Erlang). This is an interesting one, because it comes out of the Erlang community for a change, and instead of porting Erlang ideas to Lisp, it goes the other route: porting Lisp ideas to Erlang.
  • Erlang-in-Lisp, a Google Summer of Code 2008 project, again very much in the spirit of Erlisp, it seems. The project is in its early stages, let's see how far this goes.
  • Erlang Server, Common Lisp Client by Berlin Brown appears to be the latest attempt of integrating Erlang and Lisp. They are connected via sockets and exchange messages in a custom protocol. This has the advantage that either side can easily be replaced by a different implementation.

And this list does not even include projects like (again defunct?) Kali Scheme, which are clearly related.

Personally, I think that the reimplementation approach will have a tough stance against integration approaches like Distel. They lock out either one or the other of the two language eco-systems: libraries, development tools, etc., and recreating this is a lot of work (but don't let that stop you!) With Distel, I can choose to program parts of the application in ELisp or Erlang, whatever is a better fit.

Distel implements Erlang's on-the-wire protocol, which is nice because there is no need to mess around with a Foreign Function Interface. Alternatively, one could bind to the Erlang C libraries. As far as rapid prototyping is concerned, this should be the fastest and most straight-forward approach. I wonder why everybody is doing it the hard way?

UPDATE 2008-07-06: Forgot ETOS

A helpful reader on reddit rightly pointed out that I forgot to include ETOS, now rectified.

UPDATE 2008-07-06: Erlang Interoperability

Bill Clementson wrote a nice summary of the Erlang Interoperability options. Thanks again, Bill!

Lisp: Planet Lisp

Lispjobs: Freelance: install FUF/Surge


Up to $500 to install Common Lisp, FUF/SURGE.

See link.

Lisp: Planet Lisp

Hans Hübner: Building Load Resilient Web Servers

One of the bigger challenges with deploying dynamic web servers is being able to cope with load peaks that happen when the URL is communicated to larger communities in a short time. I have seen several sites being slashdotted and collapse under the load, and it is common to blame the underlying server technology for crashes; being Lisp lovers, we don't want to see that happen for our sites.

Using a caching frontend to reduce backend load

Following industry practice, we have been using a caching reverse proxy in front of our Lisp based dynamic web servers from the beginning. Our choice was Squid, as I had prior experience configuring it and found it to work reliably once the configuration was in place. I was never quite happy with that choice, though, because Squid's main operation mode is forward proxying. It has gazillions of configuration options that are not needed for a reverse proxy, which made us feel that Squid would not be a perfect match for our demands.

This is not to say that Squid has hurt us in any way. It has served us well during a load peak on the create-rainforest web site, but as reverse proxying has become very common in the last few years, we found it about time to go shopping for a solution that might be a better match to our needs.

We hoped to find a frontend proxy having the following features:

  • Caching - We want the frontend to cache all content that is not session dependent in order to reduce the load on our Lisp backend.
  • Scalable - The frontend must be able to handle loads much larger than what we see normally in order to accomodate for peaks.
  • Request queueing - Ideally, we'd like the frontend to handle all concurrency issues and send requests to the backend one after the other using a single persistent http connection, maybe with pipelining.
This set of requirements reduced the available options dramatically, and we ended up giving varnish serious consideration.

Evaluating varnish

varnish seems to have most of the features that we require: It supports caching, has been tested under very high loads and supports FreeBSD which is our deployment platform. Varnish has been written by Poul-Henning Kamp of FreeBSD fame, so we also found it to be culturally compatible.

Our evaluation revealed that varnish is under active development and support, and we found the developers be very responsive to our bug reports and requests. Its architecture looks well thought out, and the configuration language (even if underdocumented) makes the request handling process very transparent.

There are a number of downsides with varnish, though:

    • Eager cache cleanup policy: varnish removes objects from its cache as soon as they expire. This means that expired objects are always fetched from the backend, even if the previous cached copy was still up to date. It is possible to work around this by either hacking varnish to revalidate cached objects before expiring them or by not expiring them automatically, but rather by explicit purge requests sent from the backend to varnish. Both options, while doable, require substantial work.
      No high load safeguards: varnish offers no control over the number of backend connections established and does not support any queuing or backend resource control mechanisms. This means that it will unconditionally try to establish a connection to the backend if an object can't be served from the cache. Once the backend reaches saturation, varnish will aggravate the situation by sending even more requests to the backend, increasing the time to recover from the backend saturation.
      Threading: varnish uses threading to schedule requests. While this in principle should not be something negative, threaded programs are much harder to debug in practice, and many concurrency bugs that threaded code is susceptible to only show up after a long time or under certain load patterns which may be hard to reproduce. Admittedly, I am a threads hater, but I am writing this here because we found a serious threading race condition on the second day of our evaluation which prevented varnish from even starting up. My trust in the code was seriously affected by this.
  • When talking to the varnish developers, the problems were acknowledged, help to fixable problems was very quick and they told us that more advanced features will be develop after the upcoming 2.0 release of varnish.

    We would have liked to switch to varnish because of the very good support and because it is meant to be a web frontend, nothing else. Yet, at the current point in time, it does not seem to be mature enough to serve our needs. After having evaluated it, we turned back to squid as it seemed to be the only other option. We found that squid meets our requirements for cache cleaning and revalidation of cached objects very well.

    Making objects cacheable

    Chosing a front end software is only part of what needs to be done to make a web system fast and robust enough to withstand high loads. The most important factor is to make the frontend serve a large percentage of the incoming requests from its cache and only consult the backend server for content that is really dynamic. The HTTP/1.1 protocol provides for request and response headers that control how content can be cached, and there is little need for explicit configuration if these headers are used correctly.

    Using If-modified-since

    One way to limit the traffic to the backend is implement the If-modified-since mechanism. It is supported by Hunchentoot for static files by default, and can also be used for dynamic handlers that can check whether a resource has changed since it had previously been requested. Varnish will set the If-modified-since header when it requests resources that it already has in the cache, so every cacheable resource will normally be transfered from the backend to Varnish only once.

    Controlling cache refreshing

    Often, resources are dynamic, yet it is not crucial that every client sees the absolutely latest version of the resource. For example, in our square meter sales application, visitors should always see the current number of square meters sold, but it is not vital that this information is accurate to the second. Thus, we want the cache to refresh such pages only at a certain interval. The HTTP/1.1 provides for the cache-control directive and in particular the max-age parameter. It specifies how long a cache may consider a cached resource be valid without revalidating with the originating server. By setting this parameter in responses sent by the backend, we can effectively limit the maximum refresh rate for dynamic resources that do not need completely up to date every time.

    Testing realistically

    In order to test the performance of a Web system, it needs better tools than the often-used ApacheBench tool, which only tests response times and throughput of a single URL. For meaningful results, one should simulate a user load that reflects the load that real users create. I have been using SIEGE for informal testing often, as it is easy to use, but I have also found it a little flakey and prune to random crashes, which made us look for more reliable solutions.

    In the FreeBSD ports collection, we found tsung. Tsung is an open-source multi-protocol distributed load testing tool written in Erlang, and it has good support for HTTP. In addition to running load tests against web servers and generating statistics reports, it supports a session recorder that can be used to create a log of the URLs that a user visits when browsing a web server which can then be directly used to simulate many simultaneous users. As an added bonus, it is possible to capture dynamically generated information from web server responses into variables and use them in subsequents requests in a session. This feature can be used to generate sale transactions or user registrations in a load simulation.

    Using tsung and squid, we were able to tune our Lisp backend so that all non-dynamic content is served from the cache, pinpoint a serious performance problem and simulate realistic loads. We are now confident that our setup can withstand the next rush of users without crashing.

    Lisp: Planet Lisp

    Franz Technical: New version of Allegro CL 8.1 Express

    There is a new version of Allegro CL 8.1 Express available for download. Allegro CL Express is the free version of Allegro CL. Current users should just update their installed copy. The new version has a larger allowable heap size and the newlicense program now retrieves the initial license in addition to updating licenses. On Windows, the update.exe program now gets updates as well as (as before) updating existing images.

    Lisp: Planet Lisp

    Leslie Polzer: Shadowing a CL function definition

    Shadowing functions is useful for example when testing.
    Suppose we want to build a tiny test suite around the following function:

     
    (defparameter *appointment* ...)
     
    (defun overdue-p ()
      (>= (get-universal-time) *appointment*))

    Testing OVERDUE-P obviously requires us to test two branches: one where the appointment is overdue and one where it is not.

    Let’s say that you can’t change *APPOINTMENT* in your testing context for whatever reasons (the reason here being that this example is ultra-contrived for simplicity).
    Assuming a fixed value for *APPOINTMENT* we need to change the return value of CL:GET-UNIVERSAL-TIME. This can be achieved by shadowing this function for the duration of our test.

    Unfortunately, shadowing a function in Common Lisp isn’t obvious.

    You can’t use FLET or LABELS because they have lexical scope.
    You can’t use DEFUN either because it affects the global function namespace and doesn’t let you save or restore the old definition.

    The only way I know of is using the function (SETF FDEFINITION):

    (let ((orig (fdefinition 'get-universal-time)))
      (setf (fdefinition 'get-universal-time) (lambda () *my-testing-time*))
      (prog1
        (overdue-p) ; you'd run some test checks against the result here
        (setf (fdefinition 'bar) orig)))

    Wrapping this in a macro is left as an exercise to the reader.

    This doesn’t work for special operators, and neither for FLET or LABELS. See the CLHS entry for accessor FDEFINITION.

    Lisp: Planet Lisp

    Zach Beane: New vecto

    I pushed out Vecto 1.3.1. New in this version:

    • stroke-to-paths will convert stroke outlines of the current path to a new set of paths you can fill
    • string-paths will add paths for a string in the current font, instead of painting the text
    • set-gradient-fill will let you fill paths with a simple axial gradient. It's not much, but it's a start...

    Many thanks to Ben Deane for providing a functional fill patch that made adding gradients much easier, and for suggesting the text-to-paths functionality. Thanks also to Jakub Higersberger for showing me how easy gradients could be. (I wound up using a very simple formula straight from the Adobe PDF Reference.)

    This uses a simple white-to-transparent gradient:

    Here's some code that uses all three new features:

    (defun text-paths (file)
      (with-canvas (:width 400 :height 100)
        (set-font (get-font "/tmp/font.ttf") 70)
        (centered-string-paths 200 15 "Hello, world!")
        (set-line-join :round)
        (set-line-cap :round)
        (set-line-width 3)
        (set-dash-pattern #(0 5) 0)
        (stroke-to-paths)
        (set-gradient-fill 0 0   1 0 0 0.5
                           0 100 1 1 1 1)
        (fill-path)
        (save-png file)))
    

    I fell short of exporting and documenting the functional fill option that enabled gradients, because I've run out of time. Maybe next release!

    Lisp: Planet Lisp

    Luke Gorrie: San Francisco

    I'll be in San Francisco from July 5th to 14th. I have a feeling that a lot of online acquaintances and people with similar interests (Erlang, Lisp, Smalltalk, etc) are based there. Let's meet up! Please tell me about any fun meetings, user groups, pub nights, etc that I should try to make it to.

    Lisp: Planet Lisp

    Tamas K Papp: announcement: minpack package

    I have been using a simple solver (based on Broyden's method) to finds roots of systems of nonlinear equation, but I encountered an ill-behaving class of problems that required heavier artillery.

    Numerical methods have made a lot of progress in the last 50 years. Methods presented in introductory textbooks are quite straightforward and very simple to code, but do not cut the mustard when it comes to more difficult situations (eg when you don't have a good initial guess, your function looks like the fjords of Norway, etc).

    State of the art methods are powerful, but they are tricky to program: the main idea is easy to grasp, but one has to cover a lot of special cases (eg line-search, niceties of trust-region methods) so implementing them from scratch takes a lot of time (and debugging). This is why most researchers rely on Fortran (or most recently, C) packages of these methods.

    Common Lisp users generally have two alternatives if they don't want to implement these methods from scratch. They can use the foreign code directly via the FFI, or translate the code using f2cl, which is available as part of CLOCC. I found the second option more appealing, for the following reasons:

    • fewer dependencies (no need to install/compile foreign libraries)
    • no need to have callbacks (which are a pain in the neck)
    • better integration into Lisp (eg you can use the condition system)

    This is the first time I used f2cl, but it was quite easy to do, especially as CLOCC already has things set up for MINPACK. I think that translating from Fortran is the way to go for some libraries, even though I recognize that for libraries like LAPACK where pure performance matters, FFI is the better option, especially as the functions there have simpler interfaces and don't need callbacks and complex condition handling.

    MINPACK has already been available as part of CLOCC, but I had a hard time getting the whole thing work in SBCL, and it doesn't use ASDF, so I decided to package it to make it self-contained and ASDF-installable. The extended version of the project I am working on will probably need homotopy methods, and I am looking forward to packaging that too.

    Lisp: Planet Lisp

    Tamas K Papp: changes in cl-cairo2

    Johann Korndoerfer kindly submitted a patch that adds patterns to cl-cairo2, and also includes some code cleanup. Here is the example Johann contributed to the tutorial, a rainbow created with patterns:



    Thanks for the nice work, Johann! I am happy that others also find cl-cairo2 useful.

    cl-cairo2 still suffers from the elusive floating point bug (possibly in libcairo), I am still working on that. In the meantime, you can work around that by not generating PS files directly, but converting them from PDF or SVG files.

    Since common-lisp.net appears to be down, I took the opportunity to migrate the repository to git, which I am now hosting on my webpage. I find git to be much more convenient than SVN, especially when it comes to ease of distribution. As before, the package remains ASDF-installable. Update: the GIT repository is here, but can also be found from the cliki page for cl-cairo2.

    Lisp: Planet Lisp

    Finding Lisp: Forth Timelessness, a Redux

    The other day, I discussed languages which I thought were timeless. Among them, I listed Lisp, C, and Forth. After writing that posting, I spent some time playing with Forth again. Today, while browsing Reddit, I stumbled on this interview with Charles Moore, the creator of Forth.

    Forth is one of those languages, like Lisp, that I'd recommend that everybody study at least for a time. Even if you don't walk away believing it's the Language to End All Languages, you'll be better off for the experience. In fact, Forth shares a lot of fundamental attributes with Lisp while at the same time appearing almost completely different to a programmer writing code.

    Some of the shared attributes include:

    1. Forth and Lisp both erupt from a very small nucleus of fundamental constructs. As Alan Kay has described Lisp as being "Maxwell's equations of sofware," similar statements would also apply to Forth. Both Forth and Lisp are fundamentally simple as a result. Sure, the libraries could be huge, but learning the actual language itself, the core rules, requires no more than a few minutes for each language. With both languages, there is a set of advanced rules (things like macros for Lisp or compiling words for Forth), but the basics are trivial.
    2. Forth and Lisp are duals of each other when it comes to their syntax. In both cases, the programmer is essentially handing the system a direct representation of the parse tree. The parsers for each language are trivial. Lisp uses prefix notation, whereas Forth uses postfix: "(+ 1 2)" vs. "1 2 +" for example. The use of prefix notation semi-requires delimiters to be inserted, giving us Lisp's beloved/hated parenthesis. With Forth, all computation revolves around the stack. Because the operation always occurs after the parameters are pushed, you don't need the delimiters. Words simply consume whatever parameters from the stack that they want to. One implication of this, however, is that you can do things like "(+ 1 2 3 4)" in Lisp. In Forth, this ends up being either "1 2 + 3 + 4 +" or "4 3 1 2 + + +".
    3. Forth and Lisp are both extensible. When you create a new function or macro in Lisp, you're extending the language itself. Your new function or macro is a peer with everything else in the language, not a red-headed stepchild. Similarly, with Forth, a word is a word is a word. You can create Forth words that interact with the compiler and do all sorts of crazy stuff. Most Forth systems also include an assembler so you can create high-performance, primitive Forth words as well.
    4. Forth and Lisp are both interactive. They both use a REPL. Forth doesn't call it that, but that's what it is. The benefits of this are similar in both. You tend to code a little, then test a little, then code a little, then test a little. In the interview with Moore linked above, you can see where he talks about the speed at which things got developed as a result of the interactivity of his Forth system.
    5. Forth and Lisp both include a compiler. I guess this really isn't a fundamental attribute of Lisp itself (you could be fully interpreted), but most Lisp systems do have a compiler. In some cases, that compiler can be pretty simple and primitive. In other cases, it could be very sophisticated (CMUCL/SBCL). With Forth, the compiler for threaded code is both fundamental and at the same time trivial. More sophisticated Forth systems can create more complex compilers (subroutine threading, superoperations, etc.), but those are not required.

    All that said, Forth and Lisp are also very different:

    1. Typically, Forth operates at the machine level, with very direct exposed representations for objects. Forth programmers think in terms of machine words, bits and bytes. In some parts of a given program, a given bit pattern will represent a character or pointer or whatever, but from Forth's point of view they're all just bit patterns in a machine word. In contrast, Lisp programmers operate a higher levels of representation with first-class status for things like symbols, numbers, characters, etc.
    2. As a result of this "level difference," Forth programs are more memory efficient than Lisp programs, but they're also more dependent on the underlying machine fundamentals. For instance, if you changed the word size of the machine, a Lisp programmer probably wouldn't be aware of it. A Forth programmer might have to scramble to rewrite a good portion of the code. But very useful Forth programs are measured in KB of size, not MB.
    3. A big difference that typifies the issue of operating at the machine level vs. higher levels of abstraction is that Forth doesn't include any GC capabilities. All memory management must be done manually by the programmer.
    4. Forth isn't very tolerant of program bugs. Because you're operating at the machine level, when things go wrong, you might end up with a crashed machine. The Forth response to that is to just push the reset button and reload the system. Because the compiler is so fast, you'll be back to where you were before the crash in no-time. In contrast, Lisp makes a lot of effort to land the programmer in an interactive debugging shell when it detects an error condition.

    Note that people have proposed systems which bridge between the two worlds. Factor is basically a Forth stack machine and syntax, augmented with high-level, Lisp-like data types and a GC. The result is a system which delivers Forth-like syntax with a Lisp-like debugging and development environment. Depending on your point of view, you'll either think this is the best of both worlds or the worst.

    For me personally, I like both Forth and Lisp, but I'd use them in completely separate domains. If I was working on a deeply embedded project, where I'd want to be close to the machine architecture and where I had only a few KB into which to implement the program, I'd choose Forth. If I was writing a large application that would be running on a server with GBs of memory, I'd choose Lisp. Each works well within its target domain and the advantages of each are nearly the same: a small, extensible language with an iterative, interactive development environment.

    As for systems like Factor, for me it's a "tweener" that doesn't fit my needs. By getting away from the machine details, adding high-level data types, GC, etc., Factor necessarily pushes itself out of the embedded world. You simply won't have microcontrollers running Factor. And if I'm going to be running on a system with an underlying operating system, a large graphical display, and GB of memory, I'd rather do my development in Lisp. While I like Forth, I find that Lisp's sexpr notation more closely matches my thinking model. With Forth's implicit stack, I have to be thinking all the time about what data values are at what positions on the stack. I'd choose to deal with that for an embedded design to get all the other attributes of Forth in that environment, but with fewer constraints, I'd choose Lisp over a "Forth with high-level data types and GC" like Factor.

    Now, that's just me. For you, Factor may be the ticket. Slava Pestov is not an idiot (and you can quote me on that, Slava). As Factor's creator, he has obviously built a system that works well for him. Other people who seem to have far better programming skills than I do are working with Factor, too. The development environment they have put together seems to have borrowed a lot of ideas from Lisp machines, and I could see the Factor environment being really productive.

    Whatever you choose, realize that all of these languages have some things they share. And fundamentally, both Lisp and Forth are timeless.

    Lisp: Planet Lisp

    Finding Lisp: LispForum, open for business

    The other day, I realized that there wasn't a great place to discuss Lisp that was using a post-Y2K sort of interface. Sure, comp.lang.lisp has been around forever, and through Google Groups it has an HTTP interface, but when you post to Usenet you become an instant spam magnet. And new users think an all text-mode interface with no markup is just so 1985. And yes, there's always #lisp on Freenode.net IRC, which is great for realtime, but bad for searching for coherent answers.

    So, I created Lisp Forum: www.lispforum.com

    The content is a bit sparse right now. That's where you come in. Please register, hang out, and participate. My goal is to make this a friendly place with a bit less Smug Lisp Weenie-ness than comp.lang.lisp, suitable for both newcomers and old pros.

    Lisp: Planet Lisp

    Gary King: Announce: simple-http version 1.2.0

    Simple-HTTP is a fork of Brian Mastenbrook’s trivial-http. If you need a serious HTTP client with all the trimming, you should look at Edi Weitz’s Drakma. On the other hand, if all want is a some basic HTTP support and don’t want to deal with lots of other dependencies, then simple-http may be something that meets your needs.

    (P.S., the website needs a bit of love… Well to be honest, all my websites need some work but simple-http’s needs tough love!).

    Lisp: Planet Lisp

    Gary King: Announce: geohash version 0.1.0

    I came across geohash.org while browsing the Semantic Web last night. This site uses a simple latitude/longitude encoding to convert locations into short strings. Here, for example, is the URL for my house.

    http://geohash.org/drs3nbcszvze
    

    The nice thing is that strings with common prefixes are geographically close to one another. I saw that there were several ports of the algorithm to Ruby, Perl, PHP, etc. but no Common Lisp love. The geohash system on Common-Lisp.net fixes that! Enjoy

    Lisp: Planet Lisp

    Zach Beane: Planet Lisp migration

    Planet Lisp is now on a new server. If you notice any problems with it, please email me.

    Lisp: Planet Lisp

    Lispjobs: Network security jobs, Qualsys, Redwood City, CA


    There are several network security jobs that require “understanding of LISP” in the job descriptions.

    link

    Lisp: Planet Lisp

    Gary King: announcing: metatilities-base and lift

    Doing some more cleanup; the biggest improvement is that lift:with-timeout is now supported in SBCL with and without threads. The non-threaded version uses timers; I like ‘em.

    • metatilities

      • moved file-newer-than-file-p from here to metatilities-base

      • did a whole bunch of symbol unexporting and exporting between here and metatiliites

    • metatilities-base (0.6.3)

      • added pathname-samep and moved file-newer-than-file-p from metatilities to metatilities-base.

      • did a whole bunch of symbol unexporting and exporting between here and metatiliites

    • lift (1.5.0)

      • improved while-counting-repetitions and while-counting

      • implemented with-timeout for SBCL without thread support (yeah!)

      • added errorp argument to find-testsuite and find-test-case

    Enjoy.

    Lisp: Planet Lisp

    Gary King: let me count the (number of) ways

    When benchmarking, it is all too easy to use the Common Lisp [time][time] macro to see how long something takes. For example,

    (time (dotimes (i 1000) (do-my-function)))
    

    There are at least two problems with this simple approach. Firstly, time doesn’t make it easy to record the values it computes; secondly, if your function is very fast, you may end up timing how quickly your lisp execute dotimes rather than measuring what you want. A better way to approach this sort of question is to ask “how many times can I execute my function in, e.g., 5-seconds?” The only downside of this approach is that it takes a little more code to set things up. Once you have the code, however, Bob is your uncle. [LIFT][] includes a small (and sadly under-documented) selection of functions and macros to help you benchmark and profile your code. Two of these are:

    (defun count-repetitions (fn delay)
      "Funcalls `fn` repeatedly for `delay` seconds. Returns
    the number of times `fn` was called. Warning: the code
    assumes that `fn` will not be called more than a fixnum
    number of times."
       ...)
    

    and

    (defmacro while-counting-repetitions ((&optional (delay 1.0)) &body body)
    "Execute `body` repeatedly for `delay` seconds. Returns
    the number of times `body` is executed per second.
    Warning: assumes that `body` will not be executed more
    than a fixnum number of times. The `delay` defaults to
    1.0."
      ...)
    

    The main difference between the two variants — well, aside from one being a macro and one a function — is that count-repetitions must funcall your function whereas while-counting-repetitions includes your code in-line.

    Let’s use them to look at three different solutions for the perennial “I want to turn a string into a keyword” problem. I’m also going to require that all of the strings be lowercased (just because). One solution uses read-from-string

    (defun form-keyword-1 (name)
      (read-from-string (format nil "~(:~A~) " name)))
    

    another uses intern. We’ll look at two variants: the first looks up the keyword package each time; the second does it just once:

    (defun form-keyword-2a (name)
      (intern (string-downcase name) (find-package '#:keyword)))
    
    (defun form-keyword-2b (name)
      (intern (string-downcase name)
        (load-time-value (find-package '#:keyword))))
    

    Lastly, let’s see if there is any cost to calling intern unnecessarily by adding a variant that first uses find-symbol and only calls intern if it must.

    (defun form-keyword-3 (name)
      (let ((downcased-name (string-downcase name))
            (keyword-package (load-time-value (find-package '#:keyword))))
        (or (find-symbol downcased-name keyword-package)
            (intern downcased-name keyword-package))))
    

    Here’s what it looks like to try a simple test. We’ll use 5-seconds as our delay.

    cl-user> (lift:count-repetitions
               (lambda () 
                 (form-keyword-1 "hello")
                 (form-keyword-1 "butter")) 
               5.0)
    57214.8
    

    So form-keyword-1 (the read-from-string variant) can run about 57,000-times a second (this is under ACL in EMACS under Slime). The other three variants give counts of:

              ACL        SBCL
     1:    57,215      37,354
    2a:   689,888     329,896
    2b:   986,085     447,137
     3: 1,028,928     461,868
    

    (Note: I’m using a somewhat out of date SBCL so these numbers shouldn’t be used to compare these two Lisps).

    That’s a pretty huge difference on both of these Lisps. Allegro especially benefits from the load-time-value resolution of the keyword package and both Lisps should a slight improvement when calling find-symbol first (which actually surprised me. I would have thought that intern would have handled that logic already.)

    Now lets see if funcalling is doing anything to change the results by switching over to the while-counting-repetitions macro:

    cl-user> (lift:while-counting-repetitions (5) 
               (form-keyword-1 "hello")
               (form-keyword-1 "butter"))
    57633.6
    

    Here’s the table

              ACL        SBCL
     1:    57,634      37,960
    2a:   686,941     328,316
    2b:   992,373     451,186
     3: 1,050,546     448,714
    

    In this example, at least, the macro and the function appear to have no advantages one over the other.

    Lisp: Planet Lisp

    Gary King: Announcing: versions that go bump in the night

    CL-Containers and dynamic-classes have both been updated:

    • CL-Containers (0.10.2) sees a patch for insert-new-item from Daniel Dickison (thanks!) and some minor tweaks and one new test case.

    • dynamic-classes (1.0.1) sees an actual (though sadly empty) test-system. It feels much better not being saddled with one cut and pasted from LIFT.

    Enjoy!

    Lisp: Planet Lisp

    Lispjobs: 2 new jobs at Alphacet (Stamford, CT)


    Job 1

    Lisp Developer at Algorithmic Trading Software Vendor

    We are looking for a Full Time Lisp developer with very strong math skills that also has experience with developing trading strategies and doing quant research in Lisp.  Your work would consist of:

    Coding functions that will be included in the system library and provided to customers (currently we have 500 functions completed covering everything from technical analysis to every major machine learning routine)
    Coding complex machine learning routines to be included in the system library, with a focus on exposing every possible parameter and intermediate data series to the user, e.g., writing linear regression so that the coefficients, residuals, etc. are accessible data series and so that the least squares metric can be replaced with other variants by simply slotting in the new function name into the keyword based call.
    Using profiling tools to assist with identifying functions that can be optimized for faster processing.
    Working with an in-house product specialist and the CTO as well as quants at customer firms to develop functions in Lisp for customers on-demand (about 50% of your time), as well as assisting with strategy development (if you also have those skills).
    Documenting Lisp functions
    FFI work to C/C++, R and compiled MatLab functions
    Assisting with extensions to the core Lisp engine (new preloaded functions, etc.)

    We are the emerging leader in the space and have an enterprise class platform for building arbitrarily complex algorithmic trading strategies in a completely codeless drag-and-drop environment (strategies look like flow diagrams).  The system's main server component is written in Lisp with an in-memory database.  We have a heavy focus on machine learning functions that can be embedded into the strategies.  The system is used for real-time high frequency trading, and backtests with enormous datasets and very computationally expensive routines.

    Experience that would be a major plus, but is not necessarily required:

    Advanced degree in quantitative discipline, e.g., Financial Engineering, Physics, Math, Statistics, Comp Sci, etc.
    Have worked at hedge fund or prop trading firm or bank developing trading strategies
    Experience developing machine learning algorithms such as neural nets, genetic algos, decision trees, Bayesian nets, hidden Markov models, particle swarm optimization, genetic programming, clustering, regressions, etc.
    MatLab, C/C++ and R development experience
    Working with threaded Lisps and real time systems, large datasets etc.

    This position is for the Stamford, CT office, though if you are near the Petaluma, CA office and unable to relocate we would consider this as well.  Please feel free to contact us even if we neglected to contact you after you responded to previous job postings.    Please contact Rosario Ingargiola, CTO at Alphacet via rosarioi@alphacet.com .

    Job 2

    Product Specialist w/ Basic Lisp Dev Skills at Algorithmic Trading Software Vendor

    The Product Specialist will become an expert user of our enterprise class application for the drag-and-drop based codeless strategy development, analysis and deployment application, and assist sales executives with product demonstrations and presentations, and handle client implementations and provide ongoing training and support. The Product Specialist will be will be instrumental in managing customer relationships during the implementation process and continued licensing usage.

    Pre-sales: Assist sales team with product demonstrations and presentations. Provide training and implementation support to customers.  Be able to understand and explain the Lisp code for any of the more than 500 functions in a growing library and help with improving documentation for those functions based upon customer questions/comments.
    Post-sales: Assist with proprietary historical data upload and import of shared libraries that have been interfaced to Lisp.  Help clients to expand proprietary strategy libraries by writing strategy logic and basic functions in Lisp. Work with other senior Lisp developers on development team to help define and then test more complex functions or strategies.  Provide production support to customers via phone, e-mail or on-site. Assist customer in optimizing business processes around Alphacet Discovery. Interact with development team (issue reporting, new feature requests).
    Use experience supporting customers to improve product documentation and training methods.

    Major pluses, though not required:

    Degree in quantitative discipline
    Trading firm experience
    Greater than basic Lisp development capabilities
    Other development/IT and sales engineer experience

    About Alphacet:  The Company Alphacet, Inc. develops innovative software and solutions for quantitative analysts, traders and portfolio managers.  The company’s flagship product is Alphacet Discovery, the only completely integrated solution for complex quantitative strategy development and deployment in the marketplace today. Alphacet Discovery seamlessly connects to leading market data vendors and market database partners, and provides advanced code-less financial modeling tools that allow ‘on the fly’ programming, back testing and walking forward of strategies - all through a revolutionary drag & drop interface.  The company was founded in 2007, building on development that began in 2003, based on pioneering work by researchers at
    the University of California.  Alphacet is headquartered in Stamford, Connecticut, with development facilities in Petaluma, California.

    This position is for the Stamford, CT office only.  Please contact Rosario Ingargiola, CTO at Alphacet via rosarioi@alphacet.com .

    Lisp: Planet Lisp

    Zach Beane: Developing Flash games with Common Lisp

    Ok, Common Lisp is a small piece of a large development setup. But I couldn't resist linking to a developer interview with Austin Haas of Pet Tomato, since it includes this exchange:

    In the alpha discussion, it was often suggested that you should have a UI gauge to show your fart "fuel." Can you elaborate on why you chose not to implement this?

    Simplicity. I'm still not sure about it, though. Lately, I've considered the idea of having him fade-in/out and sweat a little to indicate when you are really tapped and shouldn't try to fart so soon.

    Check out the development setup listed at the end for the Common Lisp connection.

    Lisp: Planet Lisp

    Page 1 | Next >>
    Username:
    Password:
    (or Cancel)