• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Scala at Mind Candy
 

Scala at Mind Candy

on

  • 1,049 views

Shown at Scala Days 2012

Shown at Scala Days 2012

Statistics

Views

Total Views
1,049
Views on SlideShare
1,049
Embed Views
0

Actions

Likes
2
Downloads
20
Comments
1

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Who we areWhat is scalaWhy we chose itHow we use itWhy you should use it\n\naim for 25 mins tops\n
  • http://mindcandy.com/\n\nLet’s see a show of hands... and who has actually played?Mindcandy - we make Moshi Monsters, have millions of users and digital entertainment is heart of our company\n\nSean - "Back end" developer\nMark - "Tools" developer\n \n
  • http://mindcandy.com/\n\nLet’s see a show of hands... and who has actually played?Mindcandy - we make Moshi Monsters, have millions of users and digital entertainment is heart of our company\n\nSean - "Back end" developer\nMark - "Tools" developer\n \n
  • (not needed for Scala Days)\n\nIMPORTANT HIGHLIGHTS ONLY\n\nWhat are the most relevant bits to us - 5 mins total\n\nStandard blurb is\nScala is a general purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional languages, enabling Java and other programmers to be more productive. Code sizes are typically reduced by a factor of two to three when compared to an equivalent Java application.\n\nso what does that mean?\n\nit's functional AND object oriented\n\nit's type safe and uses static typing with compile-time type checks\n\nit compiles to Java Bytecode, runs on the Java Virtual Machine and can call any Java library / be called by java libraries very easily\n\nit can infer types at compile time so you don't have to write them again and again (and again)\n\nit has a REPL console\n\nfocus on productivity / not repeating boilerplate\n\n\nhttp://www.scala-lang.org/node/104 is good reference\nLanguage features of scala\nTraits and Type parameters\nthough you don't need to use (generics) often, they are convenient for library writers\n\nNO MACROS OR TEMPLATES!\n
  • \n
  • News feed for the best friends of users.\n\nWhen a best friend does something of note, it should appear in here.\n\nPolled from the client.\n
  • News feed for the best friends of users.\n\nWhen a best friend does something of note, it should appear in here.\n\nPolled from the client.\n
  • Write phase.\n\n- User 1 performs some action that has a news item associated with it.\n- News item pushed through HTTP to the news service, service returns immediately once the request has been parsed.\n- News service looks up users that have marked user 1 as a best friend from Cassandra.\n- If necessary populates Cassandra from the game database.\n- Performs a fanout of the news item to individual feeds for each user.\n
  • Write phase.\n\n- User 1 performs some action that has a news item associated with it.\n- News item pushed through HTTP to the news service, service returns immediately once the request has been parsed.\n- News service looks up users that have marked user 1 as a best friend from Cassandra.\n- If necessary populates Cassandra from the game database.\n- Performs a fanout of the news item to individual feeds for each user.\n
  • Write phase.\n\n- User 1 performs some action that has a news item associated with it.\n- News item pushed through HTTP to the news service, service returns immediately once the request has been parsed.\n- News service looks up users that have marked user 1 as a best friend from Cassandra.\n- If necessary populates Cassandra from the game database.\n- Performs a fanout of the news item to individual feeds for each user.\n
  • Write phase.\n\n- User 1 performs some action that has a news item associated with it.\n- News item pushed through HTTP to the news service, service returns immediately once the request has been parsed.\n- News service looks up users that have marked user 1 as a best friend from Cassandra.\n- If necessary populates Cassandra from the game database.\n- Performs a fanout of the news item to individual feeds for each user.\n
  • Write phase.\n\n- User 1 performs some action that has a news item associated with it.\n- News item pushed through HTTP to the news service, service returns immediately once the request has been parsed.\n- News service looks up users that have marked user 1 as a best friend from Cassandra.\n- If necessary populates Cassandra from the game database.\n- Performs a fanout of the news item to individual feeds for each user.\n
  • Write phase.\n\n- User 1 performs some action that has a news item associated with it.\n- News item pushed through HTTP to the news service, service returns immediately once the request has been parsed.\n- News service looks up users that have marked user 1 as a best friend from Cassandra.\n- If necessary populates Cassandra from the game database.\n- Performs a fanout of the news item to individual feeds for each user.\n
  • Write phase.\n\n- User 1 performs some action that has a news item associated with it.\n- News item pushed through HTTP to the news service, service returns immediately once the request has been parsed.\n- News service looks up users that have marked user 1 as a best friend from Cassandra.\n- If necessary populates Cassandra from the game database.\n- Performs a fanout of the news item to individual feeds for each user.\n
  • Write phase.\n\n- User 1 performs some action that has a news item associated with it.\n- News item pushed through HTTP to the news service, service returns immediately once the request has been parsed.\n- News service looks up users that have marked user 1 as a best friend from Cassandra.\n- If necessary populates Cassandra from the game database.\n- Performs a fanout of the news item to individual feeds for each user.\n
  • Write phase.\n\n- User 1 performs some action that has a news item associated with it.\n- News item pushed through HTTP to the news service, service returns immediately once the request has been parsed.\n- News service looks up users that have marked user 1 as a best friend from Cassandra.\n- If necessary populates Cassandra from the game database.\n- Performs a fanout of the news item to individual feeds for each user.\n
  • Write phase.\n\n- User 1 performs some action that has a news item associated with it.\n- News item pushed through HTTP to the news service, service returns immediately once the request has been parsed.\n- News service looks up users that have marked user 1 as a best friend from Cassandra.\n- If necessary populates Cassandra from the game database.\n- Performs a fanout of the news item to individual feeds for each user.\n
  • Write phase.\n\n- User 1 performs some action that has a news item associated with it.\n- News item pushed through HTTP to the news service, service returns immediately once the request has been parsed.\n- News service looks up users that have marked user 1 as a best friend from Cassandra.\n- If necessary populates Cassandra from the game database.\n- Performs a fanout of the news item to individual feeds for each user.\n
  • Write phase.\n\n- User 1 performs some action that has a news item associated with it.\n- News item pushed through HTTP to the news service, service returns immediately once the request has been parsed.\n- News service looks up users that have marked user 1 as a best friend from Cassandra.\n- If necessary populates Cassandra from the game database.\n- Performs a fanout of the news item to individual feeds for each user.\n
  • Write phase.\n\n- User 1 performs some action that has a news item associated with it.\n- News item pushed through HTTP to the news service, service returns immediately once the request has been parsed.\n- News service looks up users that have marked user 1 as a best friend from Cassandra.\n- If necessary populates Cassandra from the game database.\n- Performs a fanout of the news item to individual feeds for each user.\n
  • Write phase.\n\n- User 1 performs some action that has a news item associated with it.\n- News item pushed through HTTP to the news service, service returns immediately once the request has been parsed.\n- News service looks up users that have marked user 1 as a best friend from Cassandra.\n- If necessary populates Cassandra from the game database.\n- Performs a fanout of the news item to individual feeds for each user.\n
  • Write phase.\n\n- User 1 performs some action that has a news item associated with it.\n- News item pushed through HTTP to the news service, service returns immediately once the request has been parsed.\n- News service looks up users that have marked user 1 as a best friend from Cassandra.\n- If necessary populates Cassandra from the game database.\n- Performs a fanout of the news item to individual feeds for each user.\n
  • Read phase.\n\n- Front-end polls news service.\n- News service performs a read against the feed for said user.\n- User information for the users mentioned in those news items are looked up from Cassandra.\n- Users who are not populated in the cache are eliminated from the response and a message is fired to populate that user cache asynchronously.\n\nDesigned to be overly cautious and easy on the infrastructure as it was the first project at Mind Candy to use Scala/Cassandra/Akka.\n
  • Read phase.\n\n- Front-end polls news service.\n- News service performs a read against the feed for said user.\n- User information for the users mentioned in those news items are looked up from Cassandra.\n- Users who are not populated in the cache are eliminated from the response and a message is fired to populate that user cache asynchronously.\n\nDesigned to be overly cautious and easy on the infrastructure as it was the first project at Mind Candy to use Scala/Cassandra/Akka.\n
  • Read phase.\n\n- Front-end polls news service.\n- News service performs a read against the feed for said user.\n- User information for the users mentioned in those news items are looked up from Cassandra.\n- Users who are not populated in the cache are eliminated from the response and a message is fired to populate that user cache asynchronously.\n\nDesigned to be overly cautious and easy on the infrastructure as it was the first project at Mind Candy to use Scala/Cassandra/Akka.\n
  • Read phase.\n\n- Front-end polls news service.\n- News service performs a read against the feed for said user.\n- User information for the users mentioned in those news items are looked up from Cassandra.\n- Users who are not populated in the cache are eliminated from the response and a message is fired to populate that user cache asynchronously.\n\nDesigned to be overly cautious and easy on the infrastructure as it was the first project at Mind Candy to use Scala/Cassandra/Akka.\n
  • Read phase.\n\n- Front-end polls news service.\n- News service performs a read against the feed for said user.\n- User information for the users mentioned in those news items are looked up from Cassandra.\n- Users who are not populated in the cache are eliminated from the response and a message is fired to populate that user cache asynchronously.\n\nDesigned to be overly cautious and easy on the infrastructure as it was the first project at Mind Candy to use Scala/Cassandra/Akka.\n
  • Read phase.\n\n- Front-end polls news service.\n- News service performs a read against the feed for said user.\n- User information for the users mentioned in those news items are looked up from Cassandra.\n- Users who are not populated in the cache are eliminated from the response and a message is fired to populate that user cache asynchronously.\n\nDesigned to be overly cautious and easy on the infrastructure as it was the first project at Mind Candy to use Scala/Cassandra/Akka.\n
  • Read phase.\n\n- Front-end polls news service.\n- News service performs a read against the feed for said user.\n- User information for the users mentioned in those news items are looked up from Cassandra.\n- Users who are not populated in the cache are eliminated from the response and a message is fired to populate that user cache asynchronously.\n\nDesigned to be overly cautious and easy on the infrastructure as it was the first project at Mind Candy to use Scala/Cassandra/Akka.\n
  • Read phase.\n\n- Front-end polls news service.\n- News service performs a read against the feed for said user.\n- User information for the users mentioned in those news items are looked up from Cassandra.\n- Users who are not populated in the cache are eliminated from the response and a message is fired to populate that user cache asynchronously.\n\nDesigned to be overly cautious and easy on the infrastructure as it was the first project at Mind Candy to use Scala/Cassandra/Akka.\n
  • Read phase.\n\n- Front-end polls news service.\n- News service performs a read against the feed for said user.\n- User information for the users mentioned in those news items are looked up from Cassandra.\n- Users who are not populated in the cache are eliminated from the response and a message is fired to populate that user cache asynchronously.\n\nDesigned to be overly cautious and easy on the infrastructure as it was the first project at Mind Candy to use Scala/Cassandra/Akka.\n
  • Wanted to avoid the monolithic WAR file accompanied by Tomcat, wired up with Spring.\n\nUsed implicit constructor arguments to perform a simple form of dependency injection, which avoids circular dependencies. However be careful of SI-5618 as specifying types can cause things to be wired with nulls out of order.\n\nUnfiltered provides a clean way to do REST like services that can be easily separated to use elsewhere. Wanted to make components.\n\nAkka allowed us to build a primitive CQRS system internally to the application, creating read and write paths.\n\nIf you're not using Scalacheck, you should be. Helpful to catch the issues you don't think about. Allows me to assume that I'm stupid and that I wont think of everything.\n\nMore a general point, we can write OO/functional/actor based code where it fits most appropriately.\n
  • \n
  • From a Tools/Infrastructure POV\n\nPreviously had used Python\n\nlots of 'pure java' libraries I can use e.g. talk to Subversion so few BINARY dependencies\n\nwe already have a JVM on every machine - desktop and server\n\nMakes for very easy deployment of tools to users -- it's just a (big) .jar file\n\nFewer platform differences between Mac/Linux/Win compared to, say, Python\n\nComing from Python, code feels very familiar - terse but can understand it later!\n\nLanguage scalability - from REPL tests / scripts up to big apps - Tools/Infrastructure covers a LOT of different code sizes so having one language that works everywhere is really useful for me\n
  • Testing pattern matching / parsing with REPL\n\nQuick scripts - e.g. migration of DB update scripts from folder-of-folders to a flat list. -> clean when done functionally\n\nsetup tool using Swing UI\n\nPlay based websites - migrating to play 2\n\n\ntalking to RESTful web services using XML pattern matching\n\nbuilt in regexes make it cleaner\n
  • PLAY based site\ngood if migrating from Django I think\n\ntwitter for JSON parsing - similar to python's json parse/dump\n\npattern matching / regex parsing make life easier\n\neverything returning a value = cleaner code\n
  • populating a data table \nties together Java subversion lib, \njava google data visualisation lib, scala logic!\n\nI'm not saying its good Scala, but I found it quite easy to write / understand\n
  • Game developers especially - great migration path from dynamic scripting languages (Python, Ruby, Lua) that you may already be using.\n\n Looks like a dynamic language, scales up like a static language.\n\nFunctional programming can give very clean, well expressed algorithms so you can focus on that, not on boilerplate.\n\nStrong focus on immutability and message passing means its easier to build scalable/reliable services -- which will strongly interest Game Devs these days!\ne.g. twitter moved from Ruby -> Scala\n\nScala books/docs great!\n\n
  • Game developers especially - great migration path from dynamic scripting languages (Python, Ruby, Lua) that you may already be using.\n\n Looks like a dynamic language, scales up like a static language.\n\nFunctional programming can give very clean, well expressed algorithms so you can focus on that, not on boilerplate.\n\nStrong focus on immutability and message passing means its easier to build scalable/reliable services -- which will strongly interest Game Devs these days!\ne.g. twitter moved from Ruby -> Scala\n\nScala books/docs great!\n\n
  • large amount of syntax to learn\nfeatures better for library writers than code authors sometimes?\nBackwards compatibility - e.g. play 2 lack of Magic[T]\n\nObviously, you can write bad code in it, but no worse (I would argue) than C++ with macros/templates etc. \noperator overloading is still scary\n\n\n
  • large amount of syntax to learn\nfeatures better for library writers than code authors sometimes?\nBackwards compatibility - e.g. play 2 lack of Magic[T]\n\nObviously, you can write bad code in it, but no worse (I would argue) than C++ with macros/templates etc. \noperator overloading is still scary\n\n\n
  • large amount of syntax to learn\nfeatures better for library writers than code authors sometimes?\nBackwards compatibility - e.g. play 2 lack of Magic[T]\n\nObviously, you can write bad code in it, but no worse (I would argue) than C++ with macros/templates etc. \noperator overloading is still scary\n\n\n
  • large amount of syntax to learn\nfeatures better for library writers than code authors sometimes?\nBackwards compatibility - e.g. play 2 lack of Magic[T]\n\nObviously, you can write bad code in it, but no worse (I would argue) than C++ with macros/templates etc. \noperator overloading is still scary\n\n\n
  • currently using it in 2 production services & as standard language for Tools/Infrastructure\n(alongside Java/Python)\nWill continue to train people up in Scala and use it more\nStill learning what  best "coding standards" will be for Scala to allow people to understand each other's code\n
  • currently using it in 2 production services & as standard language for Tools/Infrastructure\n(alongside Java/Python)\nWill continue to train people up in Scala and use it more\nStill learning what  best "coding standards" will be for Scala to allow people to understand each other's code\n
  • \n

