SlideShare a Scribd company logo
1 of 21
Scala for Rubyists
Make your ideas come true
by Michel Perez
www.mrkaspa.com
Ruby :D
FELICIDAD TIPADO DINAMICO GEMS
NO IDE DOCUMENTACION FACIL DE APRENDER
Ruby :(
PERFORMANCE ESCALABILIDAD PROG FUNCIONAL
MANTENIBILIDAD CONCURRENCIA
I <3 Java
- JVM
- Libraries
- Performance
- Escalabilidad
- Mantenibilidad
SCALA CLOJURE
JRUBYGROOVY
6
7
PROS CONS
Primitivas de concurrencia
Desarrollado por Google
Tiempo de compilación
Lenguaje compilado
Lenguaje tipado
Sintaxis old style
Demasiado imperativo
Poco funcional
Inmutabilidad
8
PROS CONS
Primitivas de concurrencia
Erlang
Lenguaje interpretado
Funcional
Muy nuevo
9
PROS CONS
Primitivas de concurrencia
Funcional
JVM
Lenguaje interpretado
Sistema de tipado opcional
LISP
10
PROS CONS
Akka
Funcional
JVM
Tipado
Compilado
Tiempo de compilación
Curva de aprendizaje
Gestión de dependencias
Programacion funcional
FUNCIONES Y MAS FUNCIONES INMUTABILIDAD
CURRYING CLOSURES
LAZY EVALUATION PATTERN MATCHING
CAMBIA LA MANERA EN COMO
PROGRAMAS
Scala Variables?
12
val labels = Set(“")
val labels = Set[String](“”)
var labels = Set[String](“”)
Y los tipos?
Colecciones Inmutables
Syntaxis para generics <?>
NO HAY ; :D
Que es val ?
Scala OOP + FP
13
No es la OOP el demonio?
Un buen programador de scala no usa
side efect
Funciones puras
Usa OOP para abstraer datos
class Rational(x: Int, y: Int) {
def this(x: Int) = this(x, 1)
private def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)
private val g = gcd(x, y)
def numer = x / g
def denom = y / g
def < (o: Rational) = numer * o.denom < o.numer * denom
def > (o: Rational) = !(this < o)
def +(o: Rational) = {
new Rational(numer * o.denom + denom * o.numer, denom * o.denom)
}
def -(o: Rational) = {
this + (-o)
}
def unary_- = Rational(-numer, denom)
override def toString = {
numer + "/" + denom
}
} Cada cambio de estado genera un
nuevo objeto
Scala OOP
14
Case class -> get, set, constructor auto
Traits son similares a los modulos
en Ruby
Generic clases/traits
Singleton Object
case class SocialNetwork(id: String, name: String)
trait LinkedList[+A] {
def isEmpty: Boolean
def head: A
def tail: LinkedList[A]
def at(index: Int): A
def prepend[B >: A](elem: B): LinkedList[B] =
new Cons(elem, this)
}
object Nil extends LinkedList[Nothing] {
class Cons[A](val head: A, val tail: LinkedList[A]) extends LinkedList[A] {
Scala Functions
15
Toda funciona debe tener un tipo de
retorno(type inference)
Funciones como parámetros
Retorna funciones
Vector.fill(queens.length)("* “)
.updated(col, "X ").mkString
def lambda = (x: Int) => x + 1
val multiplier = (i:Int) => i * 10
def sumComp(a: Int): (Int) => Int = {
def sum(b: Int) = a + b
}
val fun = sumComp(5)
fun(1)
def sumComp(a: Int)(b: Int): Int = {
a + b
}
Currying
Pattern Matching
16
Es un Super Switchval secondElement = List(1,2,3) match {
case x :: y :: xs => y
case _ => 0
}
val foodItem = "porridge"
def goldilocks(expr: Any) = expr match {
case (`foodItem`, _) => "eating"
case ("chair", "Mama") => "sitting"
case ("bed", "Baby") => "sleeping"
case _ => "what?"
}
goldilocks(("porridge", "Papa"))
Compara y extrae al mismo tiempo
Implicits
17
Parametros inyectados en un metodo
o constructor de manera implicita
Sirve para realizar conversiones
automaticas
implicit def implChange(str:String):Int =
new Integer(str)
def sum(a:Int, b:Int):Int = a +b
sum("1", 2)
Monads
18
map, flatMap, filter
for comprehension
def readAsync(): Future[Option[List[String]]] =
Future { readFile() }
def readFile(): Option[List[String]] =
Try { Source.fromURL("/tmp/file.txt").getLines().toList
} toOption
val futSize: Future[Int] =
for {
result <- readAsync()
list <- result
} yield list.size
val futSizeMap: Future[Option[Int]] =
readAsync().map { result: Option[List[String]] =>
result.map((list: List[String]) => list.size)
}
Future, Option, Try, Either
Actors
19
Hilos livianos
Orientados a eventos
class BloodRequester extends Actor {
implicit val executor = context.dispatcher
override def receive: Receive = {
case BloodRequest(request) =>
DonorDAO.findNear(request).map { donors =>
donors.foreach { donor =>
facebookNotifier ! FacebookNotify(donor, request)
}
}
}
}
Se reinician en caso de fallas
Supervisión
ScalaTest
20
Test Unit
trait NeoTest
extends FunSpec
with MustMatchers
with BeforeAndAfterAll
with BeforeAndAfterEach {
override def beforeEach(): Unit = {
NeoDBCleaner.cleanDB()
}
describe("UserDAOs") {
it("creates an user an checks the default group") {
withUser { (user, saved) =>
saved must be(true)
val query = s"""match (a:user {id: "${user.id.getOrElse("")}"})-[c:has_group]->(b:group) return a, b, c"""
val result = Await.result(NeoQuery.executeQuery[UserLogin, Group, HasGroupLogin](query), 2 seconds)
result.length must be(1)
}
}
}
}
Multiples Pardigmas
TDD
BDD
Scala wants U ;)
21
https://www.coursera.org/course/progfun
http://scala-exercises.47deg.com/koans

More Related Content

What's hot

Building microservices with Kotlin
Building microservices with KotlinBuilding microservices with Kotlin
Building microservices with KotlinHaim Yadid
 
Introduction to asynchronous DB access using Node.js and MongoDB
Introduction to asynchronous DB access using Node.js and MongoDBIntroduction to asynchronous DB access using Node.js and MongoDB
Introduction to asynchronous DB access using Node.js and MongoDBAdrien Joly
 
SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.Ruslan Shevchenko
 
Real cases of indispensability of Oracle SQL analytic functions
Real cases of indispensability of Oracle SQL analytic functionsReal cases of indispensability of Oracle SQL analytic functions
Real cases of indispensability of Oracle SQL analytic functionsKim Berg Hansen
 
Swift and Kotlin Presentation
Swift and Kotlin PresentationSwift and Kotlin Presentation
Swift and Kotlin PresentationAndrzej Sitek
 
Introduction to Scala for Java Developers
Introduction to Scala for Java DevelopersIntroduction to Scala for Java Developers
Introduction to Scala for Java DevelopersMichael Galpin
 
Taking Kotlin to production, Seriously
Taking Kotlin to production, SeriouslyTaking Kotlin to production, Seriously
Taking Kotlin to production, SeriouslyHaim Yadid
 
A Tour Of Scala
A Tour Of ScalaA Tour Of Scala
A Tour Of Scalafanf42
 
Kotlin For Android - Basics (part 1 of 7)
Kotlin For Android - Basics (part 1 of 7)Kotlin For Android - Basics (part 1 of 7)
Kotlin For Android - Basics (part 1 of 7)Gesh Markov
 
Intro to Functional Programming in Scala
Intro to Functional Programming in ScalaIntro to Functional Programming in Scala
Intro to Functional Programming in ScalaShai Yallin
 
Oral presentation v2
Oral presentation v2Oral presentation v2
Oral presentation v2Yeqi He
 
Kotlin For Android - Constructors and Control Flow (part 2 of 7)
Kotlin For Android - Constructors and Control Flow (part 2 of 7)Kotlin For Android - Constructors and Control Flow (part 2 of 7)
Kotlin For Android - Constructors and Control Flow (part 2 of 7)Gesh Markov
 
LINQ Inside
LINQ InsideLINQ Inside
LINQ Insidejeffz
 
Incremental Development with Lisp: Building a Game and a Website
Incremental Development with Lisp: Building a Game and a WebsiteIncremental Development with Lisp: Building a Game and a Website
Incremental Development with Lisp: Building a Game and a WebsiteJames Long
 
Alfresco the clojure way
Alfresco the clojure wayAlfresco the clojure way
Alfresco the clojure wayCarlo Sciolla
 
.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#Bertrand Le Roy
 
Elm: Make Yourself A Happy Front-end Web Developer
Elm: Make Yourself A Happy Front-end Web DeveloperElm: Make Yourself A Happy Front-end Web Developer
Elm: Make Yourself A Happy Front-end Web DeveloperAsep Bagja
 

What's hot (20)

Building microservices with Kotlin
Building microservices with KotlinBuilding microservices with Kotlin
Building microservices with Kotlin
 
Introduction to Elm
Introduction to ElmIntroduction to Elm
Introduction to Elm
 
Introduction to asynchronous DB access using Node.js and MongoDB
Introduction to asynchronous DB access using Node.js and MongoDBIntroduction to asynchronous DB access using Node.js and MongoDB
Introduction to asynchronous DB access using Node.js and MongoDB
 
SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.
 
Real cases of indispensability of Oracle SQL analytic functions
Real cases of indispensability of Oracle SQL analytic functionsReal cases of indispensability of Oracle SQL analytic functions
Real cases of indispensability of Oracle SQL analytic functions
 
Swift and Kotlin Presentation
Swift and Kotlin PresentationSwift and Kotlin Presentation
Swift and Kotlin Presentation
 
Introduction to Scala for Java Developers
Introduction to Scala for Java DevelopersIntroduction to Scala for Java Developers
Introduction to Scala for Java Developers
 
Short intro to ECMAScript
Short intro to ECMAScriptShort intro to ECMAScript
Short intro to ECMAScript
 
Taking Kotlin to production, Seriously
Taking Kotlin to production, SeriouslyTaking Kotlin to production, Seriously
Taking Kotlin to production, Seriously
 
A Tour Of Scala
A Tour Of ScalaA Tour Of Scala
A Tour Of Scala
 
Kotlin For Android - Basics (part 1 of 7)
Kotlin For Android - Basics (part 1 of 7)Kotlin For Android - Basics (part 1 of 7)
Kotlin For Android - Basics (part 1 of 7)
 
Intro to Functional Programming in Scala
Intro to Functional Programming in ScalaIntro to Functional Programming in Scala
Intro to Functional Programming in Scala
 
Oral presentation v2
Oral presentation v2Oral presentation v2
Oral presentation v2
 
Kotlin For Android - Constructors and Control Flow (part 2 of 7)
Kotlin For Android - Constructors and Control Flow (part 2 of 7)Kotlin For Android - Constructors and Control Flow (part 2 of 7)
Kotlin For Android - Constructors and Control Flow (part 2 of 7)
 
LINQ Inside
LINQ InsideLINQ Inside
LINQ Inside
 
Incremental Development with Lisp: Building a Game and a Website
Incremental Development with Lisp: Building a Game and a WebsiteIncremental Development with Lisp: Building a Game and a Website
Incremental Development with Lisp: Building a Game and a Website
 
Alfresco the clojure way
Alfresco the clojure wayAlfresco the clojure way
Alfresco the clojure way
 
.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#
 
Elm: Make Yourself A Happy Front-end Web Developer
Elm: Make Yourself A Happy Front-end Web DeveloperElm: Make Yourself A Happy Front-end Web Developer
Elm: Make Yourself A Happy Front-end Web Developer
 
C# Today and Tomorrow
C# Today and TomorrowC# Today and Tomorrow
C# Today and Tomorrow
 

Viewers also liked (20)

los bracekts
los bracekts los bracekts
los bracekts
 
Adquirir una propiedad en españa en 7 pasos
Adquirir una propiedad en españa en 7 pasosAdquirir una propiedad en españa en 7 pasos
Adquirir una propiedad en españa en 7 pasos
 
Magonia getxo blog
Magonia  getxo blogMagonia  getxo blog
Magonia getxo blog
 
Pairform cci formpro
Pairform   cci formproPairform   cci formpro
Pairform cci formpro
 
Copa menstrual y esponjas vaginales
Copa menstrual y esponjas vaginalesCopa menstrual y esponjas vaginales
Copa menstrual y esponjas vaginales
 
Servidor web lamp
Servidor web lampServidor web lamp
Servidor web lamp
 
Niquel
NiquelNiquel
Niquel
 
Dossier ii torneo once caballeros c.f.
Dossier ii torneo once caballeros c.f.Dossier ii torneo once caballeros c.f.
Dossier ii torneo once caballeros c.f.
 
2013 brand id&print
2013 brand id&print2013 brand id&print
2013 brand id&print
 
Una modesta proposición
Una modesta proposiciónUna modesta proposición
Una modesta proposición
 
Historia parte 2
Historia parte 2Historia parte 2
Historia parte 2
 
Av technika 4
Av technika 4Av technika 4
Av technika 4
 
Project Management Diploma with Instructors
Project Management Diploma with InstructorsProject Management Diploma with Instructors
Project Management Diploma with Instructors
 
9Guia1
9Guia19Guia1
9Guia1
 
C2B2 vFabric Hyperic Kickstart
C2B2 vFabric Hyperic KickstartC2B2 vFabric Hyperic Kickstart
C2B2 vFabric Hyperic Kickstart
 
Tams 2012
Tams 2012Tams 2012
Tams 2012
 
Accesus - Catalogo andamio para vias ferroviarias
Accesus - Catalogo andamio para vias ferroviariasAccesus - Catalogo andamio para vias ferroviarias
Accesus - Catalogo andamio para vias ferroviarias
 
Presentacion corporativa sevenminds agosto2012 (1)
Presentacion corporativa sevenminds agosto2012 (1)Presentacion corporativa sevenminds agosto2012 (1)
Presentacion corporativa sevenminds agosto2012 (1)
 
Principios de Diseño Sustentable (resumen)
Principios de Diseño Sustentable (resumen)Principios de Diseño Sustentable (resumen)
Principios de Diseño Sustentable (resumen)
 
Catalogo CTM 2015
Catalogo CTM 2015Catalogo CTM 2015
Catalogo CTM 2015
 

Similar to Scala for rubyists

Scala for Java Programmers
Scala for Java ProgrammersScala for Java Programmers
Scala for Java ProgrammersEric Pederson
 
Functional programming with Ruby - can make you look smart
Functional programming with Ruby - can make you look smartFunctional programming with Ruby - can make you look smart
Functional programming with Ruby - can make you look smartChen Fisher
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scalapramode_ce
 
Introduction to scala
Introduction to scalaIntroduction to scala
Introduction to scalaMichel Perez
 
The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)jeffz
 
Intro to Functional Programming
Intro to Functional ProgrammingIntro to Functional Programming
Intro to Functional ProgrammingAndraž Bajt
 
Scala - just good for Java shops?
Scala - just good for Java shops?Scala - just good for Java shops?
Scala - just good for Java shops?Sarah Mount
 
Scala is java8.next()
Scala is java8.next()Scala is java8.next()
Scala is java8.next()daewon jeong
 
Kotlin boost yourproductivity
Kotlin boost yourproductivityKotlin boost yourproductivity
Kotlin boost yourproductivitynklmish
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojureAbbas Raza
 
20160520 what youneedtoknowaboutlambdas
20160520 what youneedtoknowaboutlambdas20160520 what youneedtoknowaboutlambdas
20160520 what youneedtoknowaboutlambdasshinolajla
 
Introduction to Asynchronous scala
Introduction to Asynchronous scalaIntroduction to Asynchronous scala
Introduction to Asynchronous scalaStratio
 
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time APIModern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time APIGanesh Samarthyam
 
FP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyondFP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyondMario Fusco
 
Светлана Исакова «Язык Kotlin»
Светлана Исакова «Язык Kotlin»Светлана Исакова «Язык Kotlin»
Светлана Исакова «Язык Kotlin»e-Legion
 
The Kotlin Programming Language, Svetlana Isakova
The Kotlin Programming Language, Svetlana IsakovaThe Kotlin Programming Language, Svetlana Isakova
The Kotlin Programming Language, Svetlana IsakovaVasil Remeniuk
 

Similar to Scala for rubyists (20)

Scala in a nutshell by venkat
Scala in a nutshell by venkatScala in a nutshell by venkat
Scala in a nutshell by venkat
 
Scala for Java Programmers
Scala for Java ProgrammersScala for Java Programmers
Scala for Java Programmers
 
Functional programming with Ruby - can make you look smart
Functional programming with Ruby - can make you look smartFunctional programming with Ruby - can make you look smart
Functional programming with Ruby - can make you look smart
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scala
 
Introduction to scala
Introduction to scalaIntroduction to scala
Introduction to scala
 
The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)
 
Intro to Functional Programming
Intro to Functional ProgrammingIntro to Functional Programming
Intro to Functional Programming
 
Scala - just good for Java shops?
Scala - just good for Java shops?Scala - just good for Java shops?
Scala - just good for Java shops?
 
Scala is java8.next()
Scala is java8.next()Scala is java8.next()
Scala is java8.next()
 
Kotlin boost yourproductivity
Kotlin boost yourproductivityKotlin boost yourproductivity
Kotlin boost yourproductivity
 
Coding in Style
Coding in StyleCoding in Style
Coding in Style
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
 
20160520 what youneedtoknowaboutlambdas
20160520 what youneedtoknowaboutlambdas20160520 what youneedtoknowaboutlambdas
20160520 what youneedtoknowaboutlambdas
 
Introduction to Asynchronous scala
Introduction to Asynchronous scalaIntroduction to Asynchronous scala
Introduction to Asynchronous scala
 
Scala in Places API
Scala in Places APIScala in Places API
Scala in Places API
 
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time APIModern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
 
FP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyondFP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyond
 
Светлана Исакова «Язык Kotlin»
Светлана Исакова «Язык Kotlin»Светлана Исакова «Язык Kotlin»
Светлана Исакова «Язык Kotlin»
 
The Kotlin Programming Language, Svetlana Isakova
The Kotlin Programming Language, Svetlana IsakovaThe Kotlin Programming Language, Svetlana Isakova
The Kotlin Programming Language, Svetlana Isakova
 
Scala ntnu
Scala ntnuScala ntnu
Scala ntnu
 

Recently uploaded

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 

Recently uploaded (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

Scala for rubyists

  • 1. Scala for Rubyists Make your ideas come true by Michel Perez www.mrkaspa.com
  • 2. Ruby :D FELICIDAD TIPADO DINAMICO GEMS NO IDE DOCUMENTACION FACIL DE APRENDER
  • 3. Ruby :( PERFORMANCE ESCALABILIDAD PROG FUNCIONAL MANTENIBILIDAD CONCURRENCIA
  • 4.
  • 5. I <3 Java - JVM - Libraries - Performance - Escalabilidad - Mantenibilidad SCALA CLOJURE JRUBYGROOVY
  • 6. 6
  • 7. 7 PROS CONS Primitivas de concurrencia Desarrollado por Google Tiempo de compilación Lenguaje compilado Lenguaje tipado Sintaxis old style Demasiado imperativo Poco funcional Inmutabilidad
  • 8. 8 PROS CONS Primitivas de concurrencia Erlang Lenguaje interpretado Funcional Muy nuevo
  • 9. 9 PROS CONS Primitivas de concurrencia Funcional JVM Lenguaje interpretado Sistema de tipado opcional LISP
  • 10. 10 PROS CONS Akka Funcional JVM Tipado Compilado Tiempo de compilación Curva de aprendizaje Gestión de dependencias
  • 11. Programacion funcional FUNCIONES Y MAS FUNCIONES INMUTABILIDAD CURRYING CLOSURES LAZY EVALUATION PATTERN MATCHING CAMBIA LA MANERA EN COMO PROGRAMAS
  • 12. Scala Variables? 12 val labels = Set(“") val labels = Set[String](“”) var labels = Set[String](“”) Y los tipos? Colecciones Inmutables Syntaxis para generics <?> NO HAY ; :D Que es val ?
  • 13. Scala OOP + FP 13 No es la OOP el demonio? Un buen programador de scala no usa side efect Funciones puras Usa OOP para abstraer datos class Rational(x: Int, y: Int) { def this(x: Int) = this(x, 1) private def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b) private val g = gcd(x, y) def numer = x / g def denom = y / g def < (o: Rational) = numer * o.denom < o.numer * denom def > (o: Rational) = !(this < o) def +(o: Rational) = { new Rational(numer * o.denom + denom * o.numer, denom * o.denom) } def -(o: Rational) = { this + (-o) } def unary_- = Rational(-numer, denom) override def toString = { numer + "/" + denom } } Cada cambio de estado genera un nuevo objeto
  • 14. Scala OOP 14 Case class -> get, set, constructor auto Traits son similares a los modulos en Ruby Generic clases/traits Singleton Object case class SocialNetwork(id: String, name: String) trait LinkedList[+A] { def isEmpty: Boolean def head: A def tail: LinkedList[A] def at(index: Int): A def prepend[B >: A](elem: B): LinkedList[B] = new Cons(elem, this) } object Nil extends LinkedList[Nothing] { class Cons[A](val head: A, val tail: LinkedList[A]) extends LinkedList[A] {
  • 15. Scala Functions 15 Toda funciona debe tener un tipo de retorno(type inference) Funciones como parámetros Retorna funciones Vector.fill(queens.length)("* “) .updated(col, "X ").mkString def lambda = (x: Int) => x + 1 val multiplier = (i:Int) => i * 10 def sumComp(a: Int): (Int) => Int = { def sum(b: Int) = a + b } val fun = sumComp(5) fun(1) def sumComp(a: Int)(b: Int): Int = { a + b } Currying
  • 16. Pattern Matching 16 Es un Super Switchval secondElement = List(1,2,3) match { case x :: y :: xs => y case _ => 0 } val foodItem = "porridge" def goldilocks(expr: Any) = expr match { case (`foodItem`, _) => "eating" case ("chair", "Mama") => "sitting" case ("bed", "Baby") => "sleeping" case _ => "what?" } goldilocks(("porridge", "Papa")) Compara y extrae al mismo tiempo
  • 17. Implicits 17 Parametros inyectados en un metodo o constructor de manera implicita Sirve para realizar conversiones automaticas implicit def implChange(str:String):Int = new Integer(str) def sum(a:Int, b:Int):Int = a +b sum("1", 2)
  • 18. Monads 18 map, flatMap, filter for comprehension def readAsync(): Future[Option[List[String]]] = Future { readFile() } def readFile(): Option[List[String]] = Try { Source.fromURL("/tmp/file.txt").getLines().toList } toOption val futSize: Future[Int] = for { result <- readAsync() list <- result } yield list.size val futSizeMap: Future[Option[Int]] = readAsync().map { result: Option[List[String]] => result.map((list: List[String]) => list.size) } Future, Option, Try, Either
  • 19. Actors 19 Hilos livianos Orientados a eventos class BloodRequester extends Actor { implicit val executor = context.dispatcher override def receive: Receive = { case BloodRequest(request) => DonorDAO.findNear(request).map { donors => donors.foreach { donor => facebookNotifier ! FacebookNotify(donor, request) } } } } Se reinician en caso de fallas Supervisión
  • 20. ScalaTest 20 Test Unit trait NeoTest extends FunSpec with MustMatchers with BeforeAndAfterAll with BeforeAndAfterEach { override def beforeEach(): Unit = { NeoDBCleaner.cleanDB() } describe("UserDAOs") { it("creates an user an checks the default group") { withUser { (user, saved) => saved must be(true) val query = s"""match (a:user {id: "${user.id.getOrElse("")}"})-[c:has_group]->(b:group) return a, b, c""" val result = Await.result(NeoQuery.executeQuery[UserLogin, Group, HasGroupLogin](query), 2 seconds) result.length must be(1) } } } } Multiples Pardigmas TDD BDD
  • 21. Scala wants U ;) 21 https://www.coursera.org/course/progfun http://scala-exercises.47deg.com/koans