Dynamic languages can be compiled [Was: Prothon gets Major Facelift in Vers 0.1.0 [Prothon]]

Jacek Generowicz jacek.generowicz at cern.ch
Tue May 25 08:30:26 EDT 2004


Jacek Generowicz <jacek.generowicz at cern.ch> writes:

>     Name             Interpreted        Compiled
>     
>     LispWorks            66               1.0 s
>     Clisp                41               9.5 s
>     CMUCL          Got bored waiting      1.5 s
>     SBCL           Compiles everything    1.6 s
>     Python         Compiles everything    20  s
> 
> 
> So, we have times of 1.0s, 1.5s, 1.6s, 9.5s and 20s. Now one of those
> Common Lisp implementations does NOT compile to native; it compiles to
> bytecode. Can you guess which one it is, by looking at the timings ?

Just for fun, I threw all the declarations that came to my head at the
Lisp function, making in look thus:

    (defun fib (n)
      (declare (fixnum n))
      (declare (optimize (safety 0) (speed 3) (debug 0)
                         (space 0) (compilation-speed 0)))
      (if (< n 2)
          1
        (the fixnum 
             (+ (the fixnum (fib (- n 1)))
                (the fixnum (fib (- n 2)))))))

I also tried a C version:

    int fib(int n) {
      if (n<2) {
        return 1;
      }
      return fib(n-1) + fib(n-2);
    }
    
    int main() {
      return fib(35);
    }

Here's the table with the the results for the above added in:


Name             Interpreted        Compiled   With declarations
                                                     
LispWorks            66                1.0          1.6  
Clisp                41                9.5          9.5   
CMUCL          Got bored waiting       1.5          0.45  
SBCL           Compiles everything     1.6          0.49  
Python         Compiles everything    20
gcc            No interactivity                     0.29


(I also tried it on Allegro, via their telnet prompt (telnet
prompt.franz.com). The uncompiled version went beyond the CPU limit
they give you; the compiled version without declarations was 400ms;
with declarations was 200ms. Of course, we don't know how their
processor compares to mine.)



More information about the Python-list mailing list