Jugar Introduccion a Scala
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

Jugar Introduccion a Scala

  • 4,234 views
Uploaded on

Introducción a Scala:...

Introducción a Scala:
* JVM / Java Interop
* Type inference
* Muy Conciso
* REPL
* Collections
* Promueve buenas prácticas
* Functional + OO
* Pattern Matching
* Case Class
* Implicit conversions
* Traits
* Some/None/Option

  • 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
4,234
On Slideshare
2,191
From Embeds
2,043
Number of Embeds
17

Actions

Shares
Downloads
17
Comments
0
Likes
2

Embeds 2,043

http://gabrey.blogspot.com.ar 1,074
http://gabrey.blogspot.com 870
http://gabrey.blogspot.com.es 44
http://gabrey.blogspot.mx 20
http://gabrey.blogspot.com.br 10
http://gabrey.blogspot.com.au 7
https://www.linkedin.com 4
http://gabrey.blogspot.ru 2
http://gabrey.blogspot.ca 2
http://gabrey.blogspot.it 2
http://www.blogger.com 2
http://webcache.googleusercontent.com 1
http://translate.googleusercontent.com 1
http://gabrey.blogspot.in 1
http://gabrey.blogspot.co.uk 1
http://www.linkedin.com 1
http://gabrey.blogspot.jp 1

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. Escala el Everest con Scala
    http://slidesha.re/nRVC7x
  • 2. Soy …
    Gustavo Arjones
    gustavo@socialmetrix.com
    @arjones
    CTO – Socialmetrix
    Vivo en BA desde 2007
    Interés:
    Sistemasdistribuídos
    SOA
    Databases
    Text Mining / NLP
    Big Data
    Social Media
    Data Visualization
  • 3. “If I were to pick a language to use today other than Java, it would be Scala”
    James Gosling
  • 4. Madurez …
    Professional Services / Training
  • 5. Porque me gusta?
    JVM / Java Interop
    Type inference
    MuyConciso
    REPL
    Lib de Collections
    Promuevebuenasprácticas
    Functional + OO
    Pattern Matching
    Case Class
    Implicit conversions
    Traits
    Some/None/Option
  • 6. JVM / Java Interop
  • 7. Type Inference
    valcountryByLanguage : Map[String, List[String]] = Map(
    "es"->List("ar","es", "mx"),
    "pt" -> List("br","pt"),
    "en" -> List("uk","us")
    )
    valcountryByLanguage = Map(
    "es"->List("ar","es", "mx"),
    "pt" -> List("br","pt"),
    "en" -> List("uk","us")
    )
    countryByLanguage: scala.collection.immutable.Map[String,List[String]]
  • 8. MuyConciso
    def +(v:Int) = v+1
    objA==objB
    No esnecesario:
    ()
    ;
    return
    .
  • 9. REPL (Equiv. Ruby IRB)
  • 10. Collections
  • 11. Collections
  • 12. Buzz de los lenguajes
  • 13. Procesando Delicious
  • 14. https://gist.github.com/1123656
  • 15. Promuevebuenaspracticas … sin limitarte!
    Remueve Boilerplate
    Inmutabilidad
    Uso de funciones
    No side-effect
    Muchos helpers yconstructores
    Share-nothing
    Listopara Multi-core
  • 16. Functional programming
    cat FILE | grep"@jugar.com.ar" | wc
    valplaces = List("Buenos Aires", "Bogota", "DF", "Sao Paulo", "New York")
    places.filter((p:String) => p.startsWith("B"))
    places.filter(p => p.startsWith("B"))
    places.filter(_.startsWith("B"))
    valmyFunc = (p:String) => p.startsWith("B")
    places.filter(myFilter)
    def myFilter(p:String) = p.startsWith("B")
    places.filter(myFilter)
  • 17. Pattern Matching
    case classPerson(valname: String, valage: Int)
    valppl = List(Person("John", 25), Person("Paul", 27), Person("George", 22), Person("Ringo", 22))
    ppl.foreach {
    _ match {
    case Person("John", age) => println("John is " + age)
    case Person(name, 22) => println(name + " is 22")
    case _ => println("Don't know")
    }
    }
  • 18. Implicit conversions
    Conversión de tipos
    Adicionarcomportamiento en clasescerradas
    Extender el lenguaje
  • 19. Implicit conversions
    class RichInt(i: Int) {
    def times(f: => Unit) = {
    for (x <- 0 to i) f
    }
    }
    new RichInt (5).times { println("hi!") }
    implicit defintToRichInt(i: Int) = new RichInt(i)
    5.times { println("nice!") }
  • 20. traits – Interfaces con anabólicos
    trait NoNullAccessMap[K, V] extends java.util.Map[K, V] {
    abstract override def get(key: Object): V = {
    valvalue = super.get(key)
    assert(value != null, "No value found " + key)
    return value
    }
    }
    trait NoOverwriteMap[K, V] extends java.util.Map[K, V] {
    abstract override def put(key: K, value: V): V = {
    assert(!containsKey(key), "Could not set " + key
    + " to " + value + ": it is already set to " +
    get(key))
    return super.put(key, value)
    }
    }
  • 21. traits – Interfaces con anabólicos
    class StrictMap[K, V] extends HashMap[K, V]
    with NoNullAccessMap[K, V]
    with NoOverwriteMap[K, V]
    valstateForCity = new HashMap[String, String]()
    with NoNullAccessMap[String, String]
    with NoOverwriteMap[String, String]
  • 22. Option
    //previous approach: doesnt compile!
    val name = getPerson("person123").name
    //.get will throw a RuntimeException if it is null here
    val name2 = getPerson("person123").get.name
    //get the value, or use a default
    val name3 = getPerson("person123").getOrElse("Name unknown")
    //in some cases (not this one), pattern matching is nice
    val name4 = getPerson("person123") match {
    case Some(name) => name
    case None => "Name Unknown”
    }
  • 23. Take away
    No es Java oScala, puedenconvivir!
    AprenderScala me hacemejordesarrollador Java
    Empezá con pequeñosproyectosparaprobar, ganáconfianza
    La sintaxisparececompleja, después se despeja
  • 24. Pordóndeempezar
    How we (mostly) moved from Java to Scala
    http://bit.ly/rlw2Cx
    Scala for Java Refugees
    http://bit.ly/qmHTpm
    Simply Scala
    http://www.simplyscala.com
    Typesafe Stack
    http://bit.ly/qmcP0A
    An introduction to Scala for Java Programmers
    http://slidesha.re/oGvttM
    Pragmatic Real-World Scala
    http://slidesha.re/nfF0xK
    Tools & Libraries
    http://bit.ly/nple9Z
  • 25. Trabajamos con estastecnologías
    Sumate a nuestroequipo!
    gustavo@socialmetrix.com
  • 26. Gracias / Obrigado
    ;)