INCREMENTAL DEVELOPMENT WITH LISP
       Building a Game and a Website




                                           @jlo...
INCREMENTAL DEVELOPMENT

• “acyclic software development process developed in
 response to the weaknesses of the waterfall...
CODING

• Let’s
      focus on PROGRAMMING, apply the same model to just
 the programmer

• Write   small pieces of code, ...
WHY LISP?

• Lisp   is famous for embracing incremental development

• Very   expressive and dynamic

• Functional
       ...
IN PRACTICE
• How    do you actually write code incrementally?

• REPL

• IDE

 • Emacs

   • SLIME

   • comint-mode
EXAMPLE #1
                                    VECTORS

• Goal: Write    a 3d vector library with support for addition

  ...
EXAMPLE #1
                                    VECTORS

• Goal: Write    a 3d vector library with support for addition
   ...
EXAMPLE #2
                          RENDER QUEUE

• Goal: Write     a library which queues objects to render
    (define ...
EXAMPLE #2
                          RENDER QUEUE

• Goal: Write     a library which queues objects to render
    (define ...
INITIAL THOUGHTS?

• Emacs greatly enhances the ability for “live coding”, could be
 done in other editors though

• “Scra...
REAL WORLD EXAMPLE #1
                            WEBSITE

• Clojure   is a Lisp dialect which runs on the JVM

• Compojur...
REAL WORLD EXAMPLE #2
                           GAME

•Iused Gambit Scheme to make
 an iPhone game, Farmageddon

• Wrote ...
REAL WORLD EXAMPLE #2
                           GAME

•Iused Gambit Scheme to make
 an iPhone game, Farmageddon

• Wrote ...
PROBLEMS

• Youmust write your code in a way that allows incremental
 development

• Your   IDE must support it

• Sometim...
WHAT ABOUT YOU?


• Most     of you don’t use Lisp, probably

• Python     and many other languages could support this too...
• Buymy game, available next week on the App Store for only
 $1.99

• @farmageddongame

• http://farmageddongame.com
Upcoming SlideShare
Loading in …5
×

Incremental Development with Lisp: Building a Game and a Website

2,846 views

Published on

I show how powerful incremental development with Lisp/Scheme is by showing a website and game I created by running the application and developing them real-time.

Published in: Technology
  • Hi, I am a lisp programming and have been for some years now. Can your provide me with some details how on your went about deploying the game. I am assuming you wrote the game in Lisp. Thanks
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Incremental Development with Lisp: Building a Game and a Website

  1. 1. INCREMENTAL DEVELOPMENT WITH LISP Building a Game and a Website @jlongster James Long
  2. 2. INCREMENTAL DEVELOPMENT • “acyclic software development process developed in response to the weaknesses of the waterfall model” - Wikipedia • Rapidly evolving software by means of frequent small changes
  3. 3. CODING • Let’s focus on PROGRAMMING, apply the same model to just the programmer • Write small pieces of code, run them, and repeat • Tweak and extend the program while it is running • Advantages: instant results, higher morale, less rabbit trails
  4. 4. WHY LISP? • Lisp is famous for embracing incremental development • Very expressive and dynamic • Functional simplicity allows for “piece-by-piece” evaluation, or running small chunks of code quickly • Thephilosophy of Lisp is built around incremental development
  5. 5. IN PRACTICE • How do you actually write code incrementally? • REPL • IDE • Emacs • SLIME • comint-mode
  6. 6. EXAMPLE #1 VECTORS • Goal: Write a 3d vector library with support for addition (define-type v3 x y z) EVAL (define (v3-add v1 v2) (make-v3 (+ (v3-x v1) (v3-x v2)) (+ (v3-y v1) (v3-y v2)) (+ (v3-z v1) (v3-z v2)))) EVAL • Intimate with what’s going on with the code
  7. 7. EXAMPLE #1 VECTORS • Goal: Write a 3d vector library with support for addition (define-type v3 (define-type v3 constructor: really-make-vec3d x y z) x y z) EVAL EVAL (define (v3-add v1 v2) (define (make-v3 x y z #!key (scale 1.)) (make-v3 (really-make-vec3d (* x scale) (+ (v3-x v1) (v3-x v2)) (* y scale) (+ (v3-y v1) (v3-y v2)) (* z scale))) (+ (v3-z v1) (v3-z v2)))) EVAL EVAL v3-add is still available • Intimate with what’s going on with the code
  8. 8. EXAMPLE #2 RENDER QUEUE • Goal: Write a library which queues objects to render (define queue '()) (define (queue-add obj) (set! queue (cons obj queue))) (define (queue-render-all) (for-each (lambda (obj) (write obj)) queue)) EVAL-REGION • Modify a program while its running and never throw away state
  9. 9. EXAMPLE #2 RENDER QUEUE • Goal: Write a library which queues objects to render (define queue '()) (define (queue-render-all) (define (queue-add obj) (display "--- RENDERED OBJECTS ---n") (set! queue (cons obj queue))) (for-each (lambda (obj) (display obj) (define (queue-render-all) (newline)) (for-each (lambda (obj) queue)) (write obj)) queue)) queue and queue-add are the same as before EVAL-REGION • Modify a program while its running and never throw away state
  10. 10. INITIAL THOUGHTS? • Emacs greatly enhances the ability for “live coding”, could be done in other editors though • “Scratch buffers” are commonly used to test the system • Your “scratch code” evolves into unit tests
  11. 11. REAL WORLD EXAMPLE #1 WEBSITE • Clojure is a Lisp dialect which runs on the JVM • Compojure is a web framework developed in Clojure • jlongster.com • Clojure supports SLIME, an incredible development environment fully embracing incremental development
  12. 12. REAL WORLD EXAMPLE #2 GAME •Iused Gambit Scheme to make an iPhone game, Farmageddon • Wrote a tool that embeds “remote REPLs” in applications so that you can develop it SLIME-style • Extended Emacs keybindings
  13. 13. REAL WORLD EXAMPLE #2 GAME •Iused Gambit Scheme to make an iPhone game, Farmageddon • Wrote a tool that embeds “remote REPLs” in applications so that you can develop it SLIME-style • Extended Emacs keybindings
  14. 14. PROBLEMS • Youmust write your code in a way that allows incremental development • Your IDE must support it • Sometimes there’s a lot of overhead for little gain
  15. 15. WHAT ABOUT YOU? • Most of you don’t use Lisp, probably • Python and many other languages could support this too • It’s a different mindset that I challenge you to try
  16. 16. • Buymy game, available next week on the App Store for only $1.99 • @farmageddongame • http://farmageddongame.com

×