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 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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 my presentation 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}
  38. \frametitle{History}
  39. \begin{itemize}
  40. \item Lisp (not Common Lisp) was originally implemented in the early 1960s.
  41. \item Really took off in the 1970s and 1980s.
  42. \item Lots of differing implementations with their own ideas and features during this time period.
  43. \item Common Lisp became an ANSI standard in 1994.
  44. \item Historically used primarily for Artificial Intelligence.
  45. \item Use drastically lowered after the decline of AI funding when the world realized ``true AI'' was further off than they thought.
  46. \end{itemize}
  47. \end{frame}
  48. \begin{frame}
  49. \frametitle{Made with Secret Alien Technology}
  50. \begin{center}
  51. \includegraphics[scale=0.75]{lisplogo_256}
  52. \end{center}
  53. \end{frame}
  54. \begin{frame}[fragile]
  55. \frametitle{An example}
  56. \begin{minted}[gobble=4,fontsize=\footnotesize]{cl}
  57. ;; From http://rosettacode.org/wiki/Fibonacci_sequence
  58. (defun fibonacci-tail-recursive (n &optional (a 0) (b 1))
  59. (if (= n 0)
  60. a
  61. (fibonacci-tail-recursive (- n 1) b (+ a b))))
  62. \end{minted}
  63. \end{frame}
  64. \begin{frame}
  65. \frametitle{Lisp Implementations}
  66. \begin{itemize}
  67. \item Common Lisp is an ansi standard.
  68. \item There are many implementations of this standard, both commercial and open source.
  69. \item The current most popular appear to be \href{http://sbcl.org/}{SBCL} and \href{http://ccl.clozure.com/}{CCL}.
  70. \item There are many differences between implementations, but they are generally easy to deal with using libraries built for the purpose.
  71. \end{itemize}
  72. \end{frame}
  73. \begin{frame}
  74. \frametitle{Lisp Libraries}
  75. \begin{itemize}
  76. \item Quicklisp is the library manager for Lisp. \href{https://beta.quicklisp.org}{https://beta.quicklisp.org}.
  77. \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.
  78. \item Coolest feature is the ability to install + load libraries completely from the Lisp REPL without restarting the process.
  79. \end{itemize}
  80. \end{frame}
  81. \section{Useful Lisp Features}
  82. \begin{frame}[fragile]
  83. \frametitle{Compiled and Interpreted (simultaneously)}
  84. \begin{minted}{lisp}
  85. (disassemble (defun add () (+ 2 4)))
  86. ; disassembly for ADD
  87. ; Size: 22 bytes. Origin: #x1003BA0A04
  88. ; 04: 498B4C2460 MOV RCX, [R12+96] ; thread.binding-stack-pointer
  89. ; no-arg-parsing entry point
  90. ; 09: 48894DF8 MOV [RBP-8], RCX
  91. ; 0D: BA0C000000 MOV EDX, 12
  92. ; 12: 488BE5 MOV RSP, RBP
  93. ; 15: F8 CLC
  94. ; 16: 5D POP RBP
  95. ; 17: C3 RET
  96. ; 18: CC10 BREAK 16 ; Invalid argument count trap
  97. \end{minted}
  98. \end{frame}
  99. \begin{frame}
  100. \frametitle{"Gradual Typing"}
  101. \begin{itemize}
  102. \item Can declare types of arguments and function returns values. Commonly only argument types are declared.
  103. \item Type system integrated with Object System, used for generics/method dispatch.
  104. \item In SBCL types are verified at compile time in certain cases, some other implementations only verify at run time.
  105. \item SBCL will use types to optimize the compiled code, resulting in large performance improvements in some cases.
  106. \item Unfortunately compile-time checking is not that advanced, mostly only catches constants/literals.
  107. \end{itemize}
  108. \end{frame}
  109. \begin{frame}[fragile]
  110. \frametitle{Types Example}
  111. \begin{minted}{lisp}
  112. (declaim (ftype (function
  113. (number number)
  114. number) add))
  115. (defun add (x y)
  116. (declare (number x y))
  117. (the number (+ x y)))
  118. ; NIL
  119. (add 1 2)
  120. ; 3
  121. (add "string" 2)
  122. ; The value "string" is not of type NUMBER.
  123. \end{minted}
  124. \end{frame}
  125. \begin{frame}
  126. \frametitle{Object Oriented programming}
  127. \begin{itemize}
  128. \item Classes have slots (``instance variables'')
  129. \item Methods are defined in terms of generic functions.
  130. \item Uses multiple dispatch instead of single.
  131. \item Has multiple inheritance.
  132. \item Has cool :before, :after, and :around methods
  133. \item Super dynamic, can change class definitions at runtime even when instances already exist.
  134. \end{itemize}
  135. \end{frame}
  136. \begin{frame}[fragile]
  137. \frametitle{Simple CLOS Example}
  138. \begin{minted}[fontsize=\footnotesize]{lisp}
  139. (defclass dog ()
  140. ((name :reader name :initarg :name :type string)
  141. (age :accessor age :type fixnum :initarg :age)))
  142. (defgeneric speak (thing))
  143. (defmethod speak ((rover dog))
  144. (dotimes (times (age rover))
  145. (format t "~A SPEAK!~%" (name rover))
  146. (format t "WOOF!~%")))
  147. (let ((our-dog
  148. (make-instance 'dog :name "Stupid dog!" :age 1)))
  149. (speak our-dog)
  150. ; Stupid dog! SPEAK!
  151. ; WOOF!
  152. (incf (age our-dog))
  153. (speak our-dog)
  154. ; Stupid dog! Speak!
  155. ; WOOF!
  156. ; Stupid dog! Speak!
  157. ; WOOF!
  158. )
  159. \end{minted}
  160. \end{frame}
  161. \begin{frame}
  162. \frametitle{Package System}
  163. \begin{itemize}
  164. \item Basically a namespace/module system. Using it may seem similar to clojure or javascript's ES6 modules.
  165. \item The way it actually works under the hood is super cool and different from most others.
  166. \item See \href{http://www.gigamonkeys.com/book/programming-in-the-large-packages-and-symbols.html}{Practical Common Lisp} for more info.
  167. \end{itemize}
  168. \end{frame}
  169. \begin{frame}[fragile]
  170. \frametitle{C Foreign Function Interface}
  171. \begin{itemize}
  172. \item Lisp has an excellent CFFI library found at \href{https://common-lisp.net/project/cffi/}{https://common-lisp.net/project/cffi/}. It is in quicklisp.
  173. \item The CFFI is used heavily for game development, as OpenGL and other libraries are C.
  174. \item Cool library \href{https://github.com/rpav/cl-autowrap}{https://github.com/rpav/cl-autowrap} makes making a new CFFI wrapper super easy.
  175. \end{itemize}
  176. \end{frame}
  177. \begin{frame}
  178. \frametitle{The REPL}
  179. \begin{itemize}
  180. \item The sheer power of the Common Lisp REPL is greater than any other REPL I know of.
  181. \item REPL driven development is THE primary paradigm for common lisp (no this is not really at odds with TDD).
  182. \item You can do practically anything in the REPL that you could do in a file, all without having to restart your process.
  183. \item For a user friendly REPL experience you will want to use Emacs + Slime, Vim + slimv, or one of the few lisp specific IDEs.
  184. \item The default command line REPLs for most implementations have a rather bad user experience compared to the above.
  185. \end{itemize}
  186. \end{frame}
  187. \section{Lisp game tools}
  188. \begin{frame}
  189. \frametitle{Lispgames Group}
  190. \begin{itemize}
  191. \item \href{https://github.com/lispgames}{https://github.com/lispgames}
  192. \item Benevolent leader rpav/oGMo \href{https://github.com/rpav}{https://github.com/rpav}
  193. \item Freenode IRC channel \#lispgames
  194. \item In progress wiki/site \href{http://lispgames.org}{http://lispgames.org}
  195. \item Focused on Common Lisp but all lispers welcome including Scheme, Clojure, and others.
  196. \end{itemize}
  197. \end{frame}
  198. \begin{frame}
  199. \frametitle{Libraries}
  200. \begin{itemize}
  201. \item For the most part if you don't want to use a pre-built engine/framework you probably want to use lispgames glkit which uses cl-sdl2, cl-sdl2kit, and cl-opengl. Find it at \href{https://github.com/lispgames/glkit}{https://github.com/lispgames/glkit}. They are all in quicklisp.
  202. \item A cool 2D graphics library called sketch can be found at \href{https://github.com/vydd/sketch}{https://github.com/vydd/sketch}. It is not yet in quicklisp.
  203. \item There are a variety of other libraries in various locations, if you are looking for something in particular ask about it on \#lispgames.
  204. \end{itemize}
  205. \end{frame}
  206. \begin{frame}
  207. \frametitle{Game Engines}
  208. \begin{itemize}
  209. \item CEPL by baggers, \href{https://github.com/cbaggers/cepl}{https://github.com/cbaggers/cepl}. Active work in progress.
  210. \item CLINCH by warweasle, \href{https://github.com/BradWBeer/CLinch}{https://github.com/BradWBeer/CLinch}. Alpha, should soon be ready as a general purpose engine.
  211. \item Xelf by dto (see dto-games on youtube), GPLv3, \href{http://xelf.me/}{http://xelf.me/}. Has been used by dto to create several games.
  212. \end{itemize}
  213. \end{frame}
  214. \section{Learning resources}
  215. \begin{frame}
  216. \frametitle{Books}
  217. \begin{itemize}
  218. \item The de facto primary learning book is ``Practical Common Lisp'' and is free online at \href{http://www.gigamonkeys.com/book/}{http://www.gigamonkeys.com/book/}
  219. \item There is a brand new (not free) book being hailed as an excellent follow up called ``Common Lisp Recipes'' at \href{http://www.apress.com/9781484211779?gtmf=s}{http://www.apress.com/9781484211779?gtmf=s}
  220. \item A list of other Lisp books can be found at \href{http://cliki.net/Lisp+Books}{http://cliki.net/Lisp+Books}
  221. \end{itemize}
  222. \end{frame}
  223. \begin{frame}
  224. \frametitle{Videos}
  225. \begin{itemize}
  226. \item \href{https://www.youtube.com/channel/UCKfZ9JfFgg7cxa2hYfC5O0A}{dto-games} channel on youtube, live coding and commentary.
  227. \item cbaggers user \href{https://www.youtube.com/user/CBaggers}{https://www.youtube.com/user/CBaggers} on youtube. Demonstrations of the CEPL game engine, general tutorials.
  228. \item Axed Code (axion) short progress videos \href{https://www.youtube.com/playlist?list=PLcdTh590GDjFgdM8JVSBqFl4vJBrh8P_l}{playlist} on youtube.
  229. \end{itemize}
  230. \end{frame}
  231. \begin{frame}
  232. \frametitle{Websites}
  233. \begin{itemize}
  234. \item Common Lisp \href{http://www.lispworks.com/documentation/HyperSpec/Front/index.htm}{Hyperspec}
  235. \item \href{http://articulate-lisp.com/}{http://articulate-lisp.com/}
  236. \item Common Lisp wiki \href{http://www.cliki.net/}{http://www.cliki.net}
  237. \item Common Lisp official site \href{https://common-lisp.net/}{https://common-lisp.net/}
  238. \item Common Lisp gitlab instance \href{https://gitlab.common-lisp.net}{https://gitlab.common-lisp.net}
  239. \end{itemize}
  240. \end{frame}
  241. \section{Demonstration}
  242. \begin{frame}
  243. \frametitle{Demonstration}
  244. \begin{itemize}
  245. \item I will be running and modifying \href{https://github.com/k-stz/picking-sticks}{https://github.com/k-stz/picking-sticks}.
  246. \item You will need a lisp implementation, \href{https://www.quicklisp.org/beta/}{quicklisp}, libsdl2, libfreetype, working OpenGL drivers, and to put \href{https://github.com/rpav/texatl}{https://github.com/rpav/texatl} and \href{https://github.com/rpav/laconic}{https://github.com/rpav/laconic} in \texttildelow/quicklisp/local-projects.
  247. \item Unless you've already got most of this setup I would recommend not trying to set this up during my presentation.
  248. \end{itemize}
  249. \end{frame}
  250. \end{document}