S c al a Qu e st: T h e S ca l a A dv e nt u re 1 A le jand r o L - - PowerPoint PPT Presentation

s c al a qu e st t h e s ca l a a dv e nt u re
SMART_READER_LITE
LIVE PREVIEW

S c al a Qu e st: T h e S ca l a A dv e nt u re 1 A le jand r o L - - PowerPoint PPT Presentation

S c al a Qu e st: T h e S ca l a A dv e nt u re 1 A le jand r o L ujan 1 W h o? D a vi d , C h ri s ti a n, E d ua r do, M a ur i ci o 2 W h y d o y ou c a re? 4 Y ou wa n t to l evel up yo u r S cala 4 Y ou wa n t to gr o w yo u r t eam 4 Y ou


slide-1
SLIDE 1

ScalaQuest: The Scala Adventure

1

Ale jandro Lujan

1

slide-2
SLIDE 2

Who?

David, Christian, Eduardo, Mauricio

2

slide-3
SLIDE 3

Why do you care?

4 You want to level up your Scala 4 You want to grow your team 4 You want to encourage others 4 You want to have fun

3

slide-4
SLIDE 4

Why do I care?

4 I've been teaching Scala for 5+ years 4 I've been teaching since high school 4 I learned english by playing a game

4

slide-5
SLIDE 5

5

slide-6
SLIDE 6

Fun is a multiplying factor for learning

6

slide-7
SLIDE 7

Play is the highest form of research.

1

Albert Einstein on the Zelda series

7

slide-8
SLIDE 8

Serious Games leads

4 Jane McGonigal 4 Tom Baranowski 4 Learning Games Network 4 MIT Game Lab 4 International Journal of Serious Games

8

slide-9
SLIDE 9

The best moments usually occur when a person’s body or mind is stretched [...] in a voluntary efgort to accomplish something diffjcult and worthwhile.

1

Mihaly Csikszentmihalyi, Flow (1990)

9

slide-10
SLIDE 10

Learning Scala is diffjcult and worthwhile... but can we make it fun?

10

slide-11
SLIDE 11

Let me tell you a story...

11

slide-12
SLIDE 12

Juan Ex

4 DataLand 4 Farmers harvest manually

12

slide-13
SLIDE 13

Computers

4 A while back, computers appeared

13

slide-14
SLIDE 14

Computers

4 A while back, computers appeared 4 Powerful forces arose 4 4-train

14

slide-15
SLIDE 15

Computers

4 A while back, computers appeared 4 Powerful forces arose 4 4-train, Sea-cross-cross

15

slide-16
SLIDE 16

Computers

4 A while back, computers appeared 4 Powerful forces arose 4 4-train, C-cross-cross, Hava 4 Data harvesting more effjcient

16

slide-17
SLIDE 17

Computers

4 A while back, computers appeared 4 Powerful forces arose 4 4-train, C-cross-cross, Hava 4 Data harvesting more effjcient 4 For a time, it was good

17

slide-18
SLIDE 18

Computers

4 A while back, computers appeared 4 Powerful forces arose 4 4-train, C-cross-cross, Hava 4 Data harvesting more effjcient 4 For a time, it was good 4 Then, the Complexity Plagues appeared

18

slide-19
SLIDE 19

Ski

4 Roamed DataLand for long 4 Tamed many forces 4 Discovered a powerful one 4 Named it Scala 4 Wanted this great power to be wielded wisely 4 Gathering order of apprentices 4 Order of the Ski 4 Order[Ski] for short

19

slide-20
SLIDE 20

Tempting the Demo gods...

20

slide-21
SLIDE 21

Where we are now

4 Successful Kickstarter 4 Three levels ready 4 Level 4 on the way 4 Launching in a few weeks

21

slide-22
SLIDE 22

The internals

4 Phaser.js frontend 4 Play and Scala backend 4 Micro-challenges evaluated on the client side 4 Final challenges compiled and tested on the backend

22

slide-23
SLIDE 23

Some interesting achievements

  • 1. Level defjnitions
  • 2. Keeping user state
  • 3. Compiling user code

23

slide-24
SLIDE 24
  • 1. Level defjnitions

24

slide-25
SLIDE 25
  • 1. Level defjnitions

4 Map size and tiles 4 Items: location, sprites 4 Animations 4 Sounds

25

slide-26
SLIDE 26

I WONDER IF THERE'S A BETTER WAY TO DECLARE THESE...

LIKE A... TYPE SAFE WAY...

26

slide-27
SLIDE 27

27

slide-28
SLIDE 28
  • 1. Level defjnitions - Pushing to

backend

Image("goblinAvatar", "goblin_avatar.png", 124, 124) Sound("ambient_02", "ambient_02.ogg") Animation("left", (11 to 21).reverse, 8) smallGoblin = NPC("small-goblin", power = 5) smallGoblin.withRandomHP(min, max) val sprites = Sprites(player, npcs, items, prizes, exit, statics)

28

slide-29
SLIDE 29
  • 1. Level defjnitions - the good

4 Serialized to JSON 4 Frontend had minimal changes 4 Unit tested 4 Reduced duplication drastically 4 Caught dozens of bugs 4 Refactoring is painless

29

slide-30
SLIDE 30
  • 1. Level defjnitions - the bad:

4 (there is no bad)

30

slide-31
SLIDE 31
  • 2. Keeping user state

4 Event Sourcing 4 Akka persistence 4 One persistent actor per user 4 DynamoDB 4 Careful about model evolution

31

slide-32
SLIDE 32

Event Sourcing

// This function is applied to all incoming commands while the actor is running val receiveCommand: Receive = { case command: String => EventParser.parse(command) match { case event: GameEvent => persist(event)(updateState) case invalidCommand => log.debug(s"Command was not a valid event: $command") } }

32

slide-33
SLIDE 33

def updateState(event: GameEvent): Unit = { log.debug(s"Updating state with event '$event'") event match { case LevelFinished(ts, levelId) => levelState = LevelState.startLevel(levelId + 1) case MainChallengeSuccess(ts, levelId) => levelState = levelState.copy(mainChallengeCompleted = true) // An item that is collected goes to the inventory by default case ItemCollected(ts, levelId, itemKey) => levelState = levelState.copy( collectedItems = levelState.collectedItems + itemKey, inventory = levelState.inventory + itemKey ) ... } }

33

slide-34
SLIDE 34
  • 3. Compiling user code

34

slide-35
SLIDE 35

We needed

4 Inexpensive 4 Scalable 4 Secure 4 Easy-ish to use

35

slide-36
SLIDE 36

36

slide-37
SLIDE 37

37

slide-38
SLIDE 38

Amazon Lambda

4 Can run any JVM app 4 Including one that packs a compiler 4 Very restricted 4 Priced for elasticity

38

slide-39
SLIDE 39

Challenges

4 Packaging the app 4 Tuning resources 4 Warmup time

39

slide-40
SLIDE 40

Running on Lambda - a sample

Scala app + instructions on how to publish to Amazon Lambda: https://github.com/mvinesn/aws-lambda-example- scala

40

slide-41
SLIDE 41

What now?

ScalaQuest.com @ScalaQuest

41