• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Scala Presentation Work
 

Scala Presentation Work

on

  • 3,885 views

 

Statistics

Views

Total Views
3,885
Views on SlideShare
3,729
Embed Views
156

Actions

Likes
3
Downloads
0
Comments
1

3 Embeds 156

http://skillsmatter.com 107
http://smash 37
http://www.slideshare.net 12

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • watch this presentation

    http://skillsmatter.com/podcast/java-jee/phil-miller-ease-into-scala-web-development/zx-489
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Scala Presentation Work Scala Presentation Work Presentation Transcript

    • Ease into Scala Web Development Phil Miller
    • Speaker Qualifications
      • Google Wave webapp in Scala / Spring
      • 10 years in Java web dev
    • Ease into Scala Web Development
      • Introduction to Scala
      • Decision Matrix
      • A Scala/Spring webapp recipe
    • Introduction to Scala
      • JVM language, low barrier to entry
      • Created by Martin Odersky 2001
      • Static Typing with Type inference
      • Expressive, compact
      • Encourages functional style
      • Object-Orientated – everything an object, traits
      • Concurrency via Actors
      • IDE support and a REPL
      • Scala frameworks + a gazillion Java ones
    • Introduction to Scala Variable Value
      • Static Typing with Type inference
      • Prove absence of some runtime errors
      • Removes fear of refactoring
      • Performance optimizations
      var foo: String ”bar” :String var foo 1 :Integer
    • 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
      • Encapsulation protects source of List[Account]
    • def getAccounts(fn: Account => Boolean) = { val accounts = ... // gets a List[Account] accounts filter fn }
      • Static Typing with Type inference
      • Expressive and compact syntax
      • Encourages a functional style
      Introduction to Scala
    • def getAccounts(fn: Account => Boolean) = { val accounts = ... // gets a List[Account] accounts filter fn }
      • Static Typing with Type inference
      • Expressive and compact syntax
      • Encourages a functional style
      Introduction to Scala
    • def getAccounts( fn: Account => Boolean ) = { val accounts = ... // gets a List[Account] accounts filter fn }
      • Static Typing with Type inference
      • Expressive and compact syntax
      • Encourages a functional style
      Introduction to Scala
    • def getAccounts( fn: Account => Boolean ) = { val accounts = ... // gets a List[Account] accounts filter fn }
      • Object-Orientated – everything an object , traits
      Introduction to Scala
    • val curried = (as: List[Account]) => (fn: Account => Boolean) => as filter fn
      • Encourages a functional style
      • Expressiveness and comprehension indirectly proportional
      Introduction to Scala
    • Scala pain
      • Type System intimidating
      • Implicit conversions & parameters
      • IDE support not equal to Java yet
      • Compile times
      • Java 3 rd party API interop – i.e. Hibernate @OneToMany
      • Readability
      • You won't want to write Java again
    • 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
    • Decision Matrix: Properties of a Language
      • Writability: expressive , compactness
      • Readability: comprehension , maintainable
      • Tooling & IDEs
      • Testability
      • Performance
      • Portability
      • Frameworks
      • http://gist.github.com/325374
    • Decision Matrix: Properties of a Language Java Scala Writability Readability IDE support
    • IOU Example webapp
      • Spring 3.0
      • Maven
      • Junit
      • Specs
      • Scala
      • http://github.com/idrop/scala-spring
      Html / jQuery Spring 3.0 MVC Container MyController MyService Storage: Actor
    • Best path into Scala web dev
      • Webapp using Scala, Spring, Maven
      • Same deployment unit as Java
      • Choose something ancillary to your big project
      • Don't give up over IDE support
      • Dojos with REPL
    • Java Spring Maven webapp => Scala
      • Existin g passing suite of unit tests
      • Copy src/main/java & src/test/java to src/main/scala & src/test/scala
      • Rename copied java files to *.scala
      • Scala-ify pom.xml
      • Don't use an IDE yet!
      • Scala-ify src/main/scala first
      • New suite of Scala tests pass
    • Some alternatives to Scala / Spring
      • Java 7
      • Lift
      • Akka
      • C#
    • References
      • Decision Matrix: http://gist.github.com/325374
      • Scala-Spring: http://github.com/idrop/scala-spring
      • Simon Peyton-Jones on funtional programming: http://tinyurl.com/se-radio-haskell
      • Akka Tutorial: http://jonasboner.com/2010/01/04/introducing-akka.html
      • Play! http://www.playframework.org/documentation/1.1-trunk/scala
      • Lift: http://liftweb.net/
      • Scala for Java Refugees: http://www.codecommit.com/blog/scala/roundup-scala-for-java-refugees
      • Daily Scala: http://daily-scala.blogspot.com/
      • Coding Dojos: http://www.codingdojo.org/
    • 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
      • Expressive and compact syntax
      • Encourages a functional style
    • Evolving to a Functional Style
      • Scala Proficiency Warm-up
      • Level of Proficiency in Scala Questionnaire
      • Use Scala REPL to determine proportion of responses at each proficiency level
      Grpah here
    • 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)); }
    • 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'
    • public void editAccounts(List<Account> accounts) { .......... } public Account editAccount(Account a) { .......... }
      • Void methods – Simon Peyton-Jones
      Becoming 'functional'
      • Way off pure functional concepts like lazy evaluation, monads
      Becoming 'functional'
    • Why Scala from Java?
      • Low barrier to entry
      • JVM
      • Type inference & Type safety
      • Expressive datastructures, pattern matching
      • Correctness in concurrency
      • REPL
      • Traits
    • 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”
    • 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