Live data from Hacker News

Common Lisp as a Scripting Language, 2015 Edition

fare.livejournal.com

11–20 of 42 posts

Re: Common Lisp as a Scripting Language, 2015 Edition

#11

I used Common Lisp from the mid 1980s until about 5 years ago when my customers wanted Clojure, if they wanted Lisp development done. I have never seriously used CL as a scripting language but for a while I was using Gambit-C Scheme for small compiled apps and command line tools. Gambit-C is very good for this purpose. BTW, Clojure is "out" for command line tools because of the JVM startup time but I have thought abo…

Pixie[1] is also worth a look. It's Clojure-like scripting language written in RPython. [1] https://github.com/pixie-lang/pixie

Indeed pretty cool, clojure implemented in rpython!

Re: Common Lisp as a Scripting Language, 2015 Edition

#12
post #9
post #7

I have my own scheme-esque language that I use for scripts. 16 of its 48 primitive procedures ~correspond to unix system calls (open, close, read, write, seek, select, stat, link, unlink, mkdir, lsdir, chdir, fork+exec, wait, sleep, exit). It was very instructive to work on, and using something I know inside out is a welcome relief from the uncertainty I feel when intuiting (ba)sh.

Any reason you don't use one of the existing scriptable scheme like guile's?

Wanted to put my article-gleaned understanding of lisp to the test + get at the essence of what shebang-style unix scripting was about.

Here is a reimplementation of "cat" in it:

    #!/usr/bin/env imp

    (def copy-out (proc (x)
      (let f (if (file? x) x (open x))
           bytes (read default-chunk f)
           (if bytes
               (seq (write bytes stdout)
                    (recur f))
               (close f)))))

    (if (nil? script-args)
        (copy-out stdin)
        (each copy-out script-args))
Running external programs is a bit more verbose than normal shell, but there is some optional reader-macro sugar on top of fork+exec, e.g. the effect of the following is that /usr/bin/say gets run with those non-string args converted to strings and a voice comes out of my speaker.

    !(say hello there)
    => ((status : 0) (pid : 2945) (in : [File]) (out : [File]) (err : [File]))

Re: Common Lisp as a Scripting Language, 2015 Edition

#13
post #12
post #9

Earlier quoted context omitted.

Any reason you don't use one of the existing scriptable scheme like guile's?

Wanted to put my article-gleaned understanding of lisp to the test + get at the essence of what shebang-style unix scripting was about. Here is a reimplementation of "cat" in it: #!/usr/bin/env imp (def copy-out (proc (x) (let f (if (file? x) x (open x)) bytes (read default-chunk f) (if bytes (seq (write bytes stdout) (recur f)) (close f))))) (if (nil? script-args) (copy-out stdin) (each copy-out script-args)) Runnin…

> Wanted to put my article-gleaned understanding of lisp to the test

fair enough!

> get at the essence of what shebang-style unix scripting was about

FWIW, although convoluted, you can do that with guile, with:

    #!/usr/bin/guile \
    -e main -s
Or simpler with chicken:

  #!/usr/bin/csi -s

Re: Common Lisp as a Scripting Language, 2015 Edition

#14

I used Common Lisp from the mid 1980s until about 5 years ago when my customers wanted Clojure, if they wanted Lisp development done. I have never seriously used CL as a scripting language but for a while I was using Gambit-C Scheme for small compiled apps and command line tools. Gambit-C is very good for this purpose. BTW, Clojure is "out" for command line tools because of the JVM startup time but I have thought abo…

I use Kawa Scheme on the JVM for scripting on Windows. Powershell is forbidden where I work. For some reason, it seems to start up faster than Clojure.

Re: Common Lisp as a Scripting Language, 2015 Edition

#15

Earlier quoted context omitted.

Pixie[1] is also worth a look. It's Clojure-like scripting language written in RPython. [1] https://github.com/pixie-lang/pixie

Indeed pretty cool, clojure implemented in rpython!

For even more fun, checkout hy (https://github.com/hylang/hy). It's completely compatible with standard python both ways (ie you can import python from hy and import hy from python), so you can import python-sh and do awesome stuff like:

  (import [sh [cat grep wc]])
  (->
   (cat "/usr/share/dict/words")
   (grep "-E" "^hy")
   (wc "-l"))

Re: Common Lisp as a Scripting Language, 2015 Edition

#16

I used Common Lisp from the mid 1980s until about 5 years ago when my customers wanted Clojure, if they wanted Lisp development done. I have never seriously used CL as a scripting language but for a while I was using Gambit-C Scheme for small compiled apps and command line tools. Gambit-C is very good for this purpose. BTW, Clojure is "out" for command line tools because of the JVM startup time but I have thought abo…

Nitpick, but Clojure's startup time isn't JVM startup time it's clojure.core startup time

Re: Common Lisp as a Scripting Language, 2015 Edition

#17
I wonder if the scales would tilt more in favor of separate images if you added a good tree-shaking step. You can bang out useful scripts pretty fast by pulling in a few helper functions from large libraries, but the more scripts share a library, the less functionality you can discard from the final image.

If you can cut the size of the core language's image in half with just a simple method like this, you could probably get impressive results using more sophisticated methods on images requiring a lot of libraries: https://gist.github.com/burtonsamograd/f08f561264ff94391300

Re: Common Lisp as a Scripting Language, 2015 Edition

#18

I used Common Lisp from the mid 1980s until about 5 years ago when my customers wanted Clojure, if they wanted Lisp development done. I have never seriously used CL as a scripting language but for a while I was using Gambit-C Scheme for small compiled apps and command line tools. Gambit-C is very good for this purpose. BTW, Clojure is "out" for command line tools because of the JVM startup time but I have thought abo…

Nitpick, but Clojure's startup time isn't JVM startup time it's clojure.core startup time

Ah, that is why Kawa Scheme starts up faster then.

Re: Common Lisp as a Scripting Language, 2015 Edition

#20
I use SBCL for some scripting, and haven't found the overhead to be that bad just using #!/usr/bin/sbcl. For basic stuff, I just use zsh, so by the time I've switched to Lisp, the task is already at the point where startup time isn't a big factor.

I do have some compiled programs I use, but IMO they're a little too big to be called scripts.

An interesting idea would be the ability to dump a shared library of the core image, and then dump incremental changes as executable images that dynamically link to it.

Post reply on HN