Scala in Practice
A pragmatic view on programming language adoption
Lutz Huehnken - Solutions Architect, Typesafe, Inc. @lutzhuehnken
I.Should a Pragmatist Care About languages? II.The Case For Scala III.Scala in The Real World IV.Scala Adoption Done Right
I.Should a Pragmatist Care About languages? II.The Case For Scala III.Scala in The Real World IV.Scala Adoption Done Right
Jazoon - Scala in Practice 5
Telling The Computer What To Do..
A programming language is for telling the computer what to do
Any Turing-complete language can do that
Jazoon - Scala in Practice 6
.. vs. Building A Model Of The World
The World is
• People and things (objects) interacting which each other?
• Described by laws of science and mathematics?
• Based on logic?
Jazoon - Scala in Practice 7
Ludwig Wittgenstein (1889 - 1951)
The limits of my language are the limits of my mind.
All I know is what I have words for.
Image from Wikipedia
Jazoon - Scala in Practice 8
A. Expressiveness
OOP
Functional Programming
Model
Logic Programming
Jazoon - Scala in Practice 9
B. Productivity
Managed Runtime /
Garbage Collection
> No Garbage Collection
Strongly Typed &
Static Type-Checking
> Weakly Typed or
Dynamic Type-Checking
Jazoon - Scala in Practice 10
C. Community
https://twitter.com/kilaulena/status/463317989648248832
Jazoon - Scala in Practice 11
Pragmatic Language Choice
Expressiveness
Productivity
Language
Communities
I.Should a Pragmatist Care About languages? II.The Case For Scala III.Scala in The Real World IV.Scala Adoption Done Right
Jazoon - Scala in Practice 13
Scala unifies OO and FP
http://www.scala-lang.org
Jazoon - Scala in Practice 14
Scala leverages the JVM Eco System
Jazoon - Scala in Practice 15
Scala & Java
For All You Know, It's Just a Java Library
The customer asks "Where's the Scala part?" I answer "It's in this JAR file." He goes "But, your program is written in Scala, but I looked at the byte-code and it's just Java." I answer "It's Scala... but it compiles down to Java byte-code and it runs in a Java debugger and you can't tell the difference." "You're right," he says.
So, to this customer's JVM, the Scala and Lift code looks, smells and tastes just like Java code. If I renamed the scala-library.jar file to apache-closures.jar, nobody would know the difference... at all.
http://blog.goodstuff.im/just_another_java_library
Jazoon - Scala in Practice 16
Communities: Java
Internet Tech in Enterprises
Mobile
Java
Android
Java EE
Spring
Jazoon - Scala in Practice 17
Communities: Python
Scientific Computing Data Science
Python
iPython Notebook
NumPy
SciPy
Jazoon - Scala in Practice 18
Communities: Scala
Reactive Systems
Big Data
Scala
Spark
Akka
ScalaZ
Functional Programming
Typelevel (shapeless,
cats, ..)
Jazoon - Scala in Practice 19
The Case For Scala
Expressiveness
Productivity
Scala
OO
Big Data!
CommunitiesReactive!
Java Eco System and Tooling
FP
I.Should a Pragmatist Care About languages? II.The Case For Scala III.Scala in The Real World IV.Scala Adoption Done Right
Jazoon - Scala in Practice
Jazoon - Scala in Practice 22
Apache Kafka
• Developed at LinkedIn
• Typical use-case: central publish-subscribe log for integrating data between applications, stream processing, data ingestion (Spark, Hadoop)
Jazoon - Scala in Practice 23
Apache Kafka
• 3x Intel Xeon 2.5 GHz processor (6 cores)
• Three producers, 3x async replication • 2,024,032 records/sec
• Three Consumers • 2,615,968 records/sec
Jazoon - Scala in Practice
Jazoon - Scala in Practice 25
It’s just too big right now to not mention it..
Jazoon - Scala in Practice
Jazoon - Scala in Practice 27
Twitter - may be not the role model for your company
• Early adaptor, but highly customized • E.g. Twitter „Futures“
• Twitter-Stack (Finagle etc.) • Build system (Pants)
• But
• Performance / scaling problem solved • Scala going strong at Twitter for 6 years now • And with some impact - „Server as a Function“
Jazoon - Scala in Practice
Jazoon - Scala in Practice 29
Soundcloud
Jazoon - Scala in Practice 30
Soundcloud - a bit of history
It was a phase of high experimentation, and instead of defining which languages or runtimes these teams should use, we had the rule of thumb write it in whatever you feel confident enough putting in production and being on-call for.This led to a Cambrian Explosion of languages, runtimes and skills. We had systems being developed in everything from Perl to Julia, including Haskell, Erlang, and node.js.[..]We have used Finagle for HTTP, Thrift, memcached, Redis, and MySQL. Every request to the SoundCloud platform is very likely hitting at least one of our Finagle-powered microservices, and the performance we have from these is quite amazing.
Jazoon - Scala in Practice
Jazoon - Scala in Practice 32
Morgan Stanley
Rumors
• Adoption is language - driven
• Scala because of • Functional Programming • Flexibility (DSLs, Macros..)
Jazoon - Scala in Practice
Jazoon - Scala in Practice 34
UniCredit
Rumors
• Akka & externally driven
• Very skeptical of Scala • Need for some scalable, real time event processing • SI chose Akka, Scala • Delivered under time & budget • Scala it is
Jazoon - Scala in Practice
Jazoon - Scala in Practice 36
Galeria Kaufhof
• Driven by „epiphany“: We need to be a tech company
• From standard software to build-your-own • Culture change - pure retailer to tech focus
Jazoon - Scala in Practice 37
Galeria Kaufhof
JUMP!
http://www.inoio.de/blog/2014/09/20/technologie-sprung-bei-galeria-kaufhof/
Jazoon - Scala in Practice 38
Galeria Kaufhof
Jazoon - Scala in Practice 39
Galeria Kaufhof
Jazoon - Scala in Practice
Jazoon - Scala in Practice 41
Zalando
• Magento -> Java -> Scala • Actually polyglot, autonomous teams • But must be on tech radar • Polyglot is great, but maybe not for everyone
Jazoon - Scala in Practice
Jazoon - Scala in Practice 43
Renault R-Link
• Driven by Akka
• Build by AtoS
I.Should a Pragmatist Care About languages? II.The Case For Scala III.Scala in The Real World IV.Scala Adoption Done Right
Jazoon - Scala in Practice 45
Scala Caveats
For All You Know, It's Just a Java Library.. .. but it’s not!
That may be true at runtime - but certainly not in development.
Josh Suereth:This is an important point. Scala is not just a “Java++”. There’s a lot of depth to pull out of the language, and lots you can learn. It doesn’t take a lot to start, but it can be intimidating how much is out there. You need to be prepared for it to take some time to learn things
Jazoon - Scala in Practice 46
Scala Caveats
sbt
But once you get the hang of it.. define your Scala build in Scala.
It’s actually a great tool
Jazoon - Scala in Practice 47
Scala Caveats
Parts of the community
But everyone I interacted with in the Scala community was super
friendly and helpful.
Disclaimer: Maybe Tony Morris is, too - I don’t know him and never met him.
These „headlines“ are about all I know about him.
Jazoon - Scala in Practice 48
Scala Caveats
• There is no „Scala EE“. Yet.
• But patterns are evolving.
Jazoon - Scala in Practice 49
Scala Caveats
• The power to split teams
• Goes hand in hand with „We do, because we
can“
• Comp. Design Patterns
Jazoon - Scala in Practice 50
Scala Caveats
• We can ≠ we should
• Coding guidelines
• See Twitter, Kafka, Spark..
Jazoon - Scala in Practice 51
So do what?
• Introduce Scala!
•What is your driver? Focus on that.
•Give team time to learn, get trainings
•Establish coding guidelines
•Address and avoid split proactively
•There will be along on the road
•But it’s worth it!
Thank You
Lutz Huehnken - Solutions Architect, Typesafe, Inc. @lutzhuehnken
©Typesafe 2015 – All Rights Reserved