KARELIA UNIVERSITY of APPLIED SCIENCES Degree Programme in Business Information Technology
Total Page:16
File Type:pdf, Size:1020Kb
KARELIA UNIVERSITY OF APPLIED SCIENCES Degree Programme in Business Information Technology Aki Kaisanlahti APPLICABILITY OF COMMON LISP IN GAME DEVELOPMENT Thesis February 2017 THESIS February 2017 All Degree Programmes Tikkarinne 9 80220 JOENSUU FINLAND (013) 260 600 Author (s) Aki Kaisanlahti Title Applicability of Common Lisp in Game Development Commissioned by NKUAS and KUAS Abstract The aim of the this thesis was to find out how applicable Common Lisp is in game development through examining the language and game development as well as trying to build a core of a game development framework with Common Lisp. Common Lisp was inspected as a programming language on its own, through comparing it with C family languages as well as in game development context through earlier use in video games. Game development was covered through examining tools and methods based on a programming perspective. Criteria for the final evaluation of the framework and Common Lisp in game development in general were based on what distinguishes game development from general software as far as development is concerned. The core of the programming library is based on Common Lisp macros; its API implementation is based on lower level programming libraries. The game development library is designed very strongly based on a programmer's perspective and aimed at other programmers in order to fo- cus on distinguishing points of Common Lisp in game development. The applicability of Common Lisp and the game development library in game development are based on the flexibility of the language due to its design. Future development of the library and with the library would make it possible to observe its applicability on a larger scale in game de - velopment. It would also enable broadening the possibilities of the API and fixing current is- sues such as foreign memory problems with foreign language library bindings or replacing them with native Common Lisp solutions. Language Pages 51 English Appendices 1 Keywords Common Lisp, game development, macros OPINNÄYTETYÖ Helmikuu 2017 Kaikki koulutukset Tikkarinne 9 80220 JOENSUU (013) 260 600 Tekijä(t) Aki Kaisanlahti Nimeke Common Lispin soveltuvuus pelinkehitykseen Toimeksiantaja PKAMK ja Karelia-amk Tiivistelmä Opinnäytetyössä tutkittiin Common Lisp -ohjelmointikieltä, pelinkehitystä ja Common Lispin edellytyksiä siihen. Common Lispillä toteutettiin myös pienimuotoisen pelinkehitykseen tarkoitetun ohjelmointikirjaston pohja. Common Lisp -kieltä käsiteltiin itsenäisesti, C-pohjaisiin kieliin verraten sekä pelinkehityskontekstissa. Modernia pelinkehitystä käsiteltiin metodien ja työkalujen näkökulmasta ohjelmointikeskeisesti. Tämän perusteella määriteltiin kriteerit, jotka erottavat pelinkehityksen normaalista ohjelmistokehityksestä. Kriteerien avulla voitiin arvioida ohjelmointikirjastoa ja Common Lispiä pelinkehityksessä Ohjelmointikirjaston pohja tukeutuu Common Lispin makroihin; ohjelmointirajapinnan sisäinen toteutus perustuu muihin alemman tason ohjelmointikirjastoihin. Ohjelmointikirjasto on suunniteltu vahvasti ohjelmoijanäkökulmasta ohjelmoijille, jotta voitiin keskittää huomio Common Lispin erityispiirteisiin pelinkehityksessä. Common Lispin ja ohjelmointikirjaston vahvuudet pelinkehityksessä perustuvat kielen joustavuuteen kielisuunnittelun ansiosta. Jatkokehitys selventäisi laajemmin kielen soveltuvuutta pelinkehitykseen. Jatkokehityksen myötä olisi myös mahdollista korjata yhteensopivuusongelmia toteutukseen käytettyjen muiden ohjelmointikielten kirjastojen kohdalla tai toteuttaa näistä Common Lispillä omat kirjastot. Kieli Sivuja 51 englanti Liitteet 1 Asiasanat Common Lisp, pelinkehitys, makrot Content Glossary...............................................................................................................6 1 INTRODUCTION...............................................................................................7 2 COMMON LISP.................................................................................................9 2.1 History and notable current implementations of Common Lisp................9 2.2 Common Lisp as a language...................................................................11 2.2.1 Language paradigms............................................................................11 2.2.2 Common Lisp syntax and language design.........................................13 2.2.3 Language comparison .........................................................................15 2.3 Programming ecosystem in Common Lisp.............................................17 2.4 Lisp in games...........................................................................................17 2.5 Performance............................................................................................19 3 GAME DEVELOPMENT..................................................................................20 3.1 Game development methods..................................................................21 3.2 Game development tools.........................................................................22 3.3 Criteria for game development................................................................24 4 LUCERNA: PREPARATION............................................................................25 4.1 Tests........................................................................................................26 4.1.1 Classimp...............................................................................................26 4.1.2 SDL.......................................................................................................27 4.1.3 Cl-opengl..............................................................................................28 4.1.4 Combinatory tests.................................................................................29 4.1.5 Deliverable executable.........................................................................30 4.2 Component choices.................................................................................31 4.3 Development tools...................................................................................32 5 LUCERNA: IMPLEMENTATION.....................................................................33 5.1 Framework component default implementation......................................34 5.2 Framework component custom implementation.....................................35 5.3 Framework component extension...........................................................36 5.4 Demo application.....................................................................................37 6 CONCLUSION.................................................................................................39 6.1 What is Common Lisp?...........................................................................39 6.2 What is modern game development?......................................................39 6.3 Tools and libraries in small scale game development............................40 6.4 Applicability of Common Lisp in game development...............................40 6.5 Evaluation and discussion.......................................................................41 6.6 Future development.................................................................................42 References.........................................................................................................44 Appendices Appendix 1 5 Glossary XNA A framework for making games made by Microsoft. Intended to run on Microsoft platforms such as Xbox 360 and Windows. SFML Simple and Fast Multimedia Library is composed of five parts that cover system, window, graphics, audio and network usage. Originally developed for C++, it has multiple language bindings today. Developed by Laurent Gomila (Gomila, 2016). SDL Simple DirectMedia Layer is similar to SFML, but is older, more well known and used. Used partly in Unreal Engine 4 and e.g. In FTL: Faster Than Light. OpenGL Open Graphics Library is a specification made by Khronos group along with others. Used widely in many different platforms. Vulkan is a new, lower level specification made by Khronos group aimed to give more control in graphics over the GPU. CFFI Common Foreign Function Interface, Common Lisp's foreign function interface that enables handling foreign code and memory. The cornerstone of Common Lisp language bindings of common libraries such as SDL. 6 1 INTRODUCTION The aim of this thesis is to examine Common Lisp as a programming language and reflect on its applicability in game development. In order to examine this, the main questions set were: What is Common Lisp? What distinguishes game development? What tools and libraries are necessary to enable small scale game development? How applicable is Common Lisp in game development? The choice of small scale game development and low level library testing is based on the fundamentals. If you can establish reliable rendering, windowing, input and output and such, other components of game development are more about scaling and abstraction. The game development framework development process started from seeing a video on live editing code with Common Lisp. Seeing it is possible to compile code, run and see changes live while working on the code seemed like a huge quality of life improvement compared to more static environments like those generally found in the C++ ecosystem. This is within using the same language, scripting languages and interpreters are a different matter entirely. Having the desire