86
Redesigning Common Lisp Shibuya.lisp Tech Talk #8 Eitaro Fukamachi

Redesigning Common Lisp

Embed Size (px)

DESCRIPTION

Shibuya.lisp Tech Talk #8

Citation preview

Page 1: Redesigning Common Lisp

Redesigning Common Lisp

Shibuya.lisp Tech Talk #8 Eitaro Fukamachi

Page 2: Redesigning Common Lisp

Thank you for coming.

Page 3: Redesigning Common Lisp

I’m Eitaro Fukamachi @nitro_idiot fukamachi

Page 4: Redesigning Common Lisp

(and 'web-application-developer 'common-lisper)

Page 5: Redesigning Common Lisp

Others

Clojure

Perl

Emacs Lisp

JavaScript

Common Lisp

GitHub product languages

Page 6: Redesigning Common Lisp

GitHub product languages

Page 7: Redesigning Common Lisp

I ♥ Common Lisp

Page 8: Redesigning Common Lisp

because…

Page 9: Redesigning Common Lisp

Common Lisp is the most powerful, expressive and fast language ever.

Page 10: Redesigning Common Lisp

Common Lisp is damn powerful

• First class functions + lexical closures

• Object system + multiple dispatch

• Metaobject protocol

Page 11: Redesigning Common Lisp

Common Lisp is expressive

• Reader macros

• Macros

Page 12: Redesigning Common Lisp

Common Lisp is fast

• (Optional) type declaration

• Inlining functions

• Compiler macros

• Disassembler included

• Free high-performance implementation

Page 13: Redesigning Common Lisp

Common Lisp is the most powerful, expressive and fast language ever.

Page 14: Redesigning Common Lisp

= GOD LANGUAGE

Page 15: Redesigning Common Lisp

So, here is a question.

Page 16: Redesigning Common Lisp

Is Common Lisp perfect?

Page 17: Redesigning Common Lisp

Is Common Lisp successful?

Page 18: Redesigning Common Lisp

Is Common Lisp attractive to young people?

Page 19: Redesigning Common Lisp

……………..

Page 20: Redesigning Common Lisp

“well…”

Page 21: Redesigning Common Lisp

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

Page 22: Redesigning Common Lisp

It’s because of the origin.

Page 23: Redesigning Common Lisp

8 Goals of standardising Common Lisp

Commonality

Portability

Consistency

Expressiveness

Compatibility

Efficiency

PowerStability

from Common Lisp the Language

Page 24: Redesigning Common Lisp

Common Lisp is a compound of MacLISP, Zetalisp, Spice Lisp, NIL and S-1 Lisp.

Page 25: Redesigning Common Lisp

Common Lisp was designed for MacLISP, Zetalisp, Spice Lisp, NIL and S-1 Lisp users, not us.

Page 26: Redesigning Common Lisp

Besides, Common Lisp is old.

Page 27: Redesigning Common Lisp

Common Lisp = 30 years old Ruby = 19 years old JavaScript = 19 years old Clojure = 7 years old

Page 28: Redesigning Common Lisp

Common Lisp was designed for people 30 years ago.

Page 29: Redesigning Common Lisp

But it doesn’t mean Common Lisp is obsolete.

Page 30: Redesigning Common Lisp

Common Lisp is the most powerful, expressive and fast language ever.

Page 31: Redesigning Common Lisp

Common Lisp is the best one, but I’m still not fulfilled in it.

Page 32: Redesigning Common Lisp

CLtL3? Almost hopeless.

Page 33: Redesigning Common Lisp

Let’s redesign Common Lisp for the 21st century by ourselves.

Page 34: Redesigning Common Lisp

“Common Lisp for the 21st century”

Page 35: Redesigning Common Lisp

“CL21”

Page 36: Redesigning Common Lisp

What is CL21?

• (One of) the next generation of Common Lisp

• Bases on Common Lisp

• Designed for us

• Actual implementation(not only discussions)

Page 37: Redesigning Common Lisp

8 Goals of standardising Common Lisp

Commonality

Portability

Consistency

Expressiveness

Compatibility

Efficiency

PowerStability

from Common Lisp the Language

Page 38: Redesigning Common Lisp

4 Goals of CL21

Consistency

Compatibility

Efficiency

Expressiveness

Page 39: Redesigning Common Lisp

Goal 1: Consistency

Page 40: Redesigning Common Lisp

Consistency of CL21

• Naming convention

• Argument order

Page 41: Redesigning Common Lisp

