A Tour Of Scala
Upcoming SlideShare
Loading in...5
×
 

A Tour Of Scala

on

  • 8,612 views

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

Statistics

Views

Total Views
8,612
Views on SlideShare
8,210
Embed Views
402

Actions

Likes
16
Downloads
355
Comments
0

14 Embeds 402

http://fanf42.blogspot.com 221
http://mahananda 112
http://ondrejfiedler.blogspot.cz 32
http://www.slideshare.net 16
https://www.blogger.com 9
http://fanf42.blogspot.de 2
http://fanf42.blogspot.fr 2
https://twitter.com 2
https://www.linkedin.com 1
http://www.linkedin.com 1
http://fanf42.blogspot.co.uk 1
https://duckduckgo.com 1
http://mahananda.gslab.com 1
http://www.blogger.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

CC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike License

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

A Tour Of Scala A Tour Of Scala Presentation Transcript

  • A tour of Scala Francois Armand http://fanf42.blogspot.com June 2009
  • Exploring Scala facets
    • Genesis
    • Scala is...
      • Mainstream
      • A scripting language
      • Object Oriented
      • Functional
      • Scalable
  • Background - Martin Odersky history
    • Pizza – 1996
      • A better (more functional ) Java
        • Generics , pattern matching, higher order function
        • On the JVM
      • Sun interested
    • Generic Java (GJ) – 1998/1999
      • Generics come in Java 5 (2005) with addition (wildcards...)
      • GJ compiler became the default Javac for Java 1.3
    • Funnel – 2000
      • Again, on the JVM - “Bootstrapping is too expensive”
      • Pure academic experiment - too academic
    Genesis
  • Scala genesis
    • Scala – since 2002
      • Martin O. join EPFL – École Polytechnique de Lausane
      • Major rewrite in 2006
      • Current version : 2.7.5 – 2.8 before end of 2009 (hopefully)
    • Initial goals
      • A better Java
      • Object Oriented / Functional Programing real merge
    Genesis
  • A mainstream language
    • General purpose
    • On the JVM
    • Statically typed
  • General purpose
    • Web framework
    • Business layer
    • Side libraries
      • Test
      • DSL
    • Graphical User Interface
    Scala is mainstream
  • Scala runs on the JVM
    • Compile to bytecode
    • Fully compatible with Java
      • Scala code can call Java methods, select Java field, extends Java classes, implements Java interfaces
      • Without any glue code / specific syntax
      • And the same (almost) holds for the other way
    • => all existing Java frameworks are available
    • Performances: on part with Java
    Scala is mainstream
  • Statically typed
    • One of the rare statically typed language on the JVM
    • Type annotation AFTER names
    • With generics and type boundaries
    • With type inference
    Scala is mainstream
  • Tooling
    • Plugins for the 3 main Java IDEs
      • Netbean and Idea: quite good
      • Eclipse
        • Better and better
        • One people full time on it
    • JavaRebel (live class reloading)
      • Scala plugin
      • Free licences
    Scala is mainstream
  • Scripting language
    • What do you want in a scripting language ?
      • Quick write / test loop
      • Terse / expressive
      • Duck typing
      • Add methods to existing class
      • Easyly usable, high level data types / control structures
  • Write and test - quickly Scala is a scripting language
    • Read / Eval / Print Loop (REPL)
      • Console interpreter
      • Code completion with Scala 2.8
    • Demo: basic Scala constructs
      • Value / variable
      • Function definition
      • condition
  • Java without noise
    • Type inference
    • Optional syntax
      • return
      • “ .”
      • “ ;”
      • { } for one-line method
      • “ ( )” when 0 or one argument
      • Apply method
    • Multi-line strings
      • No need to escape special chars
    Scala is a scripting language Scala is a scripting language
  • Expressive
    • Factories
      • Defined for all collections in standard library
    • Tuples
    • For comprehension
    Scala is a scripting language
  • Add methods to existing classes
    • Implicit conversions
      • Implicitly call wrappers factories to convert between types
      • Checked at compile time
    • Ex: ScalaCheck
      • Implicitly call a wrapper to add “should” method on object Map
    Scala is a scripting language
  • Duck typing
    • “ If it looks like a duck and quacks like a duck, then it probably is a duck ”
    • Structural types
      • Checked at compile time
    Scala is a scripting language
  • Real scripts, from command line
    • File “helloWorld.scala”
    • Executed in a console: ~$ ./helloWorld.scala
    Scala is a scripting language
  • Scala is Object Oriented
    • Full OO
    • With Classes and Objects
    • Traits
  • Full OO
    • No primitive types
      • Everything is an object
      • Even functions are objects !
    • No operators
      • Operator are simple methods
    • No static
    Scala is a object oriented
  • Classes and Objects
    • “class”
      • Usual Java-style classes
      • A default constructor
        • In class declaration
        • Other constructor MUST derive from that one
    • “object”
      • Scala way for static
      • Singleton object
    Scala is a object oriented
  • Compared to Java Scala is a object oriented
  • Traits - 1
    • Interfaces with implementation
    • Add aspects
    Scala is a object oriented
  • Traits - 2
    • Stackable
    Scala is a object oriented
  • Scala is functional
    • Values for everything
    • Higher order functions
    • Immutability & consistency
    • Pattern matching
    • Functional data structures
    • Currying
    • Lazy constructs
    • And a lot of other things !
  • Values for everyone
    • Each block is valued
      • Easy to add logic incrementally
      • Block in function parameters
    Scala is functional
  • Higher order function & Closures
    • Function = first class objects
    • Closure = parameters and properties
    Scala is functional
  • 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
  • Add new control structures
    • Look “natives”
      • Valued blocks
      • + Higher order functions & closures
      • + optional syntax
      • = easy extension of the language by libraries
    • Ex : no “break” keyword in Scala: add it yourself !
    Scala is functional
  • Functional Data Structures
    • The almighty List
      • Methods available for all Collections
    Scala is a functional
  • Pattern matching - 1
      • Switch under vitamins
      • Deconstruct object graph – Why ?
        • Work on semi-structured datas : XML, Rexeps, etc
        • Two many methods needed to have them in a top-level object
        • When methods (or top-level object) not under your control
    Scala is a functional
  • Pattern matching - 2
    • Case classes
      • Define your own patterns
      • Automatically add equals/hashcode and Factories for you
      • “sealed” => compiler checks that all choices are tested
    Scala is a functional
  • Currying
    • Function with a list of arguments
    • == function with multiple argument lists
    • Define new specialized functions easily
      • Division of labour
    Scala is a functional
  • Lazy constructs - 1
    • Lazy = evaluated only when needed
    Scala is a functional
  • Lazy constructs - 2
    • Create infinite Collections
    Scala is a functional
  • A lots of other things
    • Self types
    • Abstract type
    • Existential types
    • Type variance
    • Monads
    • Combinatory parsers
    • And a lot more
  • So, Why “Scala” ?
    • “Scalable” language
      • Scala is deep, not broad
      • Scale in large
        • Object / class hierarchies, traits compositions
      • Scale in small
        • Functional aspects: composable small methods
        • => Unix pipes
      • Easy to add
        • New Data types
        • New Control Structures
        • Look “native”
      • Great for DSL
  • DSL: Actors Scalable language
  • DSL: XML Scala is a functional
  • Successful (?)
    • Get more and more attention
      • 6 talks at JavaOne 2009 + ScalaLiftOff – one full day of Scala
      • 4 books (and 2 other by the end of 2009)
      • Active mailing list / irc channel
      • Several external commiters on the compiler
    • Who used it ?
      • Open Source projects
        • Lift - http://liftweb.net : web framework, full stack
        • Apache Camel / NetBeans / ScalaSpec / ScalaCheck...
      • Commercial
        • Twitter / Sony / Mimesis Republic / EDF trading / SAP
    Last words
  • Scala 2.8 preview – end of 2009
    • Redesigned collection library
    • Named and default parameters
    • Package object
    • Scala Swing library
    • Revamped REPL
    • Type specialization
    • Continuation (as a plugin compiler)
    Last words
  • Questions ?
    • http://scala-lang.org
    • http://www.artima.com