際際滷

際際滷Share a Scribd company logo
Never say no to
舒亠仄?
Free lunch is over
仂 scala 亰舒 3 仄亳仆
 弌舒亳亠从舒 亳仗亳亰舒亳(!)
 仍舒仂仄
   Java
   .Net
 Functional
   个仆从亳亳 于亠亞仂 仗仂磲从舒
   丱于仂仂于舒 亠从亳
   仍仂亢亠仆仆亠 于亳仍亠仆亳
 Pattern matching 于亠亞仂 仆舒 于亠亠
 仂仄仗舒从仆亶 亳仆舒从亳(仗仂 舒于仆亠仆亳  Java)
 弍仂弍亠仆仆亠 亳仆舒从亳亠从亳亠 从仂仆从亳亳
Concurrency

 Actors
   亟亠 于亰舒 亳亰 Erlang
 Immutabe values
 Concurrent collections
   val doubled = list.par map(x => x * 2)
   从仂仆亠仆仂 仆舒亟仂 弍 仂仂仂亢仆仄
 Akka
   Software transactional memory
   futures
OO?

  从仂仆亠仆仂!
 舒仄仆仂亞仂 仄亠仆亠 boilerplate code 亠仄 于
  Java(仗仂从舒亢 亟舒仍亠)
 亠 仄仆仂亢亠于亠仆仆仂亞仂 仆舒仍亠亟仂于舒仆亳
   舒仂 亠 traits
   亅仂 舒从亳亠 亳仆亠亠亶 c 舒亳仆仂亶 亠舒仍亳亰舒亳亠亶
 static Objects
亠仄仆仂亞仂 亳仆亠亳从亳


def max(a,b) = if (a > b) a else b


class Person(val name: String, val age: Int) {
  require(name.length != 0) //will generate exception
  require(age > 0)
  def and(that: Person): Love = new Love(this, that)
}

val Mike = new Person(Mike", 17)
val Jane = new Person("Jane", 23)
val love = Mike and Jane
//Java
import java.util.ArrayList;

Person[] people;
Person[] minors;
Person[] adults;
{
   ArrayList<Person> minorsList = new ArrayList<Person>();
   ArrayList<Person> adultsList = new ArrayList<Person>();
   for (int i = 0; i < people.length; i++)
      (people[i].age < 18 ? minorsList : adultsList)
         .add(people[i]);
   minors = minorsList.toArray(people);
   adults = adultsList.toArray(people);
}

//Scala
val people: Array[Person]
val (minors, adults) = people partition(_.age > 18)
亟亳亳

 Trading platforms
 Financial modeling
 Simulation
   domain-specific languages
 Web platforms
   Play Framework
   Lift
仂仄仗舒仆亳亳

   Twitter
   Foursquare
   Credit Suisse
   LinkedIn
   The Guardian
   Sony, IBM, Nasa, Amazon etc
丼仂 亠  仆舒?
 亟亳仆 弍仂亠于仂亶 仗仂亠从
 舒仗仂舒仆磳 仗仂 从仂仄仗舒仆亳亳 从舒从 亰舒舒亰舒
   舒亰亞仂于仂 仆舒 从仆亠 仗亳仂弍亠仍亳
    仆从亳仂仆舒仍仆亶 仂亠仆仂从
   16 亠仍仂于亠从 仆舒 仄仂仄亠仆 仗亠亰亠仆舒亳亳 仗仂仂亟
    从.
丼仂 亟舒仍亠?
 coursera.org Functional programming in Scala 仂 仂亰亟舒亠仍
  磶从舒.
 仆仂亞仂 亟亠亶于亳亠仍仆仂 仂仂亳 从仆亳亞

More Related Content

Scala in 10 minutes

  • 3. 仂 scala 亰舒 3 仄亳仆 弌舒亳亠从舒 亳仗亳亰舒亳(!) 仍舒仂仄 Java .Net Functional 个仆从亳亳 于亠亞仂 仗仂磲从舒 丱于仂仂于舒 亠从亳 仍仂亢亠仆仆亠 于亳仍亠仆亳 Pattern matching 于亠亞仂 仆舒 于亠亠 仂仄仗舒从仆亶 亳仆舒从亳(仗仂 舒于仆亠仆亳 Java) 弍仂弍亠仆仆亠 亳仆舒从亳亠从亳亠 从仂仆从亳亳
  • 4. Concurrency Actors 亟亠 于亰舒 亳亰 Erlang Immutabe values Concurrent collections val doubled = list.par map(x => x * 2) 从仂仆亠仆仂 仆舒亟仂 弍 仂仂仂亢仆仄 Akka Software transactional memory futures
  • 5. OO? 从仂仆亠仆仂! 舒仄仆仂亞仂 仄亠仆亠 boilerplate code 亠仄 于 Java(仗仂从舒亢 亟舒仍亠) 亠 仄仆仂亢亠于亠仆仆仂亞仂 仆舒仍亠亟仂于舒仆亳 舒仂 亠 traits 亅仂 舒从亳亠 亳仆亠亠亶 c 舒亳仆仂亶 亠舒仍亳亰舒亳亠亶 static Objects
  • 6. 亠仄仆仂亞仂 亳仆亠亳从亳 def max(a,b) = if (a > b) a else b class Person(val name: String, val age: Int) { require(name.length != 0) //will generate exception require(age > 0) def and(that: Person): Love = new Love(this, that) } val Mike = new Person(Mike", 17) val Jane = new Person("Jane", 23) val love = Mike and Jane
  • 7. //Java import java.util.ArrayList; Person[] people; Person[] minors; Person[] adults; { ArrayList<Person> minorsList = new ArrayList<Person>(); ArrayList<Person> adultsList = new ArrayList<Person>(); for (int i = 0; i < people.length; i++) (people[i].age < 18 ? minorsList : adultsList) .add(people[i]); minors = minorsList.toArray(people); adults = adultsList.toArray(people); } //Scala val people: Array[Person] val (minors, adults) = people partition(_.age > 18)
  • 8. 亟亳亳 Trading platforms Financial modeling Simulation domain-specific languages Web platforms Play Framework Lift
  • 9. 仂仄仗舒仆亳亳 Twitter Foursquare Credit Suisse LinkedIn The Guardian Sony, IBM, Nasa, Amazon etc
  • 10. 丼仂 亠 仆舒? 亟亳仆 弍仂亠于仂亶 仗仂亠从 舒仗仂舒仆磳 仗仂 从仂仄仗舒仆亳亳 从舒从 亰舒舒亰舒 舒亰亞仂于仂 仆舒 从仆亠 仗亳仂弍亠仍亳 仆从亳仂仆舒仍仆亶 仂亠仆仂从 16 亠仍仂于亠从 仆舒 仄仂仄亠仆 仗亠亰亠仆舒亳亳 仗仂仂亟 从.
  • 11. 丼仂 亟舒仍亠? coursera.org Functional programming in Scala 仂 仂亰亟舒亠仍 磶从舒. 仆仂亞仂 亟亠亶于亳亠仍仆仂 仂仂亳 从仆亳亞