This presentation is for enterprises that are considering adopting Scala. The author is managing editor of http://scalacourses.com, which offers self-paced online courses that teach Introductory and Intermediate Scala and Play Framework.
2. About Mike Slinn
• Principal at Micronautics Research
Corporation
• Hands-on architect, mentor, trainer
• Interim technical leader for companies in
transition
• Recognized in US Federal court as a
software expert
• Author of “Composable Futures with Akka 2.0
• Twitter: mslinn
3. About You, the Attendees
• ___% Managers
o ___% Full-time programmers
• ___% Interns
• Programmers
o ___% New to Scala
o ___% Intermediate Scala programmers
o ___% Expert Scala programmers
o ___% Currently work on Scala projects
o ___% Windows, Linux, Mac, other
5. James Gosling
“Father of Java”
“If I were to pick a
language to use today
other than Java, it
would be Scala”
6. James Strachan
Groovy Language &
Apache Camel book
“If someone had shown
me the Programming in
Scala book in 2003, I
would not have created
Groovy.”
7. Alex Payne
Early Twitter engineer,
co-author of “Joy is underrated
“Programming Scala”
as a metric for a
language's
potential success
in a development
organization”
8. What is Scala?
• Natural progression on the JVM
• Same deployment mechanism as Java
• Scale up and out, with concurrency and/or
parallelism
o Java.util.concurrent
o Scala Parallel collections
o Actors
o Futures (allows map/reduce)
o Dataflow
o Map/reduce frameworks
9. Scala vs. Other OO & FP Languages
Java Scala Clojure Ruby
Typing Static Static Dynamic Dynamic
Paradigm OO OO & FP FP OO
10. Two Types of Programming
• Imperative Programming
o Describes computation in terms of statements that
change program state
• Functional Programming
o Describes computation in terms of mathematical
functions, avoiding state and mutable data
11. Scala is Object-Oriented
• Primitives are full objects
• Static methods are attached to singletons
• Imperative style
• You can use Scala simply as a better Java
12. Scala is Also Functional
• Transform data objects instead of mutation
• Strong list processing (e.g. map and reduce)
• Thread-safe
• Parallelizable
• Supports composition
17. Scala 2012 Roadmap
May 2011 Oct 2011 Q1 2012 Q3 2012
Typesafe Typesafe Typesafe Typesafe
Stack 1.0 Stack 1.1 Stack 2.0 Stack 2.1
Scala 2.9.0 Scala 2.9.1 Scala 2.9.2 Scala 2.10
Akka 1.1 Akka 1.2 Akka 2.0 Akka 2.1
IDE 1.0 Play 2.0 Play 2.1
SBT 0.11.2 Slick (DB)
IDE 2.0 M1 IDE 2.0 RC
18. Scala Toolchain
• At a tipping point
• Toolchain options
o SBT w/ Text editor
Flexible, multiplatform, complex, compatible with
Maven, documentation lacking
Compatible with IDEs
o Maven – consider this only if you already use Maven
o Eclipse – Usable
o IntelliJ IDEA – Usable
o Netbeans – Not popular, not well supported
o Ant – Not popular but works fine
20. Use Case: guardian.co.uk
• 100,000 lines of code.
• Spring, Velocity, Hibernate, Oracle DB,
Maven.
• Full release every 2 weeks.
• Wrote integration tests using ScalaTest.
• After a month of writing tests in Scala, they
converted the whole site to Scala.
• Java and Scala code co-existed and
depended on each other
21. Use Case: Wordnik
• 5:1 reduction in code
• Corresponding increase in quality
• Maintenance costs decreased similarly
• Scala attracts good developers
• Typesafe was very responsive
• REPL makes IDEs less important
• Pattern matching was unexpected benefit
• SBT love/hate
• Never going back to Java
23. Enterprise Characteristics
• Many locations
• IT department often separate from
development teams
• Legacy apps and data
• Lots of SOAP
• Big investment in JEE containers
• Risk averse
• Compliance issues
• Budget for incremental change is small
portion of overall IT budget
24. Why Scala In the Enterprise?
• Big scale, solid programs
• Get more done
o More expressive
o Fewer lines of code
o More productive
o Strong community
o Fewer bugs (constant number of bugs/line of code)
• Talent attractor
26. Concurrency Is Too Hard
• Multithreaded programs tend to be buggy
o Non-determinism caused by concurrent threads
accessing shared mutable state.
• Actors and transactions manage state and
are therefore not a solution.
• To get deterministic processing, avoid
mutable state.
• This means functional programming.
27. Scala Offers Better Concurrency
• Akka Composable futures*
• Akka/Scala Dataflow*
• Akka Actors
• Scala Parallel collections
* Covered in my book:
“Composable Futures with Akka 2.0”
30. Why Not Scala?
• Steep learning curve
o New syntax
o Many new concepts
o Tools experiencing heavy growth
o Documentation still weak, not many books
o How to find a Scala programmer?
Grow instead of hire
• JDK 8 will have closures
o Release Sept 2013
o Mass adoption 2017?
31. Scala Vocabulary
• Lazy evaluation • Composition
• Monads • Pattern matching
• Continuations • Type extensions
• Recursion • Traits
• Closures • Control structure
• Immutable datatypes abstraction
• Currying • Refined types
• Higher order o Covariance
o Variance
functions
o Type bounds
32. Who Should Introduce Scala into
an Enterprise?
• Top down approach
o Gradual, planned implementation
• Bottom up approach
o Skunk works
• Sneak in on the side
o Custom project
• Get toolchain working before including others
33. Types of Scala Applications
• Web platforms
• Trading platforms
• Financial modeling
• Simulation
• Fast to first product, scalable afterwards
34. When to Use Scala?
• “Skunk works” approach
o Gradual introduction minimizes risk
o No need to master all of Scala before using some of it
• “Save the company” approach
o High risk, high gain
35. Where to Introduce Scala?
• Address scalability issues
• DSLs for problem statement
• Testing: integration, black box, white box
o Lots of boilerplate; Scala removes it
o Tests focus on problem domain; DSLs help
o Users (non-programmers) can examine DSLs for
accuracy and maybe write code
• Replace components
36. How to Use Scala?
• Java 6+ or .NET is required
• Choice of Java toolchain
o SBT, Maven, IntelliJ IDEA, Eclipse
o Jenkins/Hudson, other CI
• .NET toolchain not yet ready for prime time
• BUT:
o Can convert Java/Scala to .NET with IKVM
o I’ve done it – works well, easy to use
37. Thank you!
Mike Slinn
mslinn@micronauticsresearch.com
Notas do Editor
Modified from scalaBin (norwegianscala usergroup) logo
Image from Martin Odersky
Image from Martin Odersky Dec 2011.
I updated Martin Odersky’s slides from @ SF Scala Dec 2011