123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- % Local Variables:
- % TeX-command-extra-options: "-shell-escape"
- % End:
- \documentclass{beamer}
- \title{Modern Game Dev with Lisp}
- \subtitle{A lisp propaganda piece}
- \author{Lily Carpenter}
- \institute{https://www.azrazalea.net}
- \mode<presentation> {\usetheme{Dresden}}
- \date{2016-02-04}
- \usepackage[utf8]{inputenc}
- \usepackage{times}
- \usepackage[T1]{fontenc}
- \usepackage[english]{babel}
- \usepackage{hyperref}
- \usepackage{minted}
- \usepackage{upquote}
- \begin{document}
- \begin{frame}
- \titlepage
- \end{frame}
- \begin{frame}
- \frametitle{Summary}
- \tableofcontents
- \end{frame}
- \begin{frame}
- \frametitle{Get it here!}
- \href{https://gitlab.com/azrazalea/lisp-game-dev-presentation}{https://gitlab.com/azrazalea/lisp-game-dev-presentation}
- \end{frame}
- \section{What is lisp?}
- \begin{frame}
- \frametitle{John McCarthy(1927-09-04 to 2011-10-24)}
- \begin{center}
- \includegraphics[scale=0.33]{john-mccarthy-programming-wrong}
- \end{center}
- \end{frame}
- \begin{frame}[fragile]
- \frametitle{An example}
- \begin{minted}[gobble=4,fontsize=\footnotesize]{cl}
- ;; From http://rosettacode.org/wiki/Fibonacci_sequence
- (defun fibonacci-tail-recursive (n &optional (a 0) (b 1))
- (if (= n 0)
- a
- (fibonacci-tail-recursive (- n 1) b (+ a b))))
- \end{minted}
- \end{frame}
- \begin{frame}
- \frametitle{Lisp Implementations}
- \begin{itemize}
- \item Common Lisp is an ansi standard.
- \item There are many implementations of this standard, both commercial and open source.
- \item The current most popular appear to be \href{http://sbcl.org/}{SBCL} and \href{http://ccl.clozure.com/}{CCL}.
- \item There are many differences between implementations, but they are generally easy to deal with using libraries built for the purpose.
- \end{itemize}
- \end{frame}
- \begin{frame}
- \frametitle{Lisp Libraries}
- \begin{itemize}
- \item Quicklisp is the library manager for Lisp. \href{https://beta.quicklisp.org}{https://beta.quicklisp.org}.
- \item While still marked as ``beta'' it is stable and usable. It just lacks some features the author wants to add before considering it released.
- \item Coolest feature is the ability to install + load libraries completely from the Lisp repl without restarting the process.
- \end{itemize}
- \end{frame}
- \section{Useful Lisp Features}
- \begin{frame}[fragile]
- \frametitle{Compiled and Interpreted (simultaneously)}
- \begin{minted}{lisp}
- (disassemble (defun add () (+ 2 4)))
- ; disassembly for ADD
- ; Size: 22 bytes. Origin: #x1003BA0A04
- ; 04: 498B4C2460 MOV RCX, [R12+96] ; thread.binding-stack-pointer
- ; no-arg-parsing entry point
- ; 09: 48894DF8 MOV [RBP-8], RCX
- ; 0D: BA0C000000 MOV EDX, 12
- ; 12: 488BE5 MOV RSP, RBP
- ; 15: F8 CLC
- ; 16: 5D POP RBP
- ; 17: C3 RET
- ; 18: CC10 BREAK 16 ; Invalid argument count trap
- \end{minted}
- \end{frame}
- \begin{frame}
- \frametitle{"Gradual Typing"}
- \begin{itemize}
- \item Can declare types of arguments and function returns values. Commonly only argument types are declared.
- \item Type system integrated with Object System, used for generics/method dispatch.
- \item In SBCL types are verified at compile time in certain cases, some other implementations only verify at run time.
- \item SBCL will use types to optimize the compiled code, resulting in large performance improvements in some cases.
- \item Unfortunately compile-time checking is not that advanced, mostly only catches constants/literals.
- \end{itemize}
- \end{frame}
- \begin{frame}[fragile]
- \frametitle{Types Example}
- \begin{minted}{lisp}
- (declaim (ftype (function
- (number number)
- number) add))
- (defun add (x y)
- (declare (number x y))
- (the number (+ x y)))
- ; NIL
- (add 1 2)
- ; 3
- (add "string" 2)
- ; The value "string" is not of type NUMBER.
- \end{minted}
- \end{frame}
- \begin{frame}
- \frametitle{Object System}
- \begin{itemize}
- \item Classes have slots (``instance variables'')
- \item Methods are defined in terms of generic functions.
- \item Uses multiple dispatch instead of single.
- \item Has multiple inheritance.
- \item Has cool :before, :after, and :around methods
- \item Super dynamic, can change class definitions at runtime even when instances already exist.
- \end{itemize}
- \end{frame}
- \begin{frame}[fragile]
- \frametitle{Simple CLOS Example}
- \begin{minted}[fontsize=\footnotesize]{lisp}
- (defclass dog ()
- ((name :reader name :initarg :name :type string)
- (age :accessor age :type fixnum :initarg :age)))
- (defgeneric speak (thing))
- (defmethod speak ((rover dog))
- (dotimes (times (age rover))
- (format t "~A SPEAK!~%" (name rover))
- (format t "WOOF!~%")))
- (let ((our-dog
- (make-instance 'dog :name "Stupid dog!" :age 1)))
- (speak our-dog)
- ; Stupid dog! SPEAK!
- ; WOOF!
- (incf (age our-dog))
- (speak our-dog)
- ; Stupid dog! Speak!
- ; WOOF!
- ; Stupid dog! Speak!
- ; WOOF!
- )
- \end{minted}
- \end{frame}
- \end{document}
|