SlideShare une entreprise Scribd logo
1  sur  22
(partly)

                           How we moved from
                                    ^

                              Java to Scala
                                Graham Tackley
                                guardian.co.uk




Thursday, 7 October 2010
History

                    • Java shop since 2006
                    • guardian.co.uk: java + spring + velocity +
                           hibernate + oracle
                    • ~100k lines production java code (and
                           ~35k xml...)



Thursday, 7 October 2010
Content API
                    • Provide API to access all of our website
                           content
                    • Limited beta released early 2009
                    • Started implementation of final version late
                           2009
                    • Live April 2010:
                           http://content.guardianapis.com


Thursday, 7 October 2010
December 2009


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


Thursday, 7 October 2010
December 2009


                    • A few people had played with scala
                    • No production scala code


Thursday, 7 October 2010
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



Thursday, 7 October 2010
January 2010




Thursday, 7 October 2010
January 2010


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




Thursday, 7 October 2010
January 2010




Thursday, 7 October 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


Thursday, 7 October 2010
February 2010




                           Still some very java-like code...
Thursday, 7 October 2010
February 2010




  ... immediate win with non-IDE generated constructors ...
Thursday, 7 October 2010
February 2010




               ... and some things much more readable than Java
Thursday, 7 October 2010
July 2010

                • Switched from maven to simple-build-tool
                • Mainly for incremental compilation
                • ~ test-quick and ~ prepare-webapp also
                           invaluable




Thursday, 7 October 2010
Feb-Oct 2010


                • Much learning within the team as to how to
                           write concise, readable Scala code




Thursday, 7 October 2010
Option
             or How we learned to stop worrying and love the Option

                 We’d read “don’t use nulls, use Option instead”

                                     DAY ONE
                             s/x == null/x.isDefined

                                    DAY THREE
                           x match {
                             case None => ...
                             case Some(value) => ...
                           }
Thursday, 7 October 2010
Option
             or How we learned to stop worrying and love the Option

                                WEEK THREE




                                   TODAY



 We now think of Options as lists with zero or one entries

Thursday, 7 October 2010
map & flatMap




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


Thursday, 7 October 2010
Java Libraries
                            Content API extensively uses Solr/J,
                           which is good but returns loads of nulls


            And don’t get me started on HttpServletRequest...


              We used implicit conversions to hide the Java yuk



Thursday, 7 October 2010
Thursday, 7 October 2010
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

Thursday, 7 October 2010
• http://content.guardianapis.com
                • http://www.guardian.co.uk/open-platform
                • http://github.com/guardian/open-platform-
                           content-api-scala-client
                • http://blog.tackley.net
                                graham.tackley@guardian.co.uk
Thursday, 7 October 2010

Contenu connexe

Similaire à Java to scala

UCLUG TorqueBox - 03/08/2011
UCLUG TorqueBox - 03/08/2011UCLUG TorqueBox - 03/08/2011
UCLUG TorqueBox - 03/08/2011
tobiascrawley
 
2011 JavaOne Apache TomEE Java EE 6 Web Profile
2011 JavaOne Apache TomEE Java EE 6 Web Profile2011 JavaOne Apache TomEE Java EE 6 Web Profile
2011 JavaOne Apache TomEE Java EE 6 Web Profile
David Blevins
 
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume LaforgeGaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Guillaume Laforge
 
Open End To End Js Stack
Open End To End Js StackOpen End To End Js Stack
Open End To End Js Stack
Skills Matter
 
Oo java script class construction
Oo java script class constructionOo java script class construction
Oo java script class construction
Ken Collins
 
Java EE Servlet JSP Tutorial- Cookbook 1
Java EE Servlet JSP Tutorial- Cookbook 1Java EE Servlet JSP Tutorial- Cookbook 1
Java EE Servlet JSP Tutorial- Cookbook 1
billdigman
 

Similaire à Java to scala (20)

Java to scala
Java to scalaJava to scala
Java to scala
 
Java to Scala: Why & How
Java to Scala: Why & HowJava to Scala: Why & How
Java to Scala: Why & How
 
Java to scala
Java to scalaJava to scala
Java to scala
 
Red Dirt Ruby Conference
Red Dirt Ruby ConferenceRed Dirt Ruby Conference
Red Dirt Ruby Conference
 
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
 
Railsconf 2010
Railsconf 2010Railsconf 2010
Railsconf 2010
 
UCLUG TorqueBox - 03/08/2011
UCLUG TorqueBox - 03/08/2011UCLUG TorqueBox - 03/08/2011
UCLUG TorqueBox - 03/08/2011
 
2011 June - Singapore GTUG presentation. App Engine program update + intro to Go
2011 June - Singapore GTUG presentation. App Engine program update + intro to Go2011 June - Singapore GTUG presentation. App Engine program update + intro to Go
2011 June - Singapore GTUG presentation. App Engine program update + intro to Go
 
App Engine Meetup
App Engine MeetupApp Engine Meetup
App Engine Meetup
 
Tomas Grails
Tomas GrailsTomas Grails
Tomas Grails
 
JRuby in The Enterprise
JRuby in The EnterpriseJRuby in The Enterprise
JRuby in The Enterprise
 
Java basics at Lara Technologies
Java basics at Lara TechnologiesJava basics at Lara Technologies
Java basics at Lara Technologies
 
2011 JavaOne Apache TomEE Java EE 6 Web Profile
2011 JavaOne Apache TomEE Java EE 6 Web Profile2011 JavaOne Apache TomEE Java EE 6 Web Profile
2011 JavaOne Apache TomEE Java EE 6 Web Profile
 
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume LaforgeGaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
 
Bootstrapping a simple enterprise application with Java EE successor, Jakarta...
Bootstrapping a simple enterprise application with Java EE successor, Jakarta...Bootstrapping a simple enterprise application with Java EE successor, Jakarta...
Bootstrapping a simple enterprise application with Java EE successor, Jakarta...
 
Lucene, Solr and java 9 - opportunities and challenges
Lucene, Solr and java 9 - opportunities and challengesLucene, Solr and java 9 - opportunities and challenges
Lucene, Solr and java 9 - opportunities and challenges
 
ACCU 2013 Taking Scala into the Enterpise
ACCU 2013 Taking Scala into the EnterpiseACCU 2013 Taking Scala into the Enterpise
ACCU 2013 Taking Scala into the Enterpise
 
Open End To End Js Stack
Open End To End Js StackOpen End To End Js Stack
Open End To End Js Stack
 
Oo java script class construction
Oo java script class constructionOo java script class construction
Oo java script class construction
 
Java EE Servlet JSP Tutorial- Cookbook 1
Java EE Servlet JSP Tutorial- Cookbook 1Java EE Servlet JSP Tutorial- Cookbook 1
Java EE Servlet JSP Tutorial- Cookbook 1
 

Plus de Skills Matter

Oscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheimOscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheim
Skills Matter
 
Russ miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-diveRuss miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-dive
Skills Matter
 
I went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_tI went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_t
Skills Matter
 

Plus de Skills Matter (20)

5 things cucumber is bad at by Richard Lawrence
5 things cucumber is bad at by Richard Lawrence5 things cucumber is bad at by Richard Lawrence
5 things cucumber is bad at by Richard Lawrence
 
Patterns for slick database applications
Patterns for slick database applicationsPatterns for slick database applications
Patterns for slick database applications
 
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvmScala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
 
Oscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheimOscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheim
 
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
 
Cukeup nyc ian dees on elixir, erlang, and cucumberl
Cukeup nyc ian dees on elixir, erlang, and cucumberlCukeup nyc ian dees on elixir, erlang, and cucumberl
Cukeup nyc ian dees on elixir, erlang, and cucumberl
 
Cukeup nyc peter bell on getting started with cucumber.js
Cukeup nyc peter bell on getting started with cucumber.jsCukeup nyc peter bell on getting started with cucumber.js
Cukeup nyc peter bell on getting started with cucumber.js
 
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
 
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
 
Progressive f# tutorials nyc don syme on keynote f# in the open source world
Progressive f# tutorials nyc don syme on keynote f# in the open source worldProgressive f# tutorials nyc don syme on keynote f# in the open source world
Progressive f# tutorials nyc don syme on keynote f# in the open source world
 
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
 
Dmitry mozorov on code quotations code as-data for f#
Dmitry mozorov on code quotations code as-data for f#Dmitry mozorov on code quotations code as-data for f#
Dmitry mozorov on code quotations code as-data for f#
 
A poet's guide_to_acceptance_testing
A poet's guide_to_acceptance_testingA poet's guide_to_acceptance_testing
A poet's guide_to_acceptance_testing
 
Russ miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-diveRuss miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-dive
 
Serendipity-neo4j
Serendipity-neo4jSerendipity-neo4j
Serendipity-neo4j
 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelism
 
Plug 20110217
Plug   20110217Plug   20110217
Plug 20110217
 
Lug presentation
Lug presentationLug presentation
Lug presentation
 
I went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_tI went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_t
 
Plug saiku
Plug   saikuPlug   saiku
Plug saiku
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
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
 

Dernier (20)

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
 
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...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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
 
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
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
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
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
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
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
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
 

Java to scala

  • 1. (partly) How we moved from ^ Java to Scala Graham Tackley guardian.co.uk Thursday, 7 October 2010
  • 2. History • Java shop since 2006 • guardian.co.uk: java + spring + velocity + hibernate + oracle • ~100k lines production java code (and ~35k xml...) Thursday, 7 October 2010
  • 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 April 2010: http://content.guardianapis.com Thursday, 7 October 2010
  • 4. December 2009 • Started new Content API implementation • java + guice + guice servlets + apache solr Thursday, 7 October 2010
  • 5. December 2009 • A few people had played with scala • No production scala code Thursday, 7 October 2010
  • 6. 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 Thursday, 7 October 2010
  • 8. January 2010 • A fair bit of our test code was java- without-semicolons as we learnt about Scala... Thursday, 7 October 2010
  • 10. 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 Thursday, 7 October 2010
  • 11. February 2010 Still some very java-like code... Thursday, 7 October 2010
  • 12. February 2010 ... immediate win with non-IDE generated constructors ... Thursday, 7 October 2010
  • 13. February 2010 ... and some things much more readable than Java Thursday, 7 October 2010
  • 14. July 2010 • Switched from maven to simple-build-tool • Mainly for incremental compilation • ~ test-quick and ~ prepare-webapp also invaluable Thursday, 7 October 2010
  • 15. Feb-Oct 2010 • Much learning within the team as to how to write concise, readable Scala code Thursday, 7 October 2010
  • 16. Option or How we learned to stop worrying and love the Option We’d read “don’t use nulls, use Option instead” DAY ONE s/x == null/x.isDefined DAY THREE x match { case None => ... case Some(value) => ... } Thursday, 7 October 2010
  • 17. Option or How we learned to stop worrying and love the Option WEEK THREE TODAY We now think of Options as lists with zero or one entries Thursday, 7 October 2010
  • 18. map & flatMap it took us a while to realise that most of the loops we wrote in Java were actually “map” or “flatMap” Thursday, 7 October 2010
  • 19. Java Libraries Content API extensively uses Solr/J, which is good but returns loads of nulls And don’t get me started on HttpServletRequest... We used implicit conversions to hide the Java yuk Thursday, 7 October 2010
  • 21. 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 Thursday, 7 October 2010
  • 22. • http://content.guardianapis.com • http://www.guardian.co.uk/open-platform • http://github.com/guardian/open-platform- content-api-scala-client • http://blog.tackley.net graham.tackley@guardian.co.uk Thursday, 7 October 2010