danl slides
TRANSCRIPT
-
8/12/2019 Danl Slides
1/39
Racket on the Playstation 3? Its not what you
think...
Dan Liebgold
Naughty Dog, Inc.Santa Monica, CA
RacketCon 2013
http://find/http://goback/ -
8/12/2019 Danl Slides
2/39
http://find/http://goback/ -
8/12/2019 Danl Slides
3/39
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!
http://find/http://goback/ -
8/12/2019 Danl Slides
4/39
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!
http://find/http://goback/ -
8/12/2019 Danl Slides
5/39
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!
http://find/ -
8/12/2019 Danl Slides
6/39
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!
http://find/ -
8/12/2019 Danl Slides
7/39
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!
http://find/ -
8/12/2019 Danl Slides
8/39
Scheme
We had experience using Common Lisp before to create
our own implementation language (GOAL) Lisp supports creating data like code
We built DCin Racket Used Racket (MzScheme initially) because its a good Lisp,
is open source, and has quality libraries and
implementation
http://find/ -
8/12/2019 Danl Slides
9/39
Scheme
We had experience using Common Lisp before to create
our own implementation language (GOAL) Lisp supports creating data like code
We built DCin Racket Used Racket (MzScheme initially) because its a good Lisp,
is open source, and has quality libraries and
implementation
http://find/ -
8/12/2019 Danl Slides
10/39
Scheme
We had experience using Common Lisp before to create
our own implementation language (GOAL) Lisp supports creating data like code
We built DCin Racket Used Racket (MzScheme initially) because its a good Lisp,
is open source, and has quality libraries and
implementation
http://find/ -
8/12/2019 Danl Slides
11/39
Scheme
We had experience using Common Lisp before to create
our own implementation language (GOAL) Lisp supports creating data like code
We built DCin Racket Used Racket (MzScheme initially) because its a good Lisp,
is open source, and has quality libraries and
implementation
http://goforward/http://find/http://goback/ -
8/12/2019 Danl Slides
12/39
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 andconfusing.
http://find/ -
8/12/2019 Danl Slides
13/39
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 andconfusing.
http://find/ -
8/12/2019 Danl Slides
14/39
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 andconfusing.
http://find/ -
8/12/2019 Danl Slides
15/39
Architecture
E l
http://find/ -
8/12/2019 Danl Slides
16/39
Example
Lets define a player start position:
(define-export *player-start*(new locator
:trans *origin*:rot (axis-angle->quaternion *y-axis* 45)
))
S i h
http://find/ -
8/12/2019 Danl Slides
17/39
Start with some types
(deftype vec4 (:align 16)
((x float)
(y float)
(z float)
(w float :default 0)
))
St t ith t
http://find/ -
8/12/2019 Danl Slides
18/39
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;
};
T ti d
http://find/http://goback/ -
8/12/2019 Danl Slides
19/39
Types continued
(deftype quaternion (:parent vec4)
())
(deftype point (:parent vec4)
((w float :default 1)))
(deftype locator ()
((trans point :inline #t)
(rot quaternion :inline #t)
))
T pes contin ed
http://find/ -
8/12/2019 Danl Slides
20/39
Types continued
(deftype quaternion (:parent vec4)
())
(deftype point (:parent vec4)
((w float :default 1)))
(deftype locator ()
((trans point :inline #t)
(rot quaternion :inline #t)
))
Types continued
http://find/ -
8/12/2019 Danl Slides
21/39
Types continued
(deftype quaternion (:parent vec4)())
(deftype point (:parent vec4)
((w float :default 1)
))
struct Locator
{
Point m_trans;
Quaternion m_rot;};
Define a function
http://find/ -
8/12/2019 Danl Slides
22/39
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))
)))
Define some instances
http://find/ -
8/12/2019 Danl Slides
23/39
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)
))
Define some instances
http://find/ -
8/12/2019 Danl Slides
24/39
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)
))
How we use these definitions in C++ code
http://find/ -
8/12/2019 Danl Slides
25/39
How we use these definitions in C++ code
...
#include "dc-types.h"
...
const Locator * pLoc =DcLookupSymbol("*player-start*");
Point pos = pLoc->m_trans;
...
http://find/http://goback/ -
8/12/2019 Danl Slides
26/39
The Last of Us on the Playstation 3
http://find/ -
8/12/2019 Danl Slides
27/39
The Last of Uson 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
The Last of Us on the Playstation 3
http://find/ -
8/12/2019 Danl Slides
28/39
The Last of Uson 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
The Last of Us on the Playstation 3
http://find/ -
8/12/2019 Danl Slides
29/39
The Last of Uson 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
The Last of Us on the Playstation 3
http://find/ -
8/12/2019 Danl Slides
30/39
The Last of Uson 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
The Last of Us on the Playstation 3
http://goforward/http://find/http://goback/ -
8/12/2019 Danl Slides
31/39
The Last of Uson 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
The Last of Uson the Playstation 3
http://goforward/http://find/http://goback/ -
8/12/2019 Danl Slides
32/39
y
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
Experience
http://find/ -
8/12/2019 Danl Slides
33/39
p
Racket power, library support a big win
Syntax transformation source location and performance
hindered us
S-expression based language a tough sell to industryprogrammers, 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 datato be flexibly transformed to just the right runtime
representation
Experience
http://find/ -
8/12/2019 Danl Slides
34/39
p
Racket power, library support a big win
Syntax transformation source location and performance
hindered us
S-expression based language a tough sell to industryprogrammers, 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 datato be flexibly transformed to just the right runtime
representation
Experience
http://find/ -
8/12/2019 Danl Slides
35/39
p
Racket power, library support a big win
Syntax transformation source location and performance
hindered us
S-expression based language a tough sell to industryprogrammers, 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 datato be flexibly transformed to just the right runtime
representation
Experience
http://find/ -
8/12/2019 Danl Slides
36/39
Racket power, library support a big win
Syntax transformation source location and performance
hindered us
S-expression based language a tough sell to industryprogrammers, 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 datato be flexibly transformed to just the right runtime
representation
Experience
http://find/http://goback/ -
8/12/2019 Danl Slides
37/39
Racket power, library support a big win
Syntax transformation source location and performance
hindered us
S-expression based language a tough sell to industryprogrammers, 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 datato be flexibly transformed to just the right runtime
representation
Experience
http://find/ -
8/12/2019 Danl Slides
38/39
Racket power, library support a big win
Syntax transformation source location and performance
hindered us
S-expression based language a tough sell to industryprogrammers, 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 datato be flexibly transformed to just the right runtime
representation
Questions?
http://find/ -
8/12/2019 Danl Slides
39/39
http://find/