challenges of moving a java team to scala
TRANSCRIPT
![Page 2: Challenges of moving a java team to scala](https://reader034.vdocuments.net/reader034/viewer/2022042607/55a938b91a28ab430a8b475f/html5/thumbnails/2.jpg)
About me
• 10 years professional experience as a developer in multiple languages (from C to Java).
• Working at E.near, as a Systems Architect and managing 3 Scala development teams.
![Page 3: Challenges of moving a java team to scala](https://reader034.vdocuments.net/reader034/viewer/2022042607/55a938b91a28ab430a8b475f/html5/thumbnails/3.jpg)
Outline
• Why move a Java team to Scala?
• The challenges
• The good things
![Page 4: Challenges of moving a java team to scala](https://reader034.vdocuments.net/reader034/viewer/2022042607/55a938b91a28ab430a8b475f/html5/thumbnails/4.jpg)
This is not about
• An introduction to Scala language.
• Convincing Java fans to move to Scala.
• Migrating Java code to Scala.
![Page 5: Challenges of moving a java team to scala](https://reader034.vdocuments.net/reader034/viewer/2022042607/55a938b91a28ab430a8b475f/html5/thumbnails/5.jpg)
The motivation• A customer asked us to take control of a big
Scala project (+200k lines of code), already in production at the time.
• Time was short.
• We said we would do it!
• We needed the right team and a plan…
![Page 6: Challenges of moving a java team to scala](https://reader034.vdocuments.net/reader034/viewer/2022042607/55a938b91a28ab430a8b475f/html5/thumbnails/6.jpg)
The right team• Not every Java developer can be “converted” to
Scala.
• Although professional Scala experience is not required, functional programming concepts are a “must have”.
• Team members must embrace Scala - happy engineers are essential.
![Page 7: Challenges of moving a java team to scala](https://reader034.vdocuments.net/reader034/viewer/2022042607/55a938b91a28ab430a8b475f/html5/thumbnails/7.jpg)
Scala features that sometimes scare Java
developersAnd how to deal with them
![Page 8: Challenges of moving a java team to scala](https://reader034.vdocuments.net/reader034/viewer/2022042607/55a938b91a28ab430a8b475f/html5/thumbnails/8.jpg)
Infix and Postfix operations
• object.operation(k) can be written as “object operation k”
• object.operation can be written as “object operation”.
• Try not to mix them with traditional object-oriented programming language syntax.
![Page 9: Challenges of moving a java team to scala](https://reader034.vdocuments.net/reader034/viewer/2022042607/55a938b91a28ab430a8b475f/html5/thumbnails/9.jpg)
High order functions
• These are functions that take other functions as parameters, or whose result is a function.
• def hof(f: Int => String, v: Int) = f(v)
• Use them whenever it makes sense (and once you feel comfortable with the concept).
![Page 10: Challenges of moving a java team to scala](https://reader034.vdocuments.net/reader034/viewer/2022042607/55a938b91a28ab430a8b475f/html5/thumbnails/10.jpg)
Implicit conversions
• Given the declaration “implicit convert(a:A):B”.
• “convert” will be called behind the scenes whenever you have an “A” and need a “B”.
• Don’t use it before you understand the consequences.
![Page 11: Challenges of moving a java team to scala](https://reader034.vdocuments.net/reader034/viewer/2022042607/55a938b91a28ab430a8b475f/html5/thumbnails/11.jpg)
How to startOnce you have the right people aboard
![Page 12: Challenges of moving a java team to scala](https://reader034.vdocuments.net/reader034/viewer/2022042607/55a938b91a28ab430a8b475f/html5/thumbnails/12.jpg)
First steps
• Start by writing tests.
• Don’t feel guilty for using OO design in your first days in Scala.
• You don't have to understand all the possibilities when starting.
![Page 13: Challenges of moving a java team to scala](https://reader034.vdocuments.net/reader034/viewer/2022042607/55a938b91a28ab430a8b475f/html5/thumbnails/13.jpg)
Build tools• You can use Maven, but…
• SBT basics are easy to learn.
• Although not as mature as Maven, works better with Scala.
• SBT supports incremental compilation out of the box.
![Page 14: Challenges of moving a java team to scala](https://reader034.vdocuments.net/reader034/viewer/2022042607/55a938b91a28ab430a8b475f/html5/thumbnails/14.jpg)
Scala ecosystem• Typesafe activator
• The play framework
• Lots of online documentation:
• http://www.scala-lang.org/
• Stack overflow
![Page 15: Challenges of moving a java team to scala](https://reader034.vdocuments.net/reader034/viewer/2022042607/55a938b91a28ab430a8b475f/html5/thumbnails/15.jpg)
Express yourself
• Simply express your intent.
• Write readable code. Shorter code is not always a best option.
• There are lots of toys, try to use only the right ones.
![Page 16: Challenges of moving a java team to scala](https://reader034.vdocuments.net/reader034/viewer/2022042607/55a938b91a28ab430a8b475f/html5/thumbnails/16.jpg)
Things we loved about Scala since the first day
And that made things easier
![Page 17: Challenges of moving a java team to scala](https://reader034.vdocuments.net/reader034/viewer/2022042607/55a938b91a28ab430a8b475f/html5/thumbnails/17.jpg)
REPL!
!
!
• REPL is an interactive Scala command line interpreter.
• Awesome for doing experiments!
![Page 18: Challenges of moving a java team to scala](https://reader034.vdocuments.net/reader034/viewer/2022042607/55a938b91a28ab430a8b475f/html5/thumbnails/18.jpg)
Tools, libs & runtime environment
• Compiled Scala is like compiled Java - Bytecode that runs on JVM.
• We can use all our favourite Java libs.
• We can use our favourite IDE (Scala / IntelliJ), and the debugger works!
![Page 19: Challenges of moving a java team to scala](https://reader034.vdocuments.net/reader034/viewer/2022042607/55a938b91a28ab430a8b475f/html5/thumbnails/19.jpg)
Class constructors!
!
!
!
![Page 20: Challenges of moving a java team to scala](https://reader034.vdocuments.net/reader034/viewer/2022042607/55a938b91a28ab430a8b475f/html5/thumbnails/20.jpg)
Pattern matching!
!
!
!
![Page 21: Challenges of moving a java team to scala](https://reader034.vdocuments.net/reader034/viewer/2022042607/55a938b91a28ab430a8b475f/html5/thumbnails/21.jpg)
Conclusions• Myth: We don’t need frameworks.
• Myth: Java sucks, and Java coders aren’t as smart as us.
• More concise code.
• Less time coding.
• Less bugs, if you do it right.