Scala at Mind Candy Scala at Mind Candy Presentation Transcript

  • Scala at MindCandy Sean Parsons & Mark Baker @seanparsons @markltbaker
  • Who are we?
  • Who are we?
  • Why we chose ScalaFamiliarity with the JVM.Transforming collections, Guava is still a bit ofa blunt tool.Static types are cool.Of the non-Java JVM languages seemed tohave the bigger community.Commercial Support
  • How we used Scala - Services (1)
  • How we used Scala - Services (1)
  • How we used Scala - Services (2)
  • How we used Scala - Services (2)User: 1
  • How we used Scala - Services (2)User: 1 Game
  • How we used Scala - Services (2)User: 1 Game News
  • How we used Scala - Services (2)User: 1 Game News BFFs
  • How we used Scala - Services (2)User: 1 Game News BFFs GameDB
  • How we used Scala - Services (2) Feed: 7User: 1 Game News Feed: 8 Feed: 9 BFFs GameDB
  • How we used Scala - Services (3)
  • How we used Scala - Services (3)User: 7
  • How we used Scala - Services (3)User: 7 News
  • How we used Scala - Services (3) Feed: 7User: 7 News
  • How we used Scala - Services (3) Feed: 7User: 7 News Users
  • How we used Scala - Services (3) Feed: 7User: 7 News Users GameDB
  • How we used Scala - Services (4)Simpler designUnfiltered & AkkaScalacheck is a lifesaverUsed the appropriate paradigm
  • Now the story from Tools...
  • Why Scala for ToolsFewer dependenciesEasy to distribute toolsLots of useful Java libsMove from Python "felt good"XML / Pattern match featuresLanguage Scalability
  • How we used Scala - Tools (1)REPL investigationsQuick ScriptsSetup Tool Play-based websites
  • How we used Scala - Tools (2)private val HudsonColorRegex = new Regex(""".*"color":"(w+)".*""")private def jenkinsBuildStatus(build:models.AutomatedBuild):String = { val hudsonUrl = build.url + "/api/json" val result = scala.io.Source.fromURL(hudsonUrl).getLines().mkString val HudsonColorRegex(color) = result color match { case "blue" => GOOD case "red" => BAD case "aborted" => BAD case "disabled" => DISABLED case "grey_anime" => UNKNOWN // build has not run yet... case _ => unknownStatus("cant match jenkins build status color of: " + color) }}
  • How we used Scala - Tools (3)getCachedFileSizes(path, revision) .groupBy{ _.size / groupByBytes } .map { case (group,files) => group -> files.size } .toList .sorted .foreach { case (group, count) => data.addRowFromValues( humanGroupSize(group * groupByBytes, groupByBytes), new Integer(count)) }
  • Our Scala Experience
  • Our Scala ExperienceMigration from dynamic languagesClean expression of algorithms – What, not HowImmutability and Actors = Scale!The REPL
  • Our Scala Experience
  • Our Scala ExperienceTraining - lots of syntax to learnNew language & New paradigmsTools maturityCompiler errors
  • Our Scala ExperienceTraining - lots of syntax to learnNew language & New paradigmsTools maturityCompiler errorsStill learning about maintenancebehaviour
  • Future of Scala at Mind Candy
  • Future of Scala at Mind Candy Tools Scripts Services Training
  • Were hiring!tech.mindcandy.comEmail:markb@mindcandy.comsean@mindcandy.comTwitter:@markltbaker@seanparsons