ASDF 3 Why Lisp is Now an Acceptable Scripting Language Franois-Ren - - PowerPoint PPT Presentation

asdf 3
SMART_READER_LITE
LIVE PREVIEW

ASDF 3 Why Lisp is Now an Acceptable Scripting Language Franois-Ren - - PowerPoint PPT Presentation

ASDF 3 Why Lisp is Now an Acceptable Scripting Language Franois-Ren Rideau <tunes@google.com> European Lisp Symposium, 2014-05-05 1 ASDF 3 Another System De fi nition Facility build system de facto standard DEFSYSTEM tradition


slide-1
SLIDE 1

ASDF 3

Why Lisp is Now an Acceptable Scripting Language François-René Rideau <tunes@google.com> European Lisp Symposium, 2014-05-05

1

slide-2
SLIDE 2

ASDF 3

Another System Definition Facility build system de facto standard DEFSYSTEM tradition in-image version 3

2

slide-3
SLIDE 3

Brief History of ASDF

Prehistory: load scripts 1970s DEFSYSTEM 1990 MK-DEFSYSTEM 2002 ASDF (Dan Barlow ≠ me) 2010 ASDF 2 (me me!) 2013 ASDF 3 (me me me!)

3

slide-4
SLIDE 4

An Acceptable Scripting Language

4

slide-5
SLIDE 5

Writing a Unix-style script in Lisp

#!/usr/bin/cl -sp lisp-stripper -E main (defun main (argv) (if argv (map () 'print-loc-count argv) (print-loc-count *standard-input*))) lispwc *.lisp

5

slide-6
SLIDE 6

Invoking Lisp code from the shell

#!/bin/sh form='`#5(1 ,@`(2 3))' for impl in allegro ccl clisp sbcl ecl \ lispworks abcl cmucl gcl scl xcl ; \ do cl -l $impl \ "(format t \"$impl ~S~%\" $form)" \ 2>&1 | grep "^$impl " # LW, GCL are verbose done

6

slide-7
SLIDE 7

Invoking external commands from Lisp

#!/usr/bin/cl -sp inferior-shell (loop with form = "`#5(1 ,@`(2 3))" for impl in '(allegro ccl clisp sbcl ecl lispworks abcl cmucl gcl scl xcl) do (run `(pipe (cl -l ,impl (>& 2 1) ("(format t \"" ,impl " ~S~%\" " ,form ")")) (grep ("^" ,impl " ")))))

7

slide-8
SLIDE 8

Better abstractions for scripting

(loop with form = "`#5(1 ,@`(2 3))" for impl in '(allegro ccl clisp sbcl ecl lispworks abcl cmucl gcl scl xcl) collect (run `(pipe (cl -l ,impl (>& 2 1) ("(format t \"" ,impl " ~S~%\" " ,form ")")) (grep ("^" ,impl " "))) :output :forms))

8

slide-9
SLIDE 9

Standards-based portability

`#5(1 ,@`(2 3)) ((ALLEGRO #(1 2 3 2 3 2 3 2 3)) (CCL #(1 2 3 2 3 2 3 2 3))) (CLISP #(1 2 3 2 3 2 3 2 3))) (SBCL #(1 2 3 2 3 2 3 2 3))) (ECL #(1 2 3 3 3))) (LISPWORKS #(1 2 3 3 3))) (ABCL #(1 2 3))) (CMUCL #(1 2 3))) (GCL #(1 2 3))) (SCL #(1 2 3))) (XCL #(1 2 3))))

9

slide-10
SLIDE 10

What prevented scripting?

10

slide-11
SLIDE 11

What prevented scripting?

(No) Write Once, Run Most-anywhere

11

slide-12
SLIDE 12

What prevented scripting?

finding source code locating output files command line invocation argv access run-program pipes, expansion

12

slide-13
SLIDE 13

What made scripting possible?

finding source code → asdf2 (source-registry) locating output files → asdf2 (output-translations) command line invocation → cl-launch argv access → cl-launch run-program → asdf3 (uiop) pipes, expansion → inferior-shell

13

slide-14
SLIDE 14

Finding source code (before)

Q: Where is system foo ? The hard way: modify every client logical-pathname: system and client must agree ASDF 1: user maintains a link farm to .asd files But how to configure? ~/.sbclrc, etc.

14

slide-15
SLIDE 15

Finding source code (after)

ASDF 2: source-registry Implementation-independent Nice DSL Can recurse into subtrees Prog > Env > User > Sys, Explicit > Defaults Sensible defaults ASDF 3.1: ~/common-lisp/

15

slide-16
SLIDE 16

Finding source code (lessons)

Who knows specifies, who doesn't needn't It just works by default Modular configuration Reusable DSL for pathname designators Better than in C!

16

slide-17
SLIDE 17

Locating output files (before)

Output in source code directory (Technically as bad as for C) no standard paths, no common ABI (Socially worse than for C)

17

slide-18
SLIDE 18

Locating output files (before)

Output in source code directory (Technically as bad as for C) no standard paths, no common ABI (Socially worse than for C) Libraries as source (like Perl…) Cannot share source code

18

slide-19
SLIDE 19

ASDF 1: output redirection, but...

defmethod output-files :around (o c) c-l-c (2002), A-B-L (2005)

19

slide-20
SLIDE 20

ASDF 1: output redirection, but...

defmethod output-files :around (o c) c-l-c (2002), A-B-L (2005) Not modular Where to configure? ~/.sbclrc

20

slide-21
SLIDE 21

Locating output files

ASDF 2: output-translations Configuration similar to source-registry Before: as bad as C, but without conventions Default: persistent cache, per user, per ABI Cache not shared, for security a JIT, but persistent and coarse-grained a portable bytecode VM, with code 40, 41...

21

slide-22
SLIDE 22

Shell interface

shell-to-Lisp: cl-launch Lisp-to-shell: uiop/run-program, inferior-shell 100% solution, 100% portable

22

slide-23
SLIDE 23

Related Improvements

23

slide-24
SLIDE 24

Easier delivery with bundle operations

Deliver an executable: cl-launch Deliver a library: asdf:compile-bundle-op Deliver code as only one or two files!

24

slide-25
SLIDE 25

Image Life-cycle support

Need to use environment variables? (uiop:register-image-dump-hook 'clear-env-vars) (uiop:register-image-restore-hook 'init-env-vars)

25

slide-26
SLIDE 26

Image Life-cycle support

Need to use environment variables? (uiop:register-image-dump-hook 'clear-env-vars) (uiop:register-image-restore-hook 'init-env-vars) Many other uses A standard interface matters

26

slide-27
SLIDE 27

Scripting Language?

27

slide-28
SLIDE 28

Scripting Language?

Low-overhead programming No boilerplate Write once, run everywhere unmodified No setup needed Spawn or be spawned by other programs call or be called by functions in other languages

28

slide-29
SLIDE 29

What is it all about?

29

slide-30
SLIDE 30

What is it all about?

ASDF 3 does nothing that cannot be done without it

30

slide-31
SLIDE 31

What is it all about?

ASDF 3 does nothing that cannot be done without it Neither does any piece of software

31

slide-32
SLIDE 32

What is it all about?

ASDF 3 does nothing that cannot be done without it Neither does any piece of software Division of labor

32

slide-33
SLIDE 33

What is it all about?

ASDF 3 does nothing that cannot be done without it Neither does any piece of software Division of labor Enabling the division of labor

33

slide-34
SLIDE 34

Beyond ASDF 3

34

slide-35
SLIDE 35

Beyond ASDF 3

less overhead: ASDF 3.1: asdf:package-inferred-system more modularity: ASDF 3.1: *readtable* protection more access: Integration with other languages?

35

slide-36
SLIDE 36

Lessons for other languages

less overhead more modularity more access

36

slide-37
SLIDE 37

Also in the extended article...

The basic design of ASDF Why it rocks / sucks compared with C build tools Innovations in ASDF 1 2 2.26 3 3.1 The Problem with Pathnames Lessons in Software Design including Pitfalls A great bug chase story http://github.com/fare/asdf3-2013

37

slide-38
SLIDE 38

Share and Enjoy!

http://common-lisp.net/project/asdf/ http://cliki.net/cl-launch http://cliki.net/inferior-shell http://www.quicklisp.org/beta/ http://github.com/fare/asdf3-2013 Any Questions?

38