A presentation on making games with Common Lisp. Intended for people who do not currently program in Common Lisp, so includes some general Common Lisp knowledge/propaganda. Written in LaTex, exported as pdf.

presentation.tex 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. % Local Variables:
  2. % TeX-command-extra-options: "-shell-escape"
  3. % End:
  4. \documentclass{beamer}
  5. \title{Modern Game Dev with Lisp}
  6. \subtitle{A lisp propaganda piece}
  7. \author{Lily Carpenter}
  8. \institute{https://www.azrazalea.net}
  9. \mode<presentation> {\usetheme{Dresden}}
  10. \date{2016-02-04}
  11. \usepackage[utf8]{inputenc}
  12. \usepackage{times}
  13. \usepackage[T1]{fontenc}
  14. \usepackage[english]{babel}
  15. \usepackage{hyperref}
  16. \usepackage{minted}
  17. \usepackage{upquote}
  18. \begin{document}
  19. \begin{frame}
  20. \titlepage
  21. \end{frame}
  22. \begin{frame}
  23. \frametitle{Summary}
  24. \tableofcontents
  25. \end{frame}
  26. \begin{frame}
  27. \frametitle{Get it here!}
  28. \href{https://gitlab.com/azrazalea/lisp-game-dev-presentation}{https://gitlab.com/azrazalea/lisp-game-dev-presentation}
  29. \end{frame}
  30. \section{What is lisp?}
  31. \begin{frame}
  32. \frametitle{John McCarthy(1927-09-04 to 2011-10-24)}
  33. \begin{center}
  34. \includegraphics[scale=0.33]{john-mccarthy-programming-wrong}
  35. \end{center}
  36. \end{frame}
  37. \begin{frame}[fragile]
  38. \frametitle{An example}
  39. \begin{minted}[gobble=4,fontsize=\footnotesize]{cl}
  40. ;; From http://rosettacode.org/wiki/Fibonacci_sequence
  41. (defun fibonacci-tail-recursive (n &optional (a 0) (b 1))
  42. (if (= n 0)
  43. a
  44. (fibonacci-tail-recursive (- n 1) b (+ a b))))
  45. \end{minted}
  46. \end{frame}
  47. \begin{frame}
  48. \frametitle{Lisp Implementations}
  49. \begin{itemize}
  50. \item Common Lisp is an ansi standard.
  51. \item There are many implementations of this standard, both commercial and open source.
  52. \item The current most popular appear to be \href{http://sbcl.org/}{SBCL} and \href{http://ccl.clozure.com/}{CCL}.
  53. \item There are many differences between implementations, but they are generally easy to deal with using libraries built for the purpose.
  54. \end{itemize}
  55. \end{frame}
  56. \begin{frame}
  57. \frametitle{Lisp Libraries}
  58. \begin{itemize}
  59. \item Quicklisp is the library manager for Lisp. \href{https://beta.quicklisp.org}{https://beta.quicklisp.org}.
  60. \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.
  61. \item Coolest feature is the ability to install + load libraries completely from the Lisp repl without restarting the process.
  62. \end{itemize}
  63. \end{frame}
  64. \section{Useful Lisp Features}
  65. \begin{frame}[fragile]
  66. \frametitle{Compiled and Interpreted (simultaneously)}
  67. \begin{minted}{lisp}
  68. (disassemble (defun add () (+ 2 4)))
  69. ; disassembly for ADD
  70. ; Size: 22 bytes. Origin: #x1003BA0A04
  71. ; 04: 498B4C2460 MOV RCX, [R12+96] ; thread.binding-stack-pointer
  72. ; no-arg-parsing entry point
  73. ; 09: 48894DF8 MOV [RBP-8], RCX
  74. ; 0D: BA0C000000 MOV EDX, 12
  75. ; 12: 488BE5 MOV RSP, RBP
  76. ; 15: F8 CLC
  77. ; 16: 5D POP RBP
  78. ; 17: C3 RET
  79. ; 18: CC10 BREAK 16 ; Invalid argument count trap
  80. \end{minted}
  81. \end{frame}
  82. \begin{frame}
  83. \frametitle{"Gradual Typing"}
  84. \begin{itemize}
  85. \item Can declare types of arguments and function returns values. Commonly only argument types are declared.
  86. \item Type system integrated with Object System, used for generics/method dispatch.
  87. \item In SBCL types are verified at compile time in certain cases, some other implementations only verify at run time.
  88. \item SBCL will use types to optimize the compiled code, resulting in large performance improvements in some cases.
  89. \item Unfortunately compile-time checking is not that advanced, mostly only catches constants/literals.
  90. \end{itemize}
  91. \end{frame}
  92. \begin{frame}[fragile]
  93. \frametitle{Types Example}
  94. \begin{minted}{lisp}
  95. (declaim (ftype (function
  96. (number number)
  97. number) add))
  98. (defun add (x y)
  99. (declare (number x y))
  100. (the number (+ x y)))
  101. ; NIL
  102. (add 1 2)
  103. ; 3
  104. (add "string" 2)
  105. ; The value "string" is not of type NUMBER.
  106. \end{minted}
  107. \end{frame}
  108. \begin{frame}
  109. \frametitle{Object System}
  110. \begin{itemize}
  111. \item Classes have slots (``instance variables'')
  112. \item Methods are defined in terms of generic functions.
  113. \item Uses multiple dispatch instead of single.
  114. \item Has multiple inheritance.
  115. \item Has cool :before, :after, and :around methods
  116. \item Super dynamic, can change class definitions at runtime even when instances already exist.
  117. \end{itemize}
  118. \end{frame}
  119. \begin{frame}[fragile]
  120. \frametitle{Simple CLOS Example}
  121. \begin{minted}[fontsize=\footnotesize]{lisp}
  122. (defclass dog ()
  123. ((name :reader name :initarg :name :type string)
  124. (age :accessor age :type fixnum :initarg :age)))
  125. (defgeneric speak (thing))
  126. (defmethod speak ((rover dog))
  127. (dotimes (times (age rover))
  128. (format t "~A SPEAK!~%" (name rover))
  129. (format t "WOOF!~%")))
  130. (let ((our-dog
  131. (make-instance 'dog :name "Stupid dog!" :age 1)))
  132. (speak our-dog)
  133. ; Stupid dog! SPEAK!
  134. ; WOOF!
  135. (incf (age our-dog))
  136. (speak our-dog)
  137. ; Stupid dog! Speak!
  138. ; WOOF!
  139. ; Stupid dog! Speak!
  140. ; WOOF!
  141. )
  142. \end{minted}
  143. \end{frame}
  144. \end{document}