Yes scala can!
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Yes scala can!

on

  • 4,393 views

The presentation I had for Stockholm Knowledge Network. For demo code please refer to https://github.com/anderseriksson/yesscalacan

The presentation I had for Stockholm Knowledge Network. For demo code please refer to https://github.com/anderseriksson/yesscalacan

Statistics

Views

Total Views
4,393
Views on SlideShare
4,389
Embed Views
4

Actions

Likes
8
Downloads
67
Comments
0

2 Embeds 4

https://twitter.com 3
http://us-w1.rockmelt.com 1

Accessibility

Upload Details

Uploaded via as Adobe PDF

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
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Yes scala can! Presentation Transcript

  • 1. The place for sharing ideas and knowledge
  • 2. Yes Scala Can! Amir Moulavi Anders Eriksson @mamirm @anders_erikssonamir.moulavi@jayway.com anders.eriksson@jayway.com Jayway Stockholm 2012-05-30
  • 3. Why● Weve found Scala and like it!● We would like to broaden the interest amongst Java developers.● Hopefully this presentation will inspire you to look more into Scala!
  • 4. Agenda● History and Background● Scala vs. Java: Similarities and Differences● Quick Journey to Scala● Book Raffle!
  • 5. It has been a revolution!
  • 6. Little history and background● 2001: ○ Design of Scala started ■ Goals: merge functional + object oriented paradigms● 2004: ○ First public release on JVM
  • 7. Little history and background● 2006: ○ major rewrite (v 2.0)● 2011: ○ Company Typesafe is funded for professional support
  • 8. Java vs. Scala (similarities)● Runs on JVM● Statically typed● Object oriented● Garbage collected
  • 9. Java vs. Scala (differences)● Pure object orientation● Functional paradigm● Pattern matching● Mixin composition
  • 10. Java vs. Scala (differences)● No checked exception● Implicit conversions● Flexible imports and access modifier● Read Evaluate Print Loop (REPL) console
  • 11. Scala is a unifier
  • 12. Scala is Object-oriented
  • 13. Scala is Functional
  • 14. Scala is statically typed
  • 15. Scala is concisepublic class Person { private final String name; private final int age; public Person(String name, int age) { this.name = name; this.int = int; } public String getName() { return name; Java } public int getAge() { return age; }}
  • 16. Scala is conciseclass Person(val name:String, val age:Int) Sc ala
  • 17. Scala is expressive(1 to 10) filter (_ > 7)
  • 18. REPLThe command line for Scala
  • 19. Tuples( , )( , , )( , , , )( , , , , )( , , , , , )
  • 20. Tuples● Saves you the tedium of defining simplistic data-heavy classes● Immutable● Each value different type● Can contain up to 22 values● Indexed from 1
  • 21. REPL and Tuples
  • 22. Case classes
  • 23. Case classes● Easier instantiation● Immutability in constructor parameters by default● You get these methods for free ○ toString() ○ equals() ○ hashCode() ○ apply() ○ copy()
  • 24. Case classes
  • 25. Pattern Matching
  • 26. Pattern Matching● Similar to Javas switch statement● Let you match any sort of data● First-match policy
  • 27. Pattern Matching
  • 28. Higher Order Functions
  • 29. Higher Order Functions● Functions are first class citizens in Scala F:A B● Higher Order Functions are functions that take functions as input parameters or return them as results F : (A B) (R S)
  • 30. Higher Order Functionsmap(f)filter(f)
  • 31. Powerful Collections
  • 32. Powerful Collections● Easy to use ○ A small vocabulary of 20-50 methods to solve most collection problems● Concise ○ A single word instead of several loops!
  • 33. Powerful Collections● Safe ○ Functional nature + Statically typed!● Fast ○ Tuned and optimized collections operations● Universal ○ The same operation on any type
  • 34. Powerful Collections Scala Collections Immutable Mutable
  • 35. Powerful Collections● List ○ Immutable and ListBuffer is mutable● Array ○ Mutable● Set ○ Immutable and mutable● Map ○ Immutable and mutable● ... and String! ○
  • 36. Powerful Collections with HigherOrder Functions
  • 37. Traits
  • 38. Traits● Definition: ○ Provides a set of methods that implement behaviour ○ Requires a set of methods that parameterized the provided behaviour ○ Does not specify any state variables
  • 39. Traits● Interfaces with behaviors● Fundamental unit of code re-use● Extremely powerful tool in OO design
  • 40. Rich interfacesTraits Stackable modifications
  • 41. Traits
  • 42. Parallel Collections
  • 43. Parallel Collections● Supports the same operations as sequential ones● Easily convert sequential to parallel collection
  • 44. Parallel Collections
  • 45. Scala and Java Integration● Seamless integration● Make full use of existing libraries and code Scala Java
  • 46. Scala and Java Integration● Familiar development environments ○ Eclipse, IntelliJ, Netbeans, ...● Familiar building tools like Maven ○ SBT● If you are a Java developer, youre halfway there!
  • 47. Whats Scala advantage over Java as a language choice?
  • 48. ● implicit parameters● pattern matching● case classes● type inferencing● higher-kinded types● monadic for comprehension● variance annotation● traits● default and named argument● abstract values● by-name terms● type aliasing● self types● path-dependent types● structural types● ...
  • 49. Conclusion● Scala is not complex● Express your ideas in a concise way● Better code readability● Scala = Functional + Object oriented paradigms.● Scala scales with programmers
  • 50. Where to go from here?Programming in Scala, 2nd editionby Martin Odersky, Lex Spoon andBill VennersScala for the Impatient byCay Hortsmann
  • 51. Where to go from here?Scala Stockholm User Group http://www.meetup.com/Scala-Stockholm/
  • 52. Where to go from here?Scala course "Fast-Track to Scala" fromTypesafe18-19 September, 2012
  • 53. Where to go from here?
  • 54. Questions?
  • 55. Thank you!
  • 56. The place for sharing ideas and knowledge