(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

Page 42: Redesigning 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

Page 43: Redesigning Common Lisp

(getf person :name) (gethash :name person-hash)

Consistency of CL21

Common Lisp

Page 44: Redesigning Common Lisp

(getf person :name) (gethash person-hash :name)

Consistency of CL21

CL21

Page 45: Redesigning Common Lisp

Goal 2: Expressiveness

Page 46: Redesigning Common Lisp

Expressiveness of CL21

• Specific vs Generic

• Delete useless symbols

Page 47: Redesigning Common Lisp

Expressiveness of CL21

• Specific vs Generic

• Delete useless symbols

Page 48: Redesigning Common Lisp

Expressiveness of CL21

• Specific vs Generic

• Delete useless symbols

Page 49: Redesigning Common Lisp

Expressiveness of CL21

• Specific vs Generic

• Delete useless symbols

(ed “~/.sbclrc”)

Page 50: Redesigning Common Lisp

Expressiveness of CL21

• Specific vs Generic

• Delete useless symbols

(ed “~/.sbclrc”)

Are you crazy????

Page 51: Redesigning Common Lisp

(append '(1 2 3) '(a b c)) (concatenate 'vector #(1 2 3) '()) (concatenate 'string "Hello, " name)

Expressiveness of CL21

Common Lisp

Page 52: Redesigning Common Lisp

(append '(1 2 3) '(a b c)) (append #(1 2 3) '()) (append "Hello, " name)

Expressiveness of CL21

CL21

Page 53: Redesigning Common Lisp

(mapcar #'1+ '(1 2 3)) (map 'vector #'1+ #(1 2 3))

Expressiveness of CL21

Common Lisp

Page 54: Redesigning Common Lisp

(map #'1+ '(1 2 3)) (map #'1+ #(1 2 3))

Expressiveness of CL21

CL21

Page 55: Redesigning Common Lisp

(format nil "Hello, World!~%") (format nil "Hello, ~A~%" name)

Expressiveness of CL21

Common Lisp

Page 56: Redesigning Common Lisp

"Hello, World!\n" #"Hello, ${name}\n"

Expressiveness of CL21

CL21

Page 57: Redesigning Common Lisp

(parse-integer "1984") (symbol-name 'alien-technology)

Expressiveness of CL21

Common Lisp

Page 58: Redesigning Common Lisp

(coerce "1984" 'integer) (coerce 'alien-technology 'string)

Expressiveness of CL21

CL21

Page 59: Redesigning Common Lisp

(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

Page 60: Redesigning 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

Page 61: Redesigning 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!! #/^(\d{4})-(\d{2})-(\d{2})$/ #/a/ig

Page 62: Redesigning 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!! #/^(\d{4})-(\d{2})-(\d{2})$/ #/a/ig

Appliable Regex literal

Page 63: Redesigning Common Lisp

(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

Page 64: Redesigning 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

Page 65: Redesigning 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!!!! lazy-sequence !!

Abstract sequence

Page 66: Redesigning 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!!!! lazy-sequence !!! first rest rest rest elt subseq

Abstract sequence

Builtin sequence functions are available

Page 67: Redesigning Common Lisp

Goal 3: Compatibility

Page 68: Redesigning Common Lisp

Compatibility of CL21

• Written in Common Lisp

• 100% compatible with Common Lisp

• All CL libraries are available

Page 69: Redesigning Common Lisp

Compatibility of CL21

(defsystem my-cl21-app :defsystem-depends-on (:cl21) :class :cl21-system :components ((:file "src/myapp")))

Page 70: Redesigning Common Lisp

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

Page 71: Redesigning Common Lisp

Goal 4: Efficiency

Page 72: Redesigning Common Lisp

Efficiency of CL21

• (less important in CL21, though)

• Generic methods are slow

• Compiler macros

Page 73: Redesigning Common Lisp

4 Goals of CL21

Consistency

Compatibility

Efficiency

Expressiveness

Page 74: Redesigning Common Lisp

Other topics: “syntax”

Page 75: Redesigning Common Lisp

“syntax”

• CL21 has “syntax”

• “syntax” = readtable bound to a package

Page 76: Redesigning Common Lisp

“syntax”(defsyntax cl21.process ((#\# #\`) #'run-process-reader)) !(export-syntax 'cl21.process)

(use-package :cl21.process) !#`ls -l /Users`

Page 77: Redesigning Common Lisp

Other topics: Standard libraries

Page 78: Redesigning Common Lisp

Batteries included (?)

• cl21.re

• cl21.process

• cl21.lazy

• cl21.os

Page 79: Redesigning Common Lisp

Remember CL21 is 100% compatible with Common Lisp

Page 80: Redesigning Common Lisp

You see how Common Lisp is expressive and growable?

Page 81: Redesigning Common Lisp

Current status

Page 82: Redesigning Common Lisp

Current status

• Still in development

• No backward-compatibility guaranteed

• We’ll release in the 21st century

• Not settled discussions

• loop vs iterate vs series

Page 83: Redesigning Common Lisp

WEB SITE:

cl21.org !

GITHUB:

github.com/cl21/cl21

Page 84: Redesigning Common Lisp

Make Lisp the Premier Prototyping Language.

— Richard P. Gabriel “Worse Is Better”

Page 85: Redesigning Common Lisp

Thanks.

Page 86: Redesigning Common Lisp

EITARO FUKAMACHI 8arrow.org @nitro_idiot fukamachi