2. Vanity Slide
• Software Developer at Novell
• Working on a next-gen communications
system called “Pulse”
• Author of Scala for Java Refugees
• ...and a fair bit more
• An unhealthy fascination with languages
3. Brief Overview of Pulse
• Next-Gen communications platform
• Implemented as a web application
• AJAX
• Comet
• Focus on security and enterprise
management
7. Architecture
Messaging Service
Search Service (SOLR)
Webapp (Lift) RabbitMQ
Notification Service
WFP Service
HBase + MySQL
9. <message id="42">
<line/>Playing with Pulse (and trying to avoid
accidentally poluting any of Andy's demos).
<message id="43">
<line/>We can reply quite easily.
</message>
</message>
10. Nifty Tricks
• Messages are chunks of XML
• Extend Elem
• Custom NoBindingFactoryAdapter
• Use #load(String)
11. Nifty Tricks
• Messages are chunks of XML
• All frontend services use Cake Pattern
• Very extensive use of actors
12. Challenges
• Actors require a recovery mechanism
• Java / Scala interop is a little clumsy
• Collections conversion (java-utils)
13. import scala.collection.jcl.Conversions._
def foo(bar: java.util.List[String]) = {
val xs: Seq[String] = bar
bar.add("baz")
xs foreach println // does it contain "baz"?
}
def foo(bar: List[String]) = {
val back = new java.util.ArrayList[String]
bar foreach back.add
back
}
14. import org.scala_tools.javautils.Implicits._
def foo(bar: java.util.List[String]) = {
val xs = bar.asScala
bar.add("baz")
xs foreach println
}
// returns java.util.List[String], and in O(1) too!
def foo(bar: List[String]) = bar.asJava
15. Challenges
• Actors require a recovery mechanism
• Java / Scala interop is a little clumsy
• Collections conversion (java-utils)
• Spring doesn’t like mixins
• Tools are primitive (at best)
• Scala devs are in short supply
25. Scala Style
• Leverage type inference!
val s: String = "blah" // wrong
val s = "blah" // right
26. Scala Style
• Leverage type inference!
• Higher-Order functions
// wrong
def foldLeft[A](init: A, f: (A, B) => A) = ...
// right
def foldLeft[A](init: A)(f: (A, B) => A) = ...
foldLeft(0) { (a, b) => ... }
27. Scala Style
• Leverage type inference!
• Higher-Order functions
• Function values
foo (x) => x + 1 // wrong
foo (x) => { x + 1 } // wrong
foo { _ + 1 } // right
foo { x => x + 1 } // right
28. Scala Style
• Leverage type inference!
• Higher-Order functions
• Function values
• Correct use of implicits
• Pimp-my-library
• Correcting inheritance (typeclasses)
29. Scala Style
• ...
• Function values
• Rules for correct use of implicits
• Arity-0 methods
println // wrong
println() // right
xs.length() // wrong
xs.length // right
30. Scala Style
• Leverage type inference!
• Higher-Order functions
• Function values
• Rules for correct use of implicits
• Arity-0 methods
• File organization
31. Conclusion(s)
• Yes, Scala is ready for the enterprise!
• ...but there’s definitely room to improve
• Process and conventions are critical
• Community is developing standards.
Participate!