SlideShare a Scribd company logo
1 of 25
(mostly)

How we moved from
         ^

   Java to Scala
     Graham Tackley
     guardian.co.uk
History

• Java shop since 2006
• guardian.co.uk: java + spring + velocity +
  hibernate + oracle
• ~100k lines production java code (and
  ~35k xml...)
Content API
• Provide API to access all of our website
  content
• Limited beta released early 2009
• Started implementation of final version late
  2009
• Live May 2010:
  http://content.guardianapis.com
Content API


(demo of http://content.guardianapis.com)
November 2009


• Started new Content API implementation
• java + guice + guice servlets + apache solr
November 2009


• A few people had played with scala
• No production scala code
January 2010
• Comprehensive integration tests were very
  important to us
• Started writing our integration tests in
  Scala with the awesome ScalaTest
• Already a maven project, so mixed scala-
  java support easy with maven-scala-plugin


                                             demo: mavan-scala-plugin, ScalaTest
January 2010
January 2010


• A fair bit of our test code was java-
  without-semicolons as we learnt about
  Scala...
January 2010
February 2010

• ... despite that we loved it so much that
  after a month we decided to convert the
  whole app to Scala
• scala + guice + guice servlets + apache solr
Our top 5 things we
 loved about scala
    on day one
1. Sensible Class Constructors



             =>
1. Sensible Class Constructors
2. Type inference / val & var

ArrayList<String> myList = new ArrayList<String>();




                            =>

val myList = new ArrayList[String]
3. No source file naming
           constraints


• Don’t need to be named after package &
  class name like java
• So multiple classes are allowed in a single file


                                              e.g. ResponseRenderer.scala
4. REPL (console)



• run “scala” for a scala shell
• awesome for experimentation
5. Same tools, libs, deployment &
 runtime characteristics as Java

• We still use IntelliJ (with the scala plugin)
• A scala war file is just a war file
• All the experience of running jvm in
  production still applies
• Can still use java libraries

                                          e.g. GuiceServletConfig.scala, XmlFormatter.scala
Our top 5 things we
          loved about scala
             on day one

                          SUMMARY:
Scala is great even if you only use it as a more concise java
                 (java-without-semicolons™);
             for us this was a great way to start.
July 2010

• Switched from maven to simple-build-tool
• Mainly for incremental compilation
• ~ test-quick and ~ prepare-webapp also
  invaluable
Writing code
one year on
some early code...




it took us a while to realise that most of the loops we
     wrote in Java were actually “map” or “flatMap”
... ended up as




it took us a while to realise that most of the loops we
     wrote in Java were actually “map” or “flatMap”
Summary
• Migration path from Java relatively smooth
• Take it easy, and don’t fear java-without-
  semicolons in the early days
• An incremental embrace of Scala features
  worked really well for us
• Hide the Java yuk with implicit conversions
• http://content.guardianapis.com
• http://www.guardian.co.uk/open-platform
• http://github.com/guardian/open-platform-
  content-api-scala-client



 graham.tackley@guardian.co.uk ■ @tackers

More Related Content

What's hot

Python to go
Python to goPython to go
Python to go
Weng Wei
 

What's hot (20)

Why akka
Why akkaWhy akka
Why akka
 
Challenges of moving a java team to scala
Challenges of moving a java team to scalaChallenges of moving a java team to scala
Challenges of moving a java team to scala
 
Alfresco Mvc - a seamless integration with Spring Mvc
Alfresco Mvc - a seamless integration with Spring MvcAlfresco Mvc - a seamless integration with Spring Mvc
Alfresco Mvc - a seamless integration with Spring Mvc
 
ELK Stack
ELK StackELK Stack
ELK Stack
 
IGN's V3 API
IGN's V3 APIIGN's V3 API
IGN's V3 API
 
Different ways of integrating React into Rails - Mikhail Bortnyk
Different ways of integrating React into Rails - Mikhail BortnykDifferent ways of integrating React into Rails - Mikhail Bortnyk
Different ways of integrating React into Rails - Mikhail Bortnyk
 
Building Asynchronous Applications
Building Asynchronous ApplicationsBuilding Asynchronous Applications
Building Asynchronous Applications
 
Torquebox rubyhoedown-2012
Torquebox rubyhoedown-2012Torquebox rubyhoedown-2012
Torquebox rubyhoedown-2012
 
MJ Berends talk - Women & Non-Binary Focused Intro to AWS
 MJ Berends talk - Women & Non-Binary Focused Intro to AWS MJ Berends talk - Women & Non-Binary Focused Intro to AWS
MJ Berends talk - Women & Non-Binary Focused Intro to AWS
 
DevOps for Scala
DevOps for ScalaDevOps for Scala
DevOps for Scala
 
Owin & katana
Owin & katanaOwin & katana
Owin & katana
 
Manage your environment with DSC
Manage your environment with DSCManage your environment with DSC
Manage your environment with DSC
 
Hello world - intro to node js
Hello world - intro to node jsHello world - intro to node js
Hello world - intro to node js
 
Python to go
Python to goPython to go
Python to go
 
SSDs are Awesome
SSDs are AwesomeSSDs are Awesome
SSDs are Awesome
 
Rails 5 subjective overview
Rails 5 subjective overviewRails 5 subjective overview
Rails 5 subjective overview
 
JPA 2.1 on Payara Server
JPA 2.1 on Payara ServerJPA 2.1 on Payara Server
JPA 2.1 on Payara Server
 
Taking Micronaut out for a spin
Taking Micronaut out for a spinTaking Micronaut out for a spin
Taking Micronaut out for a spin
 
Apache Jackrabbit
Apache JackrabbitApache Jackrabbit
Apache Jackrabbit
 
Scala + Akka + ning/async-http-client - Vancouver Scala meetup February 2015
Scala + Akka + ning/async-http-client - Vancouver Scala meetup February 2015Scala + Akka + ning/async-http-client - Vancouver Scala meetup February 2015
Scala + Akka + ning/async-http-client - Vancouver Scala meetup February 2015
 

Viewers also liked

241 Maddox Bc2.Indd
241 Maddox Bc2.Indd241 Maddox Bc2.Indd
241 Maddox Bc2.Indd
lmaddox
 
Models Ink Consortium Intro C1
Models Ink Consortium Intro C1Models Ink Consortium Intro C1
Models Ink Consortium Intro C1
wacotao
 
Skmbt C20309052614021
Skmbt C20309052614021Skmbt C20309052614021
Skmbt C20309052614021
guest19a3bac
 
Viatge Estudis
Viatge EstudisViatge Estudis
Viatge Estudis
imagenius
 
Victoria Tattersdill - Young Risk Professional interview
Victoria Tattersdill -  Young Risk Professional interviewVictoria Tattersdill -  Young Risk Professional interview
Victoria Tattersdill - Young Risk Professional interview
FERMA
 
Ethnoomusicology v 55 n 3 2011
Ethnoomusicology v 55 n 3  2011Ethnoomusicology v 55 n 3  2011
Ethnoomusicology v 55 n 3 2011
MUSEO ETNOLOXICO
 
Проверка знаний
Проверка знанийПроверка знаний
Проверка знаний
Marina Kalinkina
 
O ribeiro na terra do viño
O ribeiro na terra do viñoO ribeiro na terra do viño
O ribeiro na terra do viño
MUSEO ETNOLOXICO
 

Viewers also liked (20)

Filet Mignon
Filet MignonFilet Mignon
Filet Mignon
 
Oir cantar o galo duas veces
Oir cantar o galo duas vecesOir cantar o galo duas veces
Oir cantar o galo duas veces
 
Resume
ResumeResume
Resume
 
241 Maddox Bc2.Indd
241 Maddox Bc2.Indd241 Maddox Bc2.Indd
241 Maddox Bc2.Indd
 
Models Ink Consortium Intro C1
Models Ink Consortium Intro C1Models Ink Consortium Intro C1
Models Ink Consortium Intro C1
 
Oooooooooooo
OoooooooooooOooooooooooo
Oooooooooooo
 
Compensation Plan
Compensation PlanCompensation Plan
Compensation Plan
 
#2
#2#2
#2
 
Bad Body Noises
Bad Body NoisesBad Body Noises
Bad Body Noises
 
-=--
-=---=--
-=--
 
English Central User Guide
English Central  User  GuideEnglish Central  User  Guide
English Central User Guide
 
5 myths whitepaper
5 myths whitepaper5 myths whitepaper
5 myths whitepaper
 
Skmbt C20309052614021
Skmbt C20309052614021Skmbt C20309052614021
Skmbt C20309052614021
 
Action Asia May/June 09
Action Asia May/June 09Action Asia May/June 09
Action Asia May/June 09
 
Введение в маркетинг клиентских баз данных
Введение в маркетинг клиентских баз данныхВведение в маркетинг клиентских баз данных
Введение в маркетинг клиентских баз данных
 
Viatge Estudis
Viatge EstudisViatge Estudis
Viatge Estudis
 
Victoria Tattersdill - Young Risk Professional interview
Victoria Tattersdill -  Young Risk Professional interviewVictoria Tattersdill -  Young Risk Professional interview
Victoria Tattersdill - Young Risk Professional interview
 
Ethnoomusicology v 55 n 3 2011
Ethnoomusicology v 55 n 3  2011Ethnoomusicology v 55 n 3  2011
Ethnoomusicology v 55 n 3 2011
 
Проверка знаний
Проверка знанийПроверка знаний
Проверка знаний
 
O ribeiro na terra do viño
O ribeiro na terra do viñoO ribeiro na terra do viño
O ribeiro na terra do viño
 

Similar to Java to scala

Polyglot Plugin Programming
Polyglot Plugin ProgrammingPolyglot Plugin Programming
Polyglot Plugin Programming
Atlassian
 
Scala for android
Scala for androidScala for android
Scala for android
Tack Mobile
 
An Introduction to Scala
An Introduction to ScalaAn Introduction to Scala
An Introduction to Scala
Brent Lemons
 
Functional Scala 2022 - scalajs Alexis.pdf
Functional Scala 2022 - scalajs Alexis.pdfFunctional Scala 2022 - scalajs Alexis.pdf
Functional Scala 2022 - scalajs Alexis.pdf
ssusercd195b
 

Similar to Java to scala (20)

LSUG: How we (mostly) moved from Java to Scala
LSUG: How we (mostly) moved from Java to ScalaLSUG: How we (mostly) moved from Java to Scala
LSUG: How we (mostly) moved from Java to Scala
 
Java to Scala: Why & How
Java to Scala: Why & HowJava to Scala: Why & How
Java to Scala: Why & How
 
From java to scala at crowd mix
From java to scala at crowd mixFrom java to scala at crowd mix
From java to scala at crowd mix
 
Java basics at Lara Technologies
Java basics at Lara TechnologiesJava basics at Lara Technologies
Java basics at Lara Technologies
 
Polyglot Plugin Programming
Polyglot Plugin ProgrammingPolyglot Plugin Programming
Polyglot Plugin Programming
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Introduction to Scala language
Introduction to Scala languageIntroduction to Scala language
Introduction to Scala language
 
Java to scala
Java to scalaJava to scala
Java to scala
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Polyglot Grails
Polyglot GrailsPolyglot Grails
Polyglot Grails
 
Scala adoption by enterprises
Scala adoption by enterprisesScala adoption by enterprises
Scala adoption by enterprises
 
PALASH SL GUPTA
PALASH SL GUPTAPALASH SL GUPTA
PALASH SL GUPTA
 
Scala Native: Ahead of Time
Scala Native: Ahead of TimeScala Native: Ahead of Time
Scala Native: Ahead of Time
 
Java introduction by lara technologies
Java introduction by lara technologiesJava introduction by lara technologies
Java introduction by lara technologies
 
Scala final ppt vinay
Scala final ppt vinayScala final ppt vinay
Scala final ppt vinay
 
Scala for android
Scala for androidScala for android
Scala for android
 
An Introduction to Scala
An Introduction to ScalaAn Introduction to Scala
An Introduction to Scala
 
AWS Lambda How to upload and load gems fast
AWS Lambda How to upload and load gems fastAWS Lambda How to upload and load gems fast
AWS Lambda How to upload and load gems fast
 
Experience Converting from Ruby to Scala
Experience Converting from Ruby to ScalaExperience Converting from Ruby to Scala
Experience Converting from Ruby to Scala
 
Functional Scala 2022 - scalajs Alexis.pdf
Functional Scala 2022 - scalajs Alexis.pdfFunctional Scala 2022 - scalajs Alexis.pdf
Functional Scala 2022 - scalajs Alexis.pdf
 

More from GiltTech (9)

Riak a successful failure
Riak   a successful failureRiak   a successful failure
Riak a successful failure
 
Real World Cassandra
Real World CassandraReal World Cassandra
Real World Cassandra
 
Gotszling mogo db-membase
Gotszling mogo db-membaseGotszling mogo db-membase
Gotszling mogo db-membase
 
Couchdb at AMEX
Couchdb at AMEXCouchdb at AMEX
Couchdb at AMEX
 
Scala for the web Lightning Talk
Scala for the web Lightning TalkScala for the web Lightning Talk
Scala for the web Lightning Talk
 
Clojure Lightning Talk
Clojure Lightning TalkClojure Lightning Talk
Clojure Lightning Talk
 
CoffeeScript Lightning Talk
CoffeeScript Lightning TalkCoffeeScript Lightning Talk
CoffeeScript Lightning Talk
 
Erlang Lightning Talk
Erlang Lightning TalkErlang Lightning Talk
Erlang Lightning Talk
 
Groovy and Grails
Groovy and GrailsGroovy and Grails
Groovy and Grails
 

Recently uploaded

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

Java to scala

  • 1. (mostly) How we moved from ^ Java to Scala Graham Tackley guardian.co.uk
  • 2. History • Java shop since 2006 • guardian.co.uk: java + spring + velocity + hibernate + oracle • ~100k lines production java code (and ~35k xml...)
  • 3. Content API • Provide API to access all of our website content • Limited beta released early 2009 • Started implementation of final version late 2009 • Live May 2010: http://content.guardianapis.com
  • 4. Content API (demo of http://content.guardianapis.com)
  • 5. November 2009 • Started new Content API implementation • java + guice + guice servlets + apache solr
  • 6. November 2009 • A few people had played with scala • No production scala code
  • 7. January 2010 • Comprehensive integration tests were very important to us • Started writing our integration tests in Scala with the awesome ScalaTest • Already a maven project, so mixed scala- java support easy with maven-scala-plugin demo: mavan-scala-plugin, ScalaTest
  • 9. January 2010 • A fair bit of our test code was java- without-semicolons as we learnt about Scala...
  • 11. February 2010 • ... despite that we loved it so much that after a month we decided to convert the whole app to Scala • scala + guice + guice servlets + apache solr
  • 12. Our top 5 things we loved about scala on day one
  • 13. 1. Sensible Class Constructors =>
  • 14. 1. Sensible Class Constructors
  • 15. 2. Type inference / val & var ArrayList<String> myList = new ArrayList<String>(); => val myList = new ArrayList[String]
  • 16. 3. No source file naming constraints • Don’t need to be named after package & class name like java • So multiple classes are allowed in a single file e.g. ResponseRenderer.scala
  • 17. 4. REPL (console) • run “scala” for a scala shell • awesome for experimentation
  • 18. 5. Same tools, libs, deployment & runtime characteristics as Java • We still use IntelliJ (with the scala plugin) • A scala war file is just a war file • All the experience of running jvm in production still applies • Can still use java libraries e.g. GuiceServletConfig.scala, XmlFormatter.scala
  • 19. Our top 5 things we loved about scala on day one SUMMARY: Scala is great even if you only use it as a more concise java (java-without-semicolons™); for us this was a great way to start.
  • 20. July 2010 • Switched from maven to simple-build-tool • Mainly for incremental compilation • ~ test-quick and ~ prepare-webapp also invaluable
  • 22. some early code... it took us a while to realise that most of the loops we wrote in Java were actually “map” or “flatMap”
  • 23. ... ended up as it took us a while to realise that most of the loops we wrote in Java were actually “map” or “flatMap”
  • 24. Summary • Migration path from Java relatively smooth • Take it easy, and don’t fear java-without- semicolons in the early days • An incremental embrace of Scala features worked really well for us • Hide the Java yuk with implicit conversions
  • 25. • http://content.guardianapis.com • http://www.guardian.co.uk/open-platform • http://github.com/guardian/open-platform- content-api-scala-client graham.tackley@guardian.co.uk ■ @tackers

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. Demo\n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n