Taking Scala into the Enterprise           Peter Pilgrim       Oracle Java Champion       ACCU Conference 2013
About the Speaker•   Java Champion•   Independent Contractor•   Java since 1998•   Scala since 2010        13 April 2013  ...
Agenda• What’s New in Scala 2.10?• Play Framework• AKKA Framework 13 April 2013    Xenonique ©2013   3
TypeSafe13 April 2013     Xenonique ©2013   4
Simplicity“I want a language with simple means to do interestingthings, which is not the same as a language to do onlysimp...
TypeSafe: The Company• Founded in Summer 2011• Based in Switzerland and  headquartered in New York, USA• Scala, Akka and P...
Growth of Scala Training• Scala Solutions• Dick Wall and Bill Venners,  Escalate Solutions• ScalaDays conference in London...
Scala Knowledge• Hunger for more know-how• Growing Awareness in Functional  Programming• Object Oriented Languages embrace...
Scala in Enterprise•   Morgan Stanley•   HSBC•   Guardian UK•   Twitter•   Linked-In•   Four Square       13 April 2013   ...
Scala Revision                Demonstration of the simplicity13 April 2013              Xenonique ©2013        10
Scalable Language                  Still has a very bright futureFunctional                                             Pu...
Typing Derived from “Pascal”  Tree of Computer Language <variableName> [: [ <Type> ]              personName: String      ...
Variables and Values• Assignment less programming• Prefer val over varvar   x = 10.0; x = 10 + xval   y = 10.0val   z: Flo...
Scala Classclass Person (    val firstName: String    val lastName: String,    val height: Float,    val age: Int ) {    /...
Instances of Scala Classesval p1 = new Person( "Billy","Mitchell", 5.10F, 42 )val p2 = new Person( "Kat","Moon", 5.8F, 39 ...
Companion Objectsobject Person {     private records = List[Person]()     def apply(fn: String, ln: String,          h: Fl...
Case Classesclass Transmission( driveTrain:String )     13 April 2013       Xenonique ©2013   17
Scala Functionsval isEven: (Int => Boolean) =             (k: Int) => k % 2 == 0• Functions are values, values are object•...
Scala Codedef uniqueSorted[Symbol]( p: List[Symbol] ): List[Symbol] = {    val myOrdering =       Ordering.fromLessThan[Sy...
Functions are First Class• In Scala, functions are first  class citizens• Functions can return functions     13 April 2013...
SBT•   SBT is the de-facto build tool•   Works with Maven•   Incremental Compilation +1•   DSL written in Scala +1•   Plug...
Gradle• Gradle is written in Groovy• Gradle is a DSL too +1• Easier to Grok +1• Since v1.4 Gradle support  incremental com...
String Interpolation•   SIP 12: String interpolation•   S”Book written by $author”•   Arbitary identifier: StringContext• ...
Value Classes•   Implicit Classes•   Classes that extend AnyVal•   Unboxed value classes•   Language imports•   import    ...
Value ClassesElegant wrappers around simpletypes• A Value class is treated as  another type• A value value is assigned to ...
Incremental Compilation• Incremental compilation, Zinc• Language with simple means to do  interesting things     13 April ...
Scala Test•   The de-facto testing framework•   Created Bill Venners, JVM Book•   DSL unit testing language•   Behaviour D...
Play Framework                Non Java EE web framework13 April 2013            Xenonique ©2013    28
Play Framework 2.0•   Non Java EE – No Servlet•   Built for Web Development•   Direct manipulation of HTTP•   Asynchronous...
Play Framework Architecture                                 Web Client                                  Network           ...
Play Advantages•   Highly productive web development•   Work with Web Designers•   Feels of “Rails”•   Compiler type check...
Play Disadvantages• Completed encapsulated environment• Unlike JavaEE and WAR file  deployment to application server• No W...
Play Style• Dispatch through a Router file• Directly manipulation of the HTTP  response, Ok(200), Error(404)• Control HTTP...
Play Persistence• Play has its own persistence provider  Anorm: a direct SQL framework• Play can also use Squeryl: an Obje...
Developer Summary
What You Will Do Tomorrow?              Why FP?                          Gradle /Scala Test   Scala 2.10     SBT          ...
Game Over13 April 2013     Xenonique ©2013   37
Professional Services        Contract Software Development        Scala, JavaEE, JavaFX, TDD, Gradle        W: http://www....
Professional Services           peter.pilgrim@gmail.com           Scala, JavaEE 7, JavaFX           Contracting           ...
Attributions• The author would very like to attribute these  pleasurable Creative Commons License 3.0  photographers•   Br...
Attributions #2•   Study in Math exam photo by Steve S;    http://www.flickr.com/photos/scubasteveo/296747958/            ...
Upcoming SlideShare
Loading in …5
×

ACCU 2013 Taking Scala into the Enterpise

2,114 views

Published on

Talk at ACCU 2013 in Bristol

Published in: Education, Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,114
On SlideShare
0
From Embeds
0
Number of Embeds
1,442
Actions
Shares
0
Downloads
22
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

ACCU 2013 Taking Scala into the Enterpise

  1. 1. Taking Scala into the Enterprise Peter Pilgrim Oracle Java Champion ACCU Conference 2013
  2. 2. About the Speaker• Java Champion• Independent Contractor• Java since 1998• Scala since 2010 13 April 2013 Xenonique ©2013 2
  3. 3. Agenda• What’s New in Scala 2.10?• Play Framework• AKKA Framework 13 April 2013 Xenonique ©2013 3
  4. 4. TypeSafe13 April 2013 Xenonique ©2013 4
  5. 5. Simplicity“I want a language with simple means to do interestingthings, which is not the same as a language to do onlysimple things.” Prof. Martin Odersky 13 April 2013 Xenonique ©2013 5
  6. 6. TypeSafe: The Company• Founded in Summer 2011• Based in Switzerland and headquartered in New York, USA• Scala, Akka and Play Framework• Professional Support for Scala 13 April 2013 Xenonique ©2013 6
  7. 7. Growth of Scala Training• Scala Solutions• Dick Wall and Bill Venners, Escalate Solutions• ScalaDays conference in London 2012• Scala content at JavaOne 2012 13 April 2013 Xenonique ©2013 7
  8. 8. Scala Knowledge• Hunger for more know-how• Growing Awareness in Functional Programming• Object Oriented Languages embrace FP principles• JDK 8 Lambdas• Clojure jobs at CitiBank, London & NY 13 April 2013 Xenonique ©2013 8
  9. 9. Scala in Enterprise• Morgan Stanley• HSBC• Guardian UK• Twitter• Linked-In• Four Square 13 April 2013 Xenonique ©2013 9
  10. 10. Scala Revision Demonstration of the simplicity13 April 2013 Xenonique ©2013 10
  11. 11. Scalable Language Still has a very bright futureFunctional Purely Object-Oriented Statically-typed JVM Language 4/13/2013 XeNoNiQUe.co.uk (c) 2011 11
  12. 12. Typing Derived from “Pascal” Tree of Computer Language <variableName> [: [ <Type> ] personName: String taxRate: Float density: Double found: False persion: Person 13 April 2013 Xenonique ©2013 12
  13. 13. Variables and Values• Assignment less programming• Prefer val over varvar x = 10.0; x = 10 + xval y = 10.0val z: Float = xvar t: Int = 42; t = t * 2 13
  14. 14. Scala Classclass Person ( val firstName: String val lastName: String, val height: Float, val age: Int ) { // Write your definition here} 13 April 2013 Xenonique ©2013 14
  15. 15. Instances of Scala Classesval p1 = new Person( "Billy","Mitchell", 5.10F, 42 )val p2 = new Person( "Kat","Moon", 5.8F, 39 ) 13 April 2013 Xenonique ©2013 15
  16. 16. Companion Objectsobject Person { private records = List[Person]() def apply(fn: String, ln: String, h: Float, a: Int): Person = { val p = new Person(fn, ln, h, a ); records = p :: records.reverse //O(1) return p } def recordCount() = records.size} 13 April 2013 Xenonique ©2013 16
  17. 17. Case Classesclass Transmission( driveTrain:String ) 13 April 2013 Xenonique ©2013 17
  18. 18. Scala Functionsval isEven: (Int => Boolean) = (k: Int) => k % 2 == 0• Functions are values, values are object• Ergo, functions are objects in Scala 13 April 2013 Xenonique ©2013 18
  19. 19. Scala Codedef uniqueSorted[Symbol]( p: List[Symbol] ): List[Symbol] = { val myOrdering = Ordering.fromLessThan[Symbol]( _.toString < _.toString ) var acc = SortedSet.empty(myOrdering) def compress0( q: List[Symbol] ): Unit = { q match { case Nil => Nil case x :: xs => { acc += x ; compress0(xs) } } } compress0( p ) acc.toList } 13 April 2013 Xenonique ©2013 19
  20. 20. Functions are First Class• In Scala, functions are first class citizens• Functions can return functions 13 April 2013 Xenonique ©2013 20
  21. 21. SBT• SBT is the de-facto build tool• Works with Maven• Incremental Compilation +1• DSL written in Scala +1• Plugins Available +1• Complex to Understand -1 13 April 2013 Xenonique ©2013 21
  22. 22. Gradle• Gradle is written in Groovy• Gradle is a DSL too +1• Easier to Grok +1• Since v1.4 Gradle support incremental compilation through Zinc• Not the de-facto standard -1 13 April 2013 Xenonique ©2013 22
  23. 23. String Interpolation• SIP 12: String interpolation• S”Book written by $author”• Arbitary identifier: StringContext• StringContext(“Books written by”).id(author) 13 April 2013 Xenonique ©2013 23
  24. 24. Value Classes• Implicit Classes• Classes that extend AnyVal• Unboxed value classes• Language imports• import language.implicitConversions 13 April 2013 Xenonique ©2013 24
  25. 25. Value ClassesElegant wrappers around simpletypes• A Value class is treated as another type• A value value is assigned to an array• Doing runtime type tests, such as pattern matching 13 April 2013 Xenonique ©2013 25
  26. 26. Incremental Compilation• Incremental compilation, Zinc• Language with simple means to do interesting things 13 April 2013 Xenonique ©2013 26
  27. 27. Scala Test• The de-facto testing framework• Created Bill Venners, JVM Book• DSL unit testing language• Behaviour Driven Development +1• Test Driven Development 13 April 2013 Xenonique ©2013 27
  28. 28. Play Framework Non Java EE web framework13 April 2013 Xenonique ©2013 28
  29. 29. Play Framework 2.0• Non Java EE – No Servlet• Built for Web Development• Direct manipulation of HTTP• Asynchronous Input and Output• Scalable Vertically 29
  30. 30. Play Framework Architecture Web Client Network Netty (Java NIO Client Server Framework) Play Framework 13 April 2013 Xenonique ©2013 30
  31. 31. Play Advantages• Highly productive web development• Work with Web Designers• Feels of “Rails”• Compiler type checked• Model, View and Controller 31
  32. 32. Play Disadvantages• Completed encapsulated environment• Unlike JavaEE and WAR file deployment to application server• No WAR file (yet) as of Play 2.1.x• Ironically, WAR files need JavaEE 7 (WebSocket and Async Servlet 3.1) 32
  33. 33. Play Style• Dispatch through a Router file• Directly manipulation of the HTTP response, Ok(200), Error(404)• Control HTTP interface: GET, PUT, POST, DELETE• Model, View and Controller scala objects• Asynchronuous process API 33
  34. 34. Play Persistence• Play has its own persistence provider Anorm: a direct SQL framework• Play can also use Squeryl: an Object- Relational Mapper DSL with type safety. 34
  35. 35. Developer Summary
  36. 36. What You Will Do Tomorrow? Why FP? Gradle /Scala Test Scala 2.10 SBT Play / Akka
  37. 37. Game Over13 April 2013 Xenonique ©2013 37
  38. 38. Professional Services Contract Software Development Scala, JavaEE, JavaFX, TDD, Gradle W: http://www.xenonique.co.uk/blog/ E: peter.pilgrim@gmail.com 4/13/2013 38
  39. 39. Professional Services peter.pilgrim@gmail.com Scala, JavaEE 7, JavaFX Contracting Software Development 4/13/2013 39
  40. 40. Attributions• The author would very like to attribute these pleasurable Creative Commons License 3.0 photographers• Brush Metal Elevator door By Jerry "Eyes" Ranch; West Des Moines, IA, USA; http://www.flickr.com/photos/ranchjp/3684969194/• 19/365 Game Over by Mykl Roventine; http://www.flickr.com/photos/myklroventine/3210068573• Experiment in abstract lightning by Bob Doran; Walnut Creek, Arcata, USA ; http://www.flickr.com/photos/humblog/4522984790/in/photostream/ 40
  41. 41. Attributions #2• Study in Math exam photo by Steve S; http://www.flickr.com/photos/scubasteveo/296747958/ 41

×