Your SlideShare is downloading. ×
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Scala Presentation Work
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Scala Presentation Work

3,106

Published on

Published in: Technology
1 Comment
3 Likes
Statistics
Notes
  • watch this presentation

    http://skillsmatter.com/podcast/java-jee/phil-miller-ease-into-scala-web-development/zx-489
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
3,106
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
1
Likes
3
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Ease into Scala Web Development Phil Miller
  • 2. Speaker Qualifications
    • Google Wave webapp in Scala / Spring
    • 3. 10 years in Java web dev
  • 4. Ease into Scala Web Development
    • Introduction to Scala
    • 5. Decision Matrix
    • 6. A Scala/Spring webapp recipe
  • 7. Introduction to Scala
    • JVM language, low barrier to entry
    • 8. Created by Martin Odersky 2001
    • 9. Static Typing with Type inference
    • 10. Expressive, compact
    • 11. Encourages functional style
    • 12. Object-Orientated – everything an object, traits
    • 13. Concurrency via Actors
    • 14. IDE support and a REPL
    • 15. Scala frameworks + a gazillion Java ones
  • 16. Introduction to Scala Variable Value
    • Static Typing with Type inference
    • 17. Prove absence of some runtime errors
    • 18. Removes fear of refactoring
    • 19. Performance optimizations
    var foo: String ”bar” :String var foo 1 :Integer
  • 20. def getAccounts(fn: Account => Boolean) = { val accounts = ... // gets a List[Account] accounts filter fn } Introduction to Scala
    • Provides a List of Accounts, based on a Predicate Function
    • 21. Encapsulation protects source of List[Account]
  • 22. def getAccounts(fn: Account => Boolean) = { val accounts = ... // gets a List[Account] accounts filter fn }
    • Static Typing with Type inference
    • 23. Expressive and compact syntax
    • 24. Encourages a functional style
    Introduction to Scala
  • 25. def getAccounts(fn: Account => Boolean) = { val accounts = ... // gets a List[Account] accounts filter fn }
    • Static Typing with Type inference
    • 26. Expressive and compact syntax
    • 27. Encourages a functional style
    Introduction to Scala
  • 28. def getAccounts( fn: Account => Boolean ) = { val accounts = ... // gets a List[Account] accounts filter fn }
    • Static Typing with Type inference
    • 29. Expressive and compact syntax
    • 30. Encourages a functional style
    Introduction to Scala
  • 31. def getAccounts( fn: Account => Boolean ) = { val accounts = ... // gets a List[Account] accounts filter fn }
    • Object-Orientated – everything an object , traits
    Introduction to Scala
  • 32. val curried = (as: List[Account]) => (fn: Account => Boolean) => as filter fn
    • Encourages a functional style
    • 33. Expressiveness and comprehension indirectly proportional
    Introduction to Scala
  • 34. Scala pain
    • Type System intimidating
    • 35. Implicit conversions & parameters
    • 36. IDE support not equal to Java yet
    • 37. Compile times
    • 38. Java 3 rd party API interop – i.e. Hibernate @OneToMany
    • 39. Readability
    • 40. You won't want to write Java again
  • 41. Reality check
      ” ..Is there enough value choosing Scala over Java? You would have to determine that for yourself. It is a very challenging business case to switch languages. Are the benefits of switching from Java to Scala so great and so provable that it makes conclusive sense to switch? For some perhaps, but for most large enterprises that drive the JVM stack blueprint, not likely.” http://enfranchisedmind.com/blog/posts/what-killed-lisp-could-kill-haskell-as-well/#comment-37144
  • 42. Decision Matrix: Properties of a Language
    • Writability: expressive , compactness
    • 43. Readability: comprehension , maintainable
    • 44. Tooling & IDEs
    • 45. Testability
    • 46. Performance
    • 47. Portability
    • 48. Frameworks
    • 49. http://gist.github.com/325374
  • 50. Decision Matrix: Properties of a Language Java Scala Writability Readability IDE support
  • 51. IOU Example webapp Html / jQuery Spring 3.0 MVC Container MyController MyService Storage: Actor
  • 57. Best path into Scala web dev
    • Webapp using Scala, Spring, Maven
    • 58. Same deployment unit as Java
    • 59. Choose something ancillary to your big project
    • 60. Don't give up over IDE support
    • 61. Dojos with REPL
  • 62. Java Spring Maven webapp => Scala
    • Existin g passing suite of unit tests
    • 63. Copy src/main/java & src/test/java to src/main/scala & src/test/scala
    • 64. Rename copied java files to *.scala
    • 65. Scala-ify pom.xml
    • 66. Don't use an IDE yet!
    • 67. Scala-ify src/main/scala first
    • 68. New suite of Scala tests pass
  • 69. Some alternatives to Scala / Spring
  • 73. References
    • Decision Matrix: http://gist.github.com/325374
    • 74. Scala-Spring: http://github.com/idrop/scala-spring
    • 75. Simon Peyton-Jones on funtional programming: http://tinyurl.com/se-radio-haskell
    • 76. Akka Tutorial: http://jonasboner.com/2010/01/04/introducing-akka.html
    • 77. Play! http://www.playframework.org/documentation/1.1-trunk/scala
    • 78. Lift: http://liftweb.net/
    • 79. Scala for Java Refugees: http://www.codecommit.com/blog/scala/roundup-scala-for-java-refugees
    • 80. Daily Scala: http://daily-scala.blogspot.com/
    • 81. Coding Dojos: http://www.codingdojo.org/
  • 82. public List<Account> getActiveAccounts() { List<Account> accounts = ..... List<Account> list = new ArrayList<Account>(); for (Account account : accounts) { if (account.isActive()) list .add(account); } return list ; } Introduction to Scala
    • Static Typing with Type inference
    • 83. Expressive and compact syntax
    • 84. Encourages a functional style
  • 85. Evolving to a Functional Style
  • 86.
      Scala Proficiency Warm-up
    • Level of Proficiency in Scala Questionnaire
    • 87. Use Scala REPL to determine proportion of responses at each proficiency level
    Grpah here
  • 88. Becoming 'functional' /** * all accounts for this user, given user id */ public List<Account> getAccounts(String id) { return accounts.get(id); } public List <Account> getAccounts(String id) { return Collections.unmodifiableList (accounts.get(id)); }
  • 89. private Predicate<Account> active = new Predicate<Account>() { public boolean apply(Account a) { return a.isActive(); } } public List<Account> getAccounts( String id, Predicate<Account> filter ) { List<Account> accounts = getAccounts(id); Iterable<Account> filter =Iterables.filter(accounts, filter ); return Lists.newArrayList(filter); }
    • Google Collections
    Becoming 'functional'
  • 90. public void editAccounts(List<Account> accounts) { .......... } public Account editAccount(Account a) { .......... }
    • Void methods – Simon Peyton-Jones
    Becoming 'functional'
  • 91.
    • Way off pure functional concepts like lazy evaluation, monads
    Becoming 'functional'
  • 92. Why Scala from Java?
    • Low barrier to entry
    • 93. JVM
    • 94. Type inference & Type safety
    • 95. Expressive datastructures, pattern matching
    • 96. Correctness in concurrency
    • 97. REPL
    • 98. Traits
  • 99. Typing Dynamic Typing Static Typing Strong typing 1 . Groovy, Jruby, Javascript 2 . Java, Scala, C# Weak typing 3 . Perl C Variable Value var a: String ” 1” :String var a ” 1”
  • 100. Scala v. others Scala Groovy Ruby Clojure C# Low barrier to entry from Java JVM Type inference Type safety Expressive Correctness in concurrency REPL Traits

×