25

Hello World with ECL on the Raspberry Pi

qr-code for this page's url

Now that we have ecl, how can we use it? I have never used ecl, so there is some learning to do to produce even a small canonical "hello world". This is what I learned:

The hello world program itself is of course easy:

(format t "Hello world!~%")
(force-output t)
(quit)

Now, how to produce a binary? The manual tells us to do this:

(compile-file "hello-world.lisp" :system-p t)
(c:build-program "hello-world-lisp" :lisp-files '("hello-world.o"))

And lo and behold, we have a binary, which isn't even much larger than the equivalent c program:

-rwxr-xr-x 1 pi pi 5157 Jul 25 15:58 hello-world-c
-rwxr-xr-x 1 pi pi 8259 Jul 25 15:58 hello-world-lisp

But the startup times differ quite a bit:

$ time ./hello-world-lisp  > /dev/null

real    0m3.994s
user    0m3.910s
sys     0m0.070s
$ time ./hello-world-c > /dev/null

real    0m0.012s
user    0m0.000s
sys     0m0.000s

Oh well, I guess that is to be expected.