A Tour Of Scala

  • 6,455 views
Uploaded on

A general presentation of the Scala language, a OO/functional, statically typed language that runs on the JVM

A general presentation of the Scala language, a OO/functional, statically typed language that runs on the JVM

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
6,455
On Slideshare
0
From Embeds
0
Number of Embeds
10

Actions

Shares
Downloads
359
Comments
0
Likes
16

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. A tour of Scala Francois Armand http://fanf42.blogspot.com June 2009
  • 2. Exploring Scala facets
    • Genesis
    • 3. Scala is...
      • Mainstream
      • 4. A scripting language
      • 5. Object Oriented
      • 6. Functional
      • 7. Scalable
  • 8. Background - Martin Odersky history
    • Pizza – 1996
      • A better (more functional ) Java
        • Generics , pattern matching, higher order function
        • 9. On the JVM
      • Sun interested
    • Generic Java (GJ) – 1998/1999
      • Generics come in Java 5 (2005) with addition (wildcards...)
      • 10. GJ compiler became the default Javac for Java 1.3
    • Funnel – 2000
      • Again, on the JVM - “Bootstrapping is too expensive”
      • 11. Pure academic experiment - too academic
    Genesis
  • 12. Scala genesis
    • Scala – since 2002
      • Martin O. join EPFL – École Polytechnique de Lausane
      • 13. Major rewrite in 2006
      • 14. Current version : 2.7.5 – 2.8 before end of 2009 (hopefully)
    • Initial goals
      • A better Java
      • 15. Object Oriented / Functional Programing real merge
    Genesis
  • 16. A mainstream language
    • General purpose
    • 17. On the JVM
    • 18. Statically typed
  • 19. General purpose
    • Web framework
    • 20. Business layer
    • 21. Side libraries
    • Graphical User Interface
    Scala is mainstream
  • 23. Scala runs on the JVM
    • Compile to bytecode
    • 24. Fully compatible with Java
      • Scala code can call Java methods, select Java field, extends Java classes, implements Java interfaces
      • 25. Without any glue code / specific syntax
      • 26. And the same (almost) holds for the other way
    • => all existing Java frameworks are available
    • 27. Performances: on part with Java
    Scala is mainstream
  • 28. Statically typed
    • One of the rare statically typed language on the JVM
    • 29. Type annotation AFTER names
    • 30. With generics and type boundaries
    • 31. With type inference
    Scala is mainstream
  • 32. Tooling
    • Plugins for the 3 main Java IDEs
      • Netbean and Idea: quite good
      • 33. Eclipse
        • Better and better
        • 34. One people full time on it
    • JavaRebel (live class reloading)
      • Scala plugin
      • 35. Free licences
    Scala is mainstream
  • 36. Scripting language
    • What do you want in a scripting language ?
      • Quick write / test loop
      • 37. Terse / expressive
      • 38. Duck typing
      • 39. Add methods to existing class
      • 40. Easyly usable, high level data types / control structures
  • 41. Write and test - quickly Scala is a scripting language
    • Read / Eval / Print Loop (REPL)
      • Console interpreter
      • 42. Code completion with Scala 2.8
    • Demo: basic Scala constructs
      • Value / variable
      • 43. Function definition
      • 44. condition
  • 45. Java without noise
    • Type inference
    • 46. Optional syntax
    • Multi-line strings
      • No need to escape special chars
    Scala is a scripting language Scala is a scripting language
  • 52. Expressive
    • Factories
      • Defined for all collections in standard library
    • Tuples
    • 53. For comprehension
    Scala is a scripting language
  • 54. Add methods to existing classes
    • Implicit conversions
      • Implicitly call wrappers factories to convert between types
      • 55. Checked at compile time
    • Ex: ScalaCheck
      • Implicitly call a wrapper to add “should” method on object Map
    Scala is a scripting language
  • 56. Duck typing
    • “ If it looks like a duck and quacks like a duck, then it probably is a duck ”
    • 57. Structural types
      • Checked at compile time
    Scala is a scripting language
  • 58. Real scripts, from command line
    • File “helloWorld.scala”
    • 59. Executed in a console: ~$ ./helloWorld.scala
    Scala is a scripting language
  • 60. Scala is Object Oriented
  • 63. Full OO
    • No primitive types
      • Everything is an object
      • 64. Even functions are objects !
    • No operators
      • Operator are simple methods
    • No static
    Scala is a object oriented
  • 65. Classes and Objects
    • “class”
      • Usual Java-style classes
      • 66. A default constructor
        • In class declaration
        • 67. Other constructor MUST derive from that one
    • “object”
      • Scala way for static
      • 68. Singleton object
    Scala is a object oriented
  • 69. Compared to Java Scala is a object oriented
  • 70. Traits - 1
    • Interfaces with implementation
    • 71. Add aspects
    Scala is a object oriented
  • 72. Traits - 2
    • Stackable
    Scala is a object oriented
  • 73. Scala is functional
    • Values for everything
    • 74. Higher order functions
    • 75. Immutability & consistency
    • 76. Pattern matching
    • 77. Functional data structures
    • 78. Currying
    • 79. Lazy constructs
    • 80. And a lot of other things !
  • 81. Values for everyone
    • Each block is valued
      • Easy to add logic incrementally
      • 82. Block in function parameters
    Scala is functional
  • 83. Higher order function & Closures
    • Function = first class objects
    • 84. Closure = parameters and properties
    Scala is functional
  • 85. Immutability and no Null by default
    • Val & Value objects
      • Immutability is easy to achieve
    • Option type
      • Null should be avoided
    • Immutable collections
      • Available in standard library
    Scala is functional
  • 86. Add new control structures
    • Look “natives”
      • Valued blocks
      • 87. + Higher order functions & closures
      • 88. + optional syntax
      • 89. = easy extension of the language by libraries
    • Ex : no “break” keyword in Scala: add it yourself !
    Scala is functional
  • 90. Functional Data Structures
    • The almighty List
      • Methods available for all Collections
    Scala is a functional
  • 91. Pattern matching - 1
      • Switch under vitamins
      • 92. Deconstruct object graph – Why ?
        • Work on semi-structured datas : XML, Rexeps, etc
        • 93. Two many methods needed to have them in a top-level object
        • 94. When methods (or top-level object) not under your control
    Scala is a functional
  • 95. Pattern matching - 2
    • Case classes
      • Define your own patterns
      • 96. Automatically add equals/hashcode and Factories for you
      • 97. “sealed” => compiler checks that all choices are tested
    Scala is a functional
  • 98. Currying
    • Function with a list of arguments
    • 99. == function with multiple argument lists
    • 100. Define new specialized functions easily
      • Division of labour
    Scala is a functional
  • 101. Lazy constructs - 1
    • Lazy = evaluated only when needed
    Scala is a functional
  • 102. Lazy constructs - 2
    • Create infinite Collections
    Scala is a functional
  • 103. A lots of other things
  • 110. So, Why “Scala” ?
    • “Scalable” language
      • Scala is deep, not broad
      • 111. Scale in large
        • Object / class hierarchies, traits compositions
      • Scale in small
        • Functional aspects: composable small methods
        • 112. => Unix pipes
      • Easy to add
        • New Data types
        • 113. New Control Structures
        • 114. Look “native”
      • Great for DSL
  • 115. DSL: Actors Scalable language
  • 116. DSL: XML Scala is a functional
  • 117. Successful (?)
    • Get more and more attention
      • 6 talks at JavaOne 2009 + ScalaLiftOff – one full day of Scala
      • 118. 4 books (and 2 other by the end of 2009)
      • 119. Active mailing list / irc channel
      • 120. Several external commiters on the compiler
    • Who used it ?
      • Open Source projects
        • Lift - http://liftweb.net : web framework, full stack
        • 121. Apache Camel / NetBeans / ScalaSpec / ScalaCheck...
      • Commercial
        • Twitter / Sony / Mimesis Republic / EDF trading / SAP
    Last words
  • 122. Scala 2.8 preview – end of 2009
    • Redesigned collection library
    • 123. Named and default parameters
    • 124. Package object
    • 125. Scala Swing library
    • 126. Revamped REPL
    • 127. Type specialization
    • 128. Continuation (as a plugin compiler)
    Last words
  • 129. Questions ?
    • http://scala-lang.org
    • 130. http://www.artima.com