SlideShare a Scribd company logo
1 of 67
The Next Mainstream Programming Language: A Game Developer’s Perspective Tim Sweeney Epic Games
Outline ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Game Development
Game Development: Gears of War ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Software Dependencies ,[object Object],Gears of War Gameplay Code ~250,000 lines C++, script code Unreal Engine 3  Middleware Game Engine ~250,000 lines C++ code DirectX Graphics OpenAL Audio Ogg Vorbis Music Codec Speex Speech Codec wx Widgets Window Library ZLib Data Compr- ession
Game Development: Platforms ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What’s in a game? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Three Kinds of Code ,[object Object],[object Object],[object Object]
Gameplay Simulation
Gameplay Simulation ,[object Object],[object Object],[object Object],[object Object],[object Object]
Gameplay Simulation – The Numbers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Numeric Computation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Shading
Shading ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Shading in HLSL
Shading – The Numbers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Three Kinds of Code FPU Usage Lines of Code CPU Budget Languages 500 GFLOPS 5 GFLOPS 0.5 GFLOPS 10,000 250,000 250,000 n/a 90% 10% CG, HLSL C++ C++, Scripting Shading Numeric Computation Game Simulation
What are the hard problems? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Performance
Performance ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Modularity
Unreal’s game framework package UnrealEngine; class Actor { int Health; void TakeDamage(int Amount)‏ { Health = Health – Amount; if (Health<0)‏ Die(); } } class Player extends Actor { string PlayerName; socket NetworkConnection; } Gameplay module Base class of gameplay objects Members
Game class hierarchy Actor Player Enemy InventoryItem Weapon Actor Player Enemy Dragon Troll InventoryItem Weapon Sword Crossbow Generic Game Framework Game-Specific Framework Extension
Software Frameworks ,[object Object],[object Object],[object Object],[object Object]
Software Frameworks ,[object Object],[object Object],[object Object],[object Object],[object Object]
What we would like to write… ,[object Object],package Engine; class Actor { int Health; … } class Player extends Actor { … } class Inventory extends Actor { … } Base Framework Package GearsOfWar extends Engine; class Actor extends Engine.Actor { // Here we can add new members // to the base class. …  } class Player extends Engine.Player { // Thus virtually inherits from // GearsOfWar.Actor … } class Gun extends GearsOfWar.Inventory { … } Extended Framework
Reliability Or: If the compiler doesn’t beep, my program should work
Dynamic Failure in Mainstream Languages Vertex[] Transform (Vertex[] Vertices, int[] Indices, Matrix m) { Vertex[] Result = new Vertex[Indices.length]; for(int i=0; i<Indices.length; i++)‏ Result[i] = Transform(m,Vertices[Indices[i]]); return Result; }; Example (C#): Given a vertex array and an index array, we read and transform the indexed vertices into a new array. What can possibly go wrong?
Dynamic Failure in Mainstream Languages Vertex[] Transform (Vertex[] Vertices, int[] Indices, Matrix m) { Vertex[] Result = new Vertex[Indices.length]; for(int i=0; i<Indices.length; i++)‏ Result[i] = Transform(m,Vertices[Indices[i]]); return Result; }; May be NULL May be NULL May contain indices outside of the range of the Vertex array May be NULL Array access might be out of bounds Will the compiler realize this can’t fail? Could dereference a null pointer Our code is littered with runtime failure cases, Yet the compiler remains silent!
Dynamic Failure in Mainstream Languages ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What we would like to write… Transform{n:nat}(Vertices:[n]Vertex, Indices:[]nat<n, m:Matrix):[]Vertex=   for each(i in Indices)   Transform(m,Vertices[i])‏ Universally quantify over all natural numbers An array of exactly known size An index buffer containing natural numbers less than n Haskell-style array comprehension The only possible failure mode: divergence, if the call to Transform diverges.
How might this work? ,[object Object],[object Object],[object Object],int nat nat<n Sum{n:nat}(xs:[n]int)=.. a=Sum([7,8,9])‏ Sum(n:nat,xs:[n]int)=.. a=Sum(3,[7,8,9])‏ The Integers The Natural Numbers The Natural Numbers less than n, where n may be a variable! Explicit type/value dependency between function parameters
How might this work? ,[object Object],[object Object],xp:^int xo:?int xpo:?^int A pointer to an integer An optional integer An optional pointer to an integer! Successors(xs:[]int):[]int= foreach(x in xs) x+1
How might this work? A guarded casting mechanism for cases where need a safe “escape”: All potential failure must be explicitly handled, but we lose no expressiveness. GetElement(as:[]string, i:int):string=   if(n:nat<as.length=i) as[n]   else “ Index Out of Bounds” Here, we cast  i  to type of natural numbers bounded by the length of  as , and bind the result to  n We can only access  i within this context If the cast fails, we execute the else-branch
Analysis of the Unreal code ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Accessing uninitialized variables ,[object Object],[object Object],[object Object],[object Object],[object Object],class MyClass { const int a=c+1; const int b=7; const int c=b+1; } MyClass myvalue = new C; // What is myvalue.a?
Dynamic Failure: Conclusion ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Integer overflow The Natural Numbers  Factoid: C# exposes more than 10 integer-like data types, none of which are those defined by (Pythagoras, 500BC). In the future, can we get integers right? data Nat = Zero | Succ Nat
Can we get integers right? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],This could be a viable tradeoff
Concurrency
The C++/Java/C# Model: “Shared State Concurrency” ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The C++/Java/C# Model: “Shared State Concurrency” ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],There must be a better way!
Three Kinds of Code: Revisited ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Concurrency in Shading ,[object Object],[object Object],[object Object],[object Object]
Concurrency in Shading ,[object Object],[object Object]
Concurrency in Numeric Computation ,[object Object],[object Object],[object Object],[object Object],In the future, we will write these algorithms using referentially-transparent constructs.
Numeric Computation Example: Collision Detection ,[object Object],struct vec3 { float x,y,z; }; struct hit { bool  DidCollide; float Time; vec3  Location; }; hit collide(vec3 start,vec3 end); Vec3  = data Vec3 float float float Hit  = data Hit float Vec3 collide :: (vec3,vec3)->Maybe Hit
Numeric Computation Example: Collision Detection ,[object Object],[object Object],[object Object],[object Object],[object Object],collide(start:Vec3,end:Vec3):?Hit print(s:string)[#imperative]:void A pure function (the default)‏ Effectful functions require explicit annotations In a concurrent world, imperative is the wrong default!
Concurrency in Gameplay Simulation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Concurrency in Gameplay Simulation: Software Transactional Memory ,[object Object],[object Object],[object Object],[object Object],[object Object],Claim: Transactions are the only plausible solution to concurrent mutable state
Three Kinds of Code: Revisited 500 GFLOPS 5 GFLOPS 0.5 GFLOPS FPU Usage Implicit Data Parallelism Implicit Thread Parallelism Software Transactional Memory Parallelism Lines of Code CPU Budget Languages 10,000 250,000 250,000 n/a 90% 10% CG, HLSL C++ C++, Scripting Shading Numeric Computation Game Simulation
Parallelism and purity Software Transactional Memory Purely functional core Physics, collision detection, scene traversal, path finding, .. Data Parallel Subset Graphics shader programs Game World State
Musings On the Next Maintream Programming Language
Musings ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Dependent types and concurrency must evolve simultaneously
Language Implications ,[object Object],[object Object],[object Object],[object Object]
Language Implications ,[object Object],[object Object],[object Object],[object Object],Why not go one step further and define partiality as an effect, thus creating a foundational language subset suitable for proofs?
Performance – Language Implications ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Syntax ,[object Object],[object Object],[object Object],int f{nat n}(int[] as,natrange<n> i) { return as[i]; } f{n:nat}(as:[]int,i:nat<n)=as[i] f :: forall n::nat. ([int],nat<n) -> int f (xs,i) = xs !! i C Family: Least scary, but it’s a messy legacy Haskell family: Quite scary   :-)‏ Pascal/ML family: Seems promising
Conclusion
A Brief History of Game Technology 1972 Pong (hardware)‏ 1980 Zork (high level interpretted language)‏ 1993 DOOM (C)‏ 1998 Unreal (C++, Java-style scripting)‏ 2005-6 Xbox 360, PlayStation 3 with 6-8 hardware threads 2009 Next console generation. Unification of the CPU, GPU. Massive multi-core, data parallelism, etc.
The Coming Crisis in Computing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Questions?
Backup Slides
The Genius of Haskell ,[object Object],[object Object],[object Object],[object Object],[object Object]
The Genius of Haskell ,[object Object],sort []  = [] sort (x:xs) = sort [y | y<-xs, y<x ] ++ [x  ] ++   sort [y | y<-xs, y>=x] int partition(int y[], int f, int l); void quicksort(int x[], int first, int last) { int pivIndex = 0; if(first < last) { pivIndex = partition(x,first, last); quicksort(x,first,(pivIndex-1)); quicksort(x,(pivIndex+1),last); } } int partition(int y[], int f, int l) { int up,down,temp; int cc; int piv = y[f]; up = f; down = l; do {  while (y[up] <= piv && up < l) { up++; } while (y[down] > piv  ) { down--; } if (up < down ) { temp = y[up]; y[up] = y[down]; y[down] = temp; } } while (down > up); temp = piv; y[f] = y[down]; y[down] = piv; return down; } Sorting in Haskell Sorting in C
Why Haskell is Not My Favorite Programming Language ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Why Haskell is Not My Favorite Programming Language ,[object Object],[object Object],[object Object],[object Object],f(x,y) = x+y a=f(3,”4”)   f(int x,int y) = x+y a=f(3,”4”)‏ ERROR - Cannot infer instance *** Instance  : Num [Char] *** Expression : f (3,&quot;4&quot;)‏ Parameter mismatch paremter 2 of call to f:   Expected: int Got:  “4” … … ???

More Related Content

What's hot

Devnology Workshop Genpro 2 feb 2011
Devnology Workshop Genpro 2 feb 2011Devnology Workshop Genpro 2 feb 2011
Devnology Workshop Genpro 2 feb 2011
Devnology
 

What's hot (19)

Java Tutorial: Part 1. Getting Started
Java Tutorial: Part 1. Getting StartedJava Tutorial: Part 1. Getting Started
Java Tutorial: Part 1. Getting Started
 
Software Abstractions for Parallel Hardware
Software Abstractions for Parallel HardwareSoftware Abstractions for Parallel Hardware
Software Abstractions for Parallel Hardware
 
The Goal and The Journey - Turning back on one year of C++14 Migration
The Goal and The Journey - Turning back on one year of C++14 MigrationThe Goal and The Journey - Turning back on one year of C++14 Migration
The Goal and The Journey - Turning back on one year of C++14 Migration
 
Symbolic Execution And KLEE
Symbolic Execution And KLEESymbolic Execution And KLEE
Symbolic Execution And KLEE
 
SPF Getting Started - Console Program
SPF Getting Started - Console ProgramSPF Getting Started - Console Program
SPF Getting Started - Console Program
 
Symbolic Reasoning and Concrete Execution - Andrii Vozniuk
Symbolic Reasoning and Concrete Execution - Andrii Vozniuk Symbolic Reasoning and Concrete Execution - Andrii Vozniuk
Symbolic Reasoning and Concrete Execution - Andrii Vozniuk
 
Java Foundations: Basic Syntax, Conditions, Loops
Java Foundations: Basic Syntax, Conditions, LoopsJava Foundations: Basic Syntax, Conditions, Loops
Java Foundations: Basic Syntax, Conditions, Loops
 
20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstraction
 
D3, TypeScript, and Deep Learning
D3, TypeScript, and Deep LearningD3, TypeScript, and Deep Learning
D3, TypeScript, and Deep Learning
 
Cs8792 cns - Public key cryptosystem (Unit III)
Cs8792   cns - Public key cryptosystem (Unit III)Cs8792   cns - Public key cryptosystem (Unit III)
Cs8792 cns - Public key cryptosystem (Unit III)
 
Icom4015 lecture12-s16
Icom4015 lecture12-s16Icom4015 lecture12-s16
Icom4015 lecture12-s16
 
Introduction to Machine Learning with TensorFlow
Introduction to Machine Learning with TensorFlowIntroduction to Machine Learning with TensorFlow
Introduction to Machine Learning with TensorFlow
 
Icom4015 lecture4-f16
Icom4015 lecture4-f16Icom4015 lecture4-f16
Icom4015 lecture4-f16
 
Designing Architecture-aware Library using Boost.Proto
Designing Architecture-aware Library using Boost.ProtoDesigning Architecture-aware Library using Boost.Proto
Designing Architecture-aware Library using Boost.Proto
 
Java programming lab assignments
Java programming lab assignments Java programming lab assignments
Java programming lab assignments
 
Icom4015 lecture4-f17
Icom4015 lecture4-f17Icom4015 lecture4-f17
Icom4015 lecture4-f17
 
Java Foundations: Strings and Text Processing
Java Foundations: Strings and Text ProcessingJava Foundations: Strings and Text Processing
Java Foundations: Strings and Text Processing
 
Devnology Workshop Genpro 2 feb 2011
Devnology Workshop Genpro 2 feb 2011Devnology Workshop Genpro 2 feb 2011
Devnology Workshop Genpro 2 feb 2011
 
Icom4015 lecture15-f16
Icom4015 lecture15-f16Icom4015 lecture15-f16
Icom4015 lecture15-f16
 

Viewers also liked (8)

Credit2
Credit2Credit2
Credit2
 
Tutoriel Voice Recorder
Tutoriel Voice RecorderTutoriel Voice Recorder
Tutoriel Voice Recorder
 
Ejaki
EjakiEjaki
Ejaki
 
Alista
AlistaAlista
Alista
 
Ergonomics By Blr
Ergonomics By BlrErgonomics By Blr
Ergonomics By Blr
 
Edublog
EdublogEdublog
Edublog
 
Jessy & Vinny
Jessy & VinnyJessy & Vinny
Jessy & Vinny
 
Web2
Web2Web2
Web2
 

Similar to Tim Popl

A well-typed program never goes wrong
A well-typed program never goes wrongA well-typed program never goes wrong
A well-typed program never goes wrong
Julien Wetterwald
 
Unmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/InvokeUnmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/Invoke
Dmitri Nesteruk
 

Similar to Tim Popl (20)

Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
 
Introduction to Deep Learning and Tensorflow
Introduction to Deep Learning and TensorflowIntroduction to Deep Learning and Tensorflow
Introduction to Deep Learning and Tensorflow
 
C#
C#C#
C#
 
The Ring programming language version 1.9 book - Part 58 of 210
The Ring programming language version 1.9 book - Part 58 of 210The Ring programming language version 1.9 book - Part 58 of 210
The Ring programming language version 1.9 book - Part 58 of 210
 
MXNet Workshop
MXNet WorkshopMXNet Workshop
MXNet Workshop
 
Standardizing on a single N-dimensional array API for Python
Standardizing on a single N-dimensional array API for PythonStandardizing on a single N-dimensional array API for Python
Standardizing on a single N-dimensional array API for Python
 
Haskell for data science
Haskell for data scienceHaskell for data science
Haskell for data science
 
A well-typed program never goes wrong
A well-typed program never goes wrongA well-typed program never goes wrong
A well-typed program never goes wrong
 
unit 1 (1).pptx
unit 1 (1).pptxunit 1 (1).pptx
unit 1 (1).pptx
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
 
Python ppt
Python pptPython ppt
Python ppt
 
Modern C++
Modern C++Modern C++
Modern C++
 
D3, TypeScript, and Deep Learning
D3, TypeScript, and Deep LearningD3, TypeScript, and Deep Learning
D3, TypeScript, and Deep Learning
 
C language
C languageC language
C language
 
PythonStudyMaterialSTudyMaterial.pdf
PythonStudyMaterialSTudyMaterial.pdfPythonStudyMaterialSTudyMaterial.pdf
PythonStudyMaterialSTudyMaterial.pdf
 
Unmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/InvokeUnmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/Invoke
 
IntroductionToCSharp.ppt
IntroductionToCSharp.pptIntroductionToCSharp.ppt
IntroductionToCSharp.ppt
 
Introduction toc sharp
Introduction toc sharpIntroduction toc sharp
Introduction toc sharp
 
IntroductionToCSharp.ppt
IntroductionToCSharp.pptIntroductionToCSharp.ppt
IntroductionToCSharp.ppt
 
IntroductionToCSharp.ppt
IntroductionToCSharp.pptIntroductionToCSharp.ppt
IntroductionToCSharp.ppt
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

Tim Popl

  • 1. The Next Mainstream Programming Language: A Game Developer’s Perspective Tim Sweeney Epic Games
  • 2.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 10.
  • 11.
  • 12.
  • 14.
  • 16.
  • 17. Three Kinds of Code FPU Usage Lines of Code CPU Budget Languages 500 GFLOPS 5 GFLOPS 0.5 GFLOPS 10,000 250,000 250,000 n/a 90% 10% CG, HLSL C++ C++, Scripting Shading Numeric Computation Game Simulation
  • 18.
  • 20.
  • 22. Unreal’s game framework package UnrealEngine; class Actor { int Health; void TakeDamage(int Amount)‏ { Health = Health – Amount; if (Health<0)‏ Die(); } } class Player extends Actor { string PlayerName; socket NetworkConnection; } Gameplay module Base class of gameplay objects Members
  • 23. Game class hierarchy Actor Player Enemy InventoryItem Weapon Actor Player Enemy Dragon Troll InventoryItem Weapon Sword Crossbow Generic Game Framework Game-Specific Framework Extension
  • 24.
  • 25.
  • 26.
  • 27. Reliability Or: If the compiler doesn’t beep, my program should work
  • 28. Dynamic Failure in Mainstream Languages Vertex[] Transform (Vertex[] Vertices, int[] Indices, Matrix m) { Vertex[] Result = new Vertex[Indices.length]; for(int i=0; i<Indices.length; i++)‏ Result[i] = Transform(m,Vertices[Indices[i]]); return Result; }; Example (C#): Given a vertex array and an index array, we read and transform the indexed vertices into a new array. What can possibly go wrong?
  • 29. Dynamic Failure in Mainstream Languages Vertex[] Transform (Vertex[] Vertices, int[] Indices, Matrix m) { Vertex[] Result = new Vertex[Indices.length]; for(int i=0; i<Indices.length; i++)‏ Result[i] = Transform(m,Vertices[Indices[i]]); return Result; }; May be NULL May be NULL May contain indices outside of the range of the Vertex array May be NULL Array access might be out of bounds Will the compiler realize this can’t fail? Could dereference a null pointer Our code is littered with runtime failure cases, Yet the compiler remains silent!
  • 30.
  • 31. What we would like to write… Transform{n:nat}(Vertices:[n]Vertex, Indices:[]nat<n, m:Matrix):[]Vertex= for each(i in Indices) Transform(m,Vertices[i])‏ Universally quantify over all natural numbers An array of exactly known size An index buffer containing natural numbers less than n Haskell-style array comprehension The only possible failure mode: divergence, if the call to Transform diverges.
  • 32.
  • 33.
  • 34. How might this work? A guarded casting mechanism for cases where need a safe “escape”: All potential failure must be explicitly handled, but we lose no expressiveness. GetElement(as:[]string, i:int):string= if(n:nat<as.length=i) as[n] else “ Index Out of Bounds” Here, we cast i to type of natural numbers bounded by the length of as , and bind the result to n We can only access i within this context If the cast fails, we execute the else-branch
  • 35.
  • 36.
  • 37.
  • 38. Integer overflow The Natural Numbers Factoid: C# exposes more than 10 integer-like data types, none of which are those defined by (Pythagoras, 500BC). In the future, can we get integers right? data Nat = Zero | Succ Nat
  • 39.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51. Three Kinds of Code: Revisited 500 GFLOPS 5 GFLOPS 0.5 GFLOPS FPU Usage Implicit Data Parallelism Implicit Thread Parallelism Software Transactional Memory Parallelism Lines of Code CPU Budget Languages 10,000 250,000 250,000 n/a 90% 10% CG, HLSL C++ C++, Scripting Shading Numeric Computation Game Simulation
  • 52. Parallelism and purity Software Transactional Memory Purely functional core Physics, collision detection, scene traversal, path finding, .. Data Parallel Subset Graphics shader programs Game World State
  • 53. Musings On the Next Maintream Programming Language
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 60. A Brief History of Game Technology 1972 Pong (hardware)‏ 1980 Zork (high level interpretted language)‏ 1993 DOOM (C)‏ 1998 Unreal (C++, Java-style scripting)‏ 2005-6 Xbox 360, PlayStation 3 with 6-8 hardware threads 2009 Next console generation. Unification of the CPU, GPU. Massive multi-core, data parallelism, etc.
  • 61.
  • 64.
  • 65.
  • 66.
  • 67.