asdf 3
play

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


  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

  2. ASDF 3 Another System De fi nition Facility build system de facto standard DEFSYSTEM tradition in-image version 3 2

  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

  4. An Acceptable Scripting Language 4

  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

  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

  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

  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

  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

  10. What prevented scripting? 10

  11. What prevented scripting? (No) Write Once, Run Most-anywhere 11

  12. What prevented scripting? fi nding source code locating output fi les command line invocation argv access run-program pipes, expansion 12

  13. What made scripting possible? fi nding source code → asdf2 (source-registry) locating output fi les → asdf2 (output-translations) command line invocation → cl-launch argv access → cl-launch run-program → asdf3 (uiop) pipes, expansion → inferior-shell 13

  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 fi les But how to con fi gure? ~/.sbclrc , etc. 14

  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

  16. Finding source code (lessons) Who knows speci fi es, who doesn't needn't It just works by default Modular con fi guration Reusable DSL for pathname designators Better than in C! 16

  17. Locating output fi les (before) Output in source code directory (Technically as bad as for C) no standard paths, no common ABI (Socially worse than for C) 17

  18. Locating output fi les (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

  19. ASDF 1: output redirection, but... defmethod output-files :around (o c) c-l-c (2002), A-B-L (2005) 19

  20. ASDF 1: output redirection, but... defmethod output-files :around (o c) c-l-c (2002), A-B-L (2005) Not modular Where to con fi gure? ~/.sbclrc 20

  21. Locating output fi les ASDF 2: output-translations Con fi guration 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 21 a portable bytecode VM, with code 40, 41...

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

  23. Related Improvements 23

  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 fi les! 24

  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

  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

  27. Scripting Language? 27

  28. Scripting Language? Low-overhead programming No boilerplate Write once, run everywhere unmodi fi ed No setup needed Spawn or be spawned by other programs call or be called by functions in other languages 28

  29. What is it all about? 29

  30. What is it all about? ASDF 3 does nothing that cannot be done without it 30

  31. What is it all about? ASDF 3 does nothing that cannot be done without it Neither does any piece of software 31

  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

  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

  34. Beyond ASDF 3 34

  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

  36. Lessons for other languages less overhead more modularity more access 36

  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

  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

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend