(partly)

                           How we moved from
                                    ^

                            ...
History

                    • Java shop since 2006
                    • guardian.co.uk: java + spring + velocity +
     ...
Content API
                    • Provide API to access all of our website
                           content
            ...
December 2009


                    • Started new Content API implementation
                    • java + guice + guice se...
December 2009


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


...
January 2010
                    • Comprehensive integration tests were very
                           important to us
  ...
January 2010




Thursday, 7 October 2010
January 2010


                    • A fair bit of our test code was java-
                           without-semicolons a...
January 2010




Thursday, 7 October 2010
February 2010

                    • ... despite that we loved it so much that
                           after a month we...
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...
Feb-Oct 2010


                • Much learning within the team as to how to
                           write concise, read...
Option
             or How we learned to stop worrying and love the Option

                 We’d read “don’t use nulls, u...
Option
             or How we learned to stop worrying and love the Option

                                WEEK THREE



...
map & flatMap




       it took us a while to realise that most of the loops we
            wrote in Java were actually “m...
Java Libraries
                            Content API extensively uses Solr/J,
                           which is good b...
Thursday, 7 October 2010
Summary
                    • Migration path from Java relatively smooth
                    • Take it easy, and don’t fea...
• http://content.guardianapis.com
                • http://www.guardian.co.uk/open-platform
                • http://githu...
Upcoming SlideShare
Loading in...5
×

Java to scala

1,520

Published on

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,520
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Transcript of "Java to scala"

  1. 1. (partly) How we moved from ^ Java to Scala Graham Tackley guardian.co.uk Thursday, 7 October 2010
  2. 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. 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. 4. December 2009 • Started new Content API implementation • java + guice + guice servlets + apache solr Thursday, 7 October 2010
  5. 5. December 2009 • A few people had played with scala • No production scala code Thursday, 7 October 2010
  6. 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
  7. 7. January 2010 Thursday, 7 October 2010
  8. 8. January 2010 • A fair bit of our test code was java- without-semicolons as we learnt about Scala... Thursday, 7 October 2010
  9. 9. January 2010 Thursday, 7 October 2010
  10. 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. 11. February 2010 Still some very java-like code... Thursday, 7 October 2010
  12. 12. February 2010 ... immediate win with non-IDE generated constructors ... Thursday, 7 October 2010
  13. 13. February 2010 ... and some things much more readable than Java Thursday, 7 October 2010
  14. 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. 15. Feb-Oct 2010 • Much learning within the team as to how to write concise, readable Scala code Thursday, 7 October 2010
  16. 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. 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. 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. 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
  20. 20. Thursday, 7 October 2010
  21. 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. 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

×