Racket on the Playstation 3? Its not what you think... Dan Liebgold - - PowerPoint PPT Presentation

racket on the playstation 3 it s not what you think
SMART_READER_LITE
LIVE PREVIEW

Racket on the Playstation 3? Its not what you think... Dan Liebgold - - PowerPoint PPT Presentation

Racket on the Playstation 3? Its not what you think... Dan Liebgold Naughty Dog, Inc. Santa Monica, CA RacketCon 2013 Motivation In games, programmers create code; artists, designers, animators, sound designers create data We often


slide-1
SLIDE 1

Racket on the Playstation 3? It’s not what you think...

Dan Liebgold

Naughty Dog, Inc. Santa Monica, CA

RacketCon 2013

slide-2
SLIDE 2
slide-3
SLIDE 3

Motivation

◮ In games, programmers create code; artists, designers,

animators, sound designers create data

◮ We often want to create data like we create code

◮ Effect definitions, animation states & blend trees, event &

gameplay scripting/tuning, sound metadata

◮ We want powerful abstractions, flexible syntax, and

language well matched to each domain

◮ Domain Specific Languages to the rescue!

slide-4
SLIDE 4

Motivation

◮ In games, programmers create code; artists, designers,

animators, sound designers create data

◮ We often want to create data like we create code

◮ Effect definitions, animation states & blend trees, event &

gameplay scripting/tuning, sound metadata

◮ We want powerful abstractions, flexible syntax, and

language well matched to each domain

◮ Domain Specific Languages to the rescue!

slide-5
SLIDE 5

Motivation

◮ In games, programmers create code; artists, designers,

animators, sound designers create data

◮ We often want to create data like we create code

◮ Effect definitions, animation states & blend trees, event &

gameplay scripting/tuning, sound metadata

◮ We want powerful abstractions, flexible syntax, and

language well matched to each domain

◮ Domain Specific Languages to the rescue!

slide-6
SLIDE 6

Motivation

◮ In games, programmers create code; artists, designers,

animators, sound designers create data

◮ We often want to create data like we create code

◮ Effect definitions, animation states & blend trees, event &

gameplay scripting/tuning, sound metadata

◮ We want powerful abstractions, flexible syntax, and

language well matched to each domain

◮ Domain Specific Languages to the rescue!

slide-7
SLIDE 7

Motivation

◮ In games, programmers create code; artists, designers,

animators, sound designers create data

◮ We often want to create data like we create code

◮ Effect definitions, animation states & blend trees, event &

gameplay scripting/tuning, sound metadata

◮ We want powerful abstractions, flexible syntax, and

language well matched to each domain

◮ Domain Specific Languages to the rescue!

slide-8
SLIDE 8

Scheme

◮ We had experience using Common Lisp before to create

  • ur own implementation language (GOAL)

◮ Lisp supports creating data like code ◮ We built DC in Racket

◮ Used Racket (MzScheme initially) because it’s a good Lisp,

is open source, and has quality libraries and implementation

slide-9
SLIDE 9

Scheme

◮ We had experience using Common Lisp before to create

  • ur own implementation language (GOAL)

◮ Lisp supports creating data like code ◮ We built DC in Racket

◮ Used Racket (MzScheme initially) because it’s a good Lisp,

is open source, and has quality libraries and implementation

slide-10
SLIDE 10

Scheme

◮ We had experience using Common Lisp before to create

  • ur own implementation language (GOAL)

◮ Lisp supports creating data like code ◮ We built DC in Racket

◮ Used Racket (MzScheme initially) because it’s a good Lisp,

is open source, and has quality libraries and implementation

slide-11
SLIDE 11

Scheme

◮ We had experience using Common Lisp before to create

  • ur own implementation language (GOAL)

◮ Lisp supports creating data like code ◮ We built DC in Racket

◮ Used Racket (MzScheme initially) because it’s a good Lisp,

is open source, and has quality libraries and implementation

slide-12
SLIDE 12

How?

◮ Racket program that evaluated typed “Racket-ish” code

that generates data usable by C++ runtime.

◮ Usage of syntax was the prime enabler of rapid DSL

development, but also a source of much inefficiency and confusion.

◮ Error reporting was slow to develop, since it required

careful usage of syntax info, which was difficult and confusing.

slide-13
SLIDE 13

How?

◮ Racket program that evaluated typed “Racket-ish” code

that generates data usable by C++ runtime.

◮ Usage of syntax was the prime enabler of rapid DSL

development, but also a source of much inefficiency and confusion.

◮ Error reporting was slow to develop, since it required

careful usage of syntax info, which was difficult and confusing.

slide-14
SLIDE 14

How?

◮ Racket program that evaluated typed “Racket-ish” code

that generates data usable by C++ runtime.

◮ Usage of syntax was the prime enabler of rapid DSL

development, but also a source of much inefficiency and confusion.

◮ Error reporting was slow to develop, since it required

careful usage of syntax info, which was difficult and confusing.

slide-15
SLIDE 15

Architecture

slide-16
SLIDE 16

Example

Let’s define a player start position: (define-export *player-start* (new locator :trans *origin* :rot (axis-angle->quaternion *y-axis* 45) ))

slide-17
SLIDE 17

Start with some types

(deftype vec4 (:align 16) ((x float) (y float) (z float) (w float :default 0) ))

slide-18
SLIDE 18

Start with some types

(deftype vec4 (:align 16) ((x float) (y float) (z float) (w float :default 0) )) struct Vec4 { float m_x; float m_y; float m_z; float m_w; };

slide-19
SLIDE 19

Types continued

(deftype quaternion (:parent vec4) ()) (deftype point (:parent vec4) ((w float :default 1) )) (deftype locator () ((trans point :inline #t) (rot quaternion :inline #t) ))

slide-20
SLIDE 20

Types continued

(deftype quaternion (:parent vec4) ()) (deftype point (:parent vec4) ((w float :default 1) )) (deftype locator () ((trans point :inline #t) (rot quaternion :inline #t) ))

slide-21
SLIDE 21

Types continued

(deftype quaternion (:parent vec4) ()) (deftype point (:parent vec4) ((w float :default 1) )) struct Locator { Point m_trans; Quaternion m_rot; };

slide-22
SLIDE 22

Define a function

(define (axis-angle->quat axis angle) (let ((sin-angle/2 (sin (* 0.5 angle)))) (new quaternion :x (* (-> axis x) sin-angle/2) :y (* (-> axis y) sin-angle/2) :z (* (-> axis z) sin-angle/2) :w (cos (* 0.5 angle)) )))

slide-23
SLIDE 23

Define some instances

(define *y-axis* (new vec4 :x 0 :y 1 :z 0)) (define *origin* (new point :x 0 :y 0 :z 0)) (define-export *player-start* (new locator :trans *origin* :rot (axis-angle->quaternion *y-axis* 45) ))

slide-24
SLIDE 24

Define some instances

(define *y-axis* (new vec4 :x 0 :y 1 :z 0)) (define *origin* (new point :x 0 :y 0 :z 0)) (define-export *player-start* (new locator :trans *origin* :rot (axis-angle->quaternion *y-axis* 45) ))

slide-25
SLIDE 25

How we use these definitions in C++ code

... #include "dc-types.h" ... const Locator * pLoc = DcLookupSymbol("*player-start*"); Point pos = pLoc->m_trans; ...

slide-26
SLIDE 26
slide-27
SLIDE 27

The Last of Us on the Playstation 3

◮ 16 programmers on the game project ◮ 20 designers ◮ 100 artists & animators ◮ 6000 DC files ◮ 120Mb of DC source, 45Mb of DC target binary files

◮ Dynamically loaded into about 5Mb of managed heap

space

slide-28
SLIDE 28

The Last of Us on the Playstation 3

◮ 16 programmers on the game project ◮ 20 designers ◮ 100 artists & animators ◮ 6000 DC files ◮ 120Mb of DC source, 45Mb of DC target binary files

◮ Dynamically loaded into about 5Mb of managed heap

space

slide-29
SLIDE 29

The Last of Us on the Playstation 3

◮ 16 programmers on the game project ◮ 20 designers ◮ 100 artists & animators ◮ 6000 DC files ◮ 120Mb of DC source, 45Mb of DC target binary files

◮ Dynamically loaded into about 5Mb of managed heap

space

slide-30
SLIDE 30

The Last of Us on the Playstation 3

◮ 16 programmers on the game project ◮ 20 designers ◮ 100 artists & animators ◮ 6000 DC files ◮ 120Mb of DC source, 45Mb of DC target binary files

◮ Dynamically loaded into about 5Mb of managed heap

space

slide-31
SLIDE 31

The Last of Us on the Playstation 3

◮ 16 programmers on the game project ◮ 20 designers ◮ 100 artists & animators ◮ 6000 DC files ◮ 120Mb of DC source, 45Mb of DC target binary files

◮ Dynamically loaded into about 5Mb of managed heap

space

slide-32
SLIDE 32

The Last of Us on the Playstation 3

◮ 16 programmers on the game project ◮ 20 designers ◮ 100 artists & animators ◮ 6000 DC files ◮ 120Mb of DC source, 45Mb of DC target binary files

◮ Dynamically loaded into about 5Mb of managed heap

space

slide-33
SLIDE 33

Experience

◮ Racket power, library support a big win ◮ Syntax transformation source location and performance

hindered us

◮ S-expression based language a tough sell to industry

programmers, as well as designers, and non-technical types

◮ ...especially when paired up with Emacs as the editing

platform.

◮ Although once learnt many programmers and designers

were expand and extend the language effectively

◮ Functional nature of the system is a big win, allowing data

to be flexibly transformed to just the right runtime representation

slide-34
SLIDE 34

Experience

◮ Racket power, library support a big win ◮ Syntax transformation source location and performance

hindered us

◮ S-expression based language a tough sell to industry

programmers, as well as designers, and non-technical types

◮ ...especially when paired up with Emacs as the editing

platform.

◮ Although once learnt many programmers and designers

were expand and extend the language effectively

◮ Functional nature of the system is a big win, allowing data

to be flexibly transformed to just the right runtime representation

slide-35
SLIDE 35

Experience

◮ Racket power, library support a big win ◮ Syntax transformation source location and performance

hindered us

◮ S-expression based language a tough sell to industry

programmers, as well as designers, and non-technical types

◮ ...especially when paired up with Emacs as the editing

platform.

◮ Although once learnt many programmers and designers

were expand and extend the language effectively

◮ Functional nature of the system is a big win, allowing data

to be flexibly transformed to just the right runtime representation

slide-36
SLIDE 36

Experience

◮ Racket power, library support a big win ◮ Syntax transformation source location and performance

hindered us

◮ S-expression based language a tough sell to industry

programmers, as well as designers, and non-technical types

◮ ...especially when paired up with Emacs as the editing

platform.

◮ Although once learnt many programmers and designers

were expand and extend the language effectively

◮ Functional nature of the system is a big win, allowing data

to be flexibly transformed to just the right runtime representation

slide-37
SLIDE 37

Experience

◮ Racket power, library support a big win ◮ Syntax transformation source location and performance

hindered us

◮ S-expression based language a tough sell to industry

programmers, as well as designers, and non-technical types

◮ ...especially when paired up with Emacs as the editing

platform.

◮ Although once learnt many programmers and designers

were expand and extend the language effectively

◮ Functional nature of the system is a big win, allowing data

to be flexibly transformed to just the right runtime representation

slide-38
SLIDE 38

Experience

◮ Racket power, library support a big win ◮ Syntax transformation source location and performance

hindered us

◮ S-expression based language a tough sell to industry

programmers, as well as designers, and non-technical types

◮ ...especially when paired up with Emacs as the editing

platform.

◮ Although once learnt many programmers and designers

were expand and extend the language effectively

◮ Functional nature of the system is a big win, allowing data

to be flexibly transformed to just the right runtime representation

slide-39
SLIDE 39

Questions?