Upload
fukamachi
View
3.402
Download
7
Embed Size (px)
DESCRIPTION
Shibuya.lisp Tech Talk #8
Citation preview
Redesigning Common Lisp
Shibuya.lisp Tech Talk #8 Eitaro Fukamachi
Thank you for coming.
I’m Eitaro Fukamachi @nitro_idiot fukamachi
(and 'web-application-developer 'common-lisper)
Others
Clojure
Perl
Emacs Lisp
JavaScript
Common Lisp
GitHub product languages
GitHub product languages
I ♥ Common Lisp
because…
Common Lisp is the most powerful, expressive and fast language ever.
Common Lisp is damn powerful
• First class functions + lexical closures
• Object system + multiple dispatch
• Metaobject protocol
Common Lisp is expressive
• Reader macros
• Macros
Common Lisp is fast
• (Optional) type declaration
• Inlining functions
• Compiler macros
• Disassembler included
• Free high-performance implementation
Common Lisp is the most powerful, expressive and fast language ever.
= GOD LANGUAGE
So, here is a question.
Is Common Lisp perfect?
Is Common Lisp successful?
Is Common Lisp attractive to young people?
……………..
“well…”
Common Lisp is not sophisticated
• too-long-wordy-name-for-common-macros
• append & nconc
• elt vs aref vs nth
• getf vs gethash
• map?? mapc?? dolist?? loop??
• Functional vs Procedual
It’s because of the origin.
8 Goals of standardising Common Lisp
Commonality
Portability
Consistency
Expressiveness
Compatibility
Efficiency
PowerStability
from Common Lisp the Language
Common Lisp is a compound of MacLISP, Zetalisp, Spice Lisp, NIL and S-1 Lisp.
Common Lisp was designed for MacLISP, Zetalisp, Spice Lisp, NIL and S-1 Lisp users, not us.
Besides, Common Lisp is old.
Common Lisp = 30 years old Ruby = 19 years old JavaScript = 19 years old Clojure = 7 years old
Common Lisp was designed for people 30 years ago.
But it doesn’t mean Common Lisp is obsolete.
Common Lisp is the most powerful, expressive and fast language ever.
Common Lisp is the best one, but I’m still not fulfilled in it.
CLtL3? Almost hopeless.
Let’s redesign Common Lisp for the 21st century by ourselves.
“Common Lisp for the 21st century”
“CL21”
What is CL21?
• (One of) the next generation of Common Lisp
• Bases on Common Lisp
• Designed for us
• Actual implementation(not only discussions)
8 Goals of standardising Common Lisp
Commonality
Portability
Consistency
Expressiveness
Compatibility
Efficiency
PowerStability
from Common Lisp the Language
4 Goals of CL21
Consistency
Compatibility
Efficiency
Expressiveness
Goal 1: Consistency
Consistency of CL21
• Naming convention
• Argument order
(reverse '(1 2 3)) (nreverse '(1 2 3)) !(append '(1 2 3) '(a b c)) (nconc '(1 2 3) '(a b c))
Consistency of CL21
Common Lisp
(reverse '(1 2 3)) (nreverse '(1 2 3)) !(append '(1 2 3) '(a b c)) (nappend '(1 2 3) '(a b c))
Consistency of CL21
CL21
(getf person :name) (gethash :name person-hash)
Consistency of CL21
Common Lisp
(getf person :name) (gethash person-hash :name)
Consistency of CL21
CL21
Goal 2: Expressiveness
Expressiveness of CL21
• Specific vs Generic
• Delete useless symbols
Expressiveness of CL21
• Specific vs Generic
• Delete useless symbols
Expressiveness of CL21
• Specific vs Generic
• Delete useless symbols
Expressiveness of CL21
• Specific vs Generic
• Delete useless symbols
(ed “~/.sbclrc”)
Expressiveness of CL21
• Specific vs Generic
• Delete useless symbols
(ed “~/.sbclrc”)
Are you crazy????
(append '(1 2 3) '(a b c)) (concatenate 'vector #(1 2 3) '()) (concatenate 'string "Hello, " name)
Expressiveness of CL21
Common Lisp
(append '(1 2 3) '(a b c)) (append #(1 2 3) '()) (append "Hello, " name)
Expressiveness of CL21
CL21
(mapcar #'1+ '(1 2 3)) (map 'vector #'1+ #(1 2 3))
Expressiveness of CL21
Common Lisp
(map #'1+ '(1 2 3)) (map #'1+ #(1 2 3))
Expressiveness of CL21
CL21
(format nil "Hello, World!~%") (format nil "Hello, ~A~%" name)
Expressiveness of CL21
Common Lisp
"Hello, World!\n" #"Hello, ${name}\n"
Expressiveness of CL21
CL21
(parse-integer "1984") (symbol-name 'alien-technology)
Expressiveness of CL21
Common Lisp
(coerce "1984" 'integer) (coerce 'alien-technology 'string)
Expressiveness of CL21
CL21
(ql:quickload :cl-ppcre) (use-package :cl-ppcre) !(scan-to-strings "^(\\d{4})-(\\d{2})-(\\d{2})$" "2014-01-23") (regex-replace-all "a" "Eitaro Fukamachi" "α" :preserve-case nil)
Expressiveness of CL21
Common Lisp
(use-package :cl21.re) !(#/^(\d{4})-(\d{2})-(\d{2})$/ "2014-01-23") (re-replace #/a/ig "Eitaro Fukamachi" "α")
Expressiveness of CL21
CL21
(use-package :cl21.re) !(#/^(\d{4})-(\d{2})-(\d{2})$/ "2014-01-23") (re-replace #/a/ig "Eitaro Fukamachi" "α")
Expressiveness of CL21
CL21!! #/^(\d{4})-(\d{2})-(\d{2})$/ #/a/ig
(use-package :cl21.re) !(#/^(\d{4})-(\d{2})-(\d{2})$/ "2014-01-23") (re-replace #/a/ig "Eitaro Fukamachi" "α")
Expressiveness of CL21
CL21!! #/^(\d{4})-(\d{2})-(\d{2})$/ #/a/ig
Appliable Regex literal
(ql:quickload :clazy) (use-package :clazy) !(defun fib-seq () (labels ((rec (a b) (clazy:lazily (cons a (rec b (+ a b)))))) (rec 0 1))) !(head (tail (tail (tail (fib-seq))))) (lazy-seq:take 5 (fib-seq))
Expressiveness of CL21
Common Lisp
(use-package :cl21.lazy) !(defun fib-seq () (labels ((rec (a b) (lazy-sequence (cons a (rec b (+ a b)))))) (rec 0 1))) !(first (rest (rest (rest (fib-seq))))) (elt (fib-seq) 3) (subseq (fib-seq) 0 5)
Expressiveness of CL21
CL21
(use-package :cl21.lazy) !(defun fib-seq () (labels ((rec (a b) (lazy-sequence (cons a (rec b (+ a b)))))) (rec 0 1))) !(first (rest (rest (rest (fib-seq))))) (elt (fib-seq) 3) (subseq (fib-seq) 0 5)
Expressiveness of CL21
CL21!!!! lazy-sequence !!
Abstract sequence
(use-package :cl21.lazy) !(defun fib-seq () (labels ((rec (a b) (lazy-sequence (cons a (rec b (+ a b)))))) (rec 0 1))) !(first (rest (rest (rest (fib-seq))))) (elt (fib-seq) 3) (subseq (fib-seq) 0 5)
Expressiveness of CL21
CL21!!!! lazy-sequence !!! first rest rest rest elt subseq
Abstract sequence
Builtin sequence functions are available
Goal 3: Compatibility
Compatibility of CL21
• Written in Common Lisp
• 100% compatible with Common Lisp
• All CL libraries are available
Compatibility of CL21
(defsystem my-cl21-app :defsystem-depends-on (:cl21) :class :cl21-system :components ((:file "src/myapp")))
Compatibility of CL21
(defsystem my-cl21-app :defsystem-depends-on (:cl21) :class :cl21-system :components ((:file "src/myapp")))
! :defsystem-depends-on (:cl21) :class :cl21-system
Goal 4: Efficiency
Efficiency of CL21
• (less important in CL21, though)
• Generic methods are slow
• Compiler macros
4 Goals of CL21
Consistency
Compatibility
Efficiency
Expressiveness
Other topics: “syntax”
“syntax”
• CL21 has “syntax”
• “syntax” = readtable bound to a package
“syntax”(defsyntax cl21.process ((#\# #\`) #'run-process-reader)) !(export-syntax 'cl21.process)
(use-package :cl21.process) !#`ls -l /Users`
Other topics: Standard libraries
Batteries included (?)
• cl21.re
• cl21.process
• cl21.lazy
• cl21.os
Remember CL21 is 100% compatible with Common Lisp
You see how Common Lisp is expressive and growable?
Current status
Current status
• Still in development
• No backward-compatibility guaranteed
• We’ll release in the 21st century
• Not settled discussions
• loop vs iterate vs series
Make Lisp the Premier Prototyping Language.
— Richard P. Gabriel “Worse Is Better”
Thanks.
EITARO FUKAMACHI 8arrow.org @nitro_idiot fukamachi