SlideShare une entreprise Scribd logo
1  sur  25
Télécharger pour lire hors ligne
Scala Developers
Barcelona (#scalabcn)
Welcome Scala Newbies
Autumn Edition (sept 2013)
sponsored by special appearance Jordi Pradel (@agile_jordi)
Ignasi Marimon-Clos (@ignasi35)
divendres 27 de setembre de 13
thanks!
divendres 27 de setembre de 13
about me
n. /iŋ'nazi/
1) problem solver, Garbage Collector, mostly
java, learning scala, some agile
2) kayaker
3) under construction
4) wears glasses
divendres 27 de setembre de 13
about me
jordi pradel - @agile_jordi
1) agile software developer
2) agile punk
3) scala practitioner
4) glasses, braid
divendres 27 de setembre de 13
about you
divendres 27 de setembre de 13
Start with why
divendres 27 de setembre de 13
This is your (jee) life
public class PurchaseProcessorFactory {
	 public PurchaseProcessor forPoyPol() {
	 	 return new PurchaseProcessor() {
	 	 	 @Override
	 	 	 public void process(Purchase t) {
	 	 	 	 // process t using PoyPol system
	 	 	 }
	 	 };
	 }
	 public PurchaseProcessor forViso() {
	 	 return new PurchaseProcessor() {
	 	 	 @Override
	 	 	 public void process(Purchase t) {
	 	 	 	 // process t using Viso
	 	 	 }
	 	 };
	 }
}
divendres 27 de setembre de 13
This is your (jee) life
package com.meetup.java;
import java.util.Collections;
import java.util.List;
public class Purchase {
	 private final List<Item> _items;
	 public Purchase(List<Item> items) {
	 	 super();
	 	 _items = items;
	 }
	 public List<Item> getItems() {
	 	 return Collections.unmodifiableList(_items);
	 }
	 @Override
	 public String toString() {
	 	 return "Purchase [_items=" + _items + "]";
	 }
	 @Override
	 public int hashCode() {
	 	 final int prime = 31;
	 	 int result = 1;
	 	 result = prime * result + ((_items == null) ? 0 : _items.hashCode());
	 	 return result;
	 }
	 @Override
	 public boolean equals(Object obj) {
	 	 if (this == obj)
	 	 	 return true;
	 	 if (obj == null)
	 	 	 return false;
	 	 if (getClass() != obj.getClass())
package com.meetup.java;
public class Item {
	 private final String _productId;
	 private final int _rupees;
	 public Item(String _productId, int _rupees) {
	 	 super();
	 	 this._productId = _productId;
	 	 this._rupees = _rupees;
	 }
	 @Override
	 public String toString() {
	 	 return "Item [_productId=" + _productId + ", _rupees=" + _rupees + "]";
	 }
	 @Override
	 public int hashCode() {
	 	 final int prime = 31;
	 	 int result = 1;
	 	 result = prime * result
	 	 	 	 + ((_productId == null) ? 0 : _productId.hashCode());
	 	 result = prime * result + _rupees;
	 	 return result;
	 }
	 @Override
	 public boolean equals(Object obj) {
	 	 if (this == obj)
	 	 	 return true;
	 	 if (obj == null)
	 	 	 return false;
	 	 if (getClass() != obj.getClass())
	 	 	 return false;
	 	 Item other = (Item) obj;
	 	 if (_productId == null) {
	 	 	 if (other._productId != null)
	 	 	 	 return false;
	 	 } else if (!_productId.equals(other._productId))
	 	 	 return false;divendres 27 de setembre de 13
What’s wrong there?
• class per file (sort of)
• unnecessary redefinition of stuff
• duplicate intent
• (DRY is not only about copy/paste)
• unmaintainability
• JAVA
divendres 27 de setembre de 13
Let’s redo that
package com.meetup.scala
case class Item(productId : String, rupees : Int)
case class Purchase(items : List[Item])
trait Processor[T] {
def process(t : T) : Unit
}
trait PurchaseProcessor extends Processor[Purchase]
object PurchaseProcessor {
val forPoyPol = new PurchaseProcessor {
def process(p : Purchase) = println(p) // do real stuff here
}
val forViso = new PurchaseProcessor {
def process(p : Purchase) = println(p) // do real stuff here
}
}
fits in one slide (and fixes one bug!)
divendres 27 de setembre de 13
Entering decompiler
(Insert picture of Morpheus holding red pill and blue pill)
divendres 27 de setembre de 13
case classes
• all boilerplate gone
• no equals/hashCode/toString maintenance
• immutable
• named params
• optional params (not shown)
• pattern matching
divendres 27 de setembre de 13
pater-WAT ??
divendres 27 de setembre de 13
Pattern Matching
def run(input : Any) = {
input match {
case s : String => println(s)
case i : Int => println("A number: " + i)
case _ => println("something else")
}
} //> run: (input: Any)Unit
run("A long time ago in a galaxy far far away...")
//> A long time ago in a galaxy
/ /> far far away...
run(234) //> A number: 234
run(() => 42) //> something else
Worksheet rocks! REPL rocks!
divendres 27 de setembre de 13
Functions!
run(() => 42) //> something else WTF???
• Functions as first class citizens
• Functional Progamming! Bitches!
• parens + arrow + statements
• ‘return’ keyword is optional
• SOLUTION:A function with no params that simply returns ’42’
divendres 27 de setembre de 13
Functional Programming
• referential transparency
• immutability (see case classes)
• no side effects
• separate data from behavior
• monads *
* We don’t know what monads are but a talk about
FP requires using the word monad
divendres 27 de setembre de 13
Back to coding!
divendres 27 de setembre de 13
so far
• conciseness
• case classes
• traits
• multi-hierarchy
• pattern matching
• Functions
• immutability
• monads *
• spaces/parens/dots
• return keyword
divendres 27 de setembre de 13
divendres 27 de setembre de 13
Yak shaving
• Any seemingly pointless activity which is actually necessary
to solve a problem which solves a problem which, several
levels of recursion later, solves the real problem you're
working on.
http://www.urbandictionary.com/define.php?term=yak%20shaving
divendres 27 de setembre de 13
conclusions
• A lot of syntactic sugar
• Many small features but all related
• functional!
• object oriented (unlike clojure/erlang/...)
• typesafe without the pain
• Classes, Objects, Companions, Traits...
divendres 27 de setembre de 13
other stuff
• Macros
• Currying, partially applied functions, ...
• Structural Typing (see? we _do_ have duck typing!)
• implicits
• Value classes
• Lazy evaluation
• Tail recursion
• ...
divendres 27 de setembre de 13
want more?
• Intro to scala: http://scalacamp.pl/intro/#/start
• Twitter’s Scala School: http://twitter.github.io/scala_school/
• 99 problems in scala: http://aperiodic.net/phil/scala/s-99/
• Scala Puzzles: http://scalapuzzlers.com/
• “Programming in Scala” (1st ed free online: http://www.artima.com/pins1ed/)
• Scala Developers Barcelona Meetup
divendres 27 de setembre de 13
thanks!
divendres 27 de setembre de 13
Oh! And we know what monads are. ;-)
divendres 27 de setembre de 13

Contenu connexe

Tendances

Java script object model
Java script object modelJava script object model
Java script object modelJames Hsieh
 
JavaScript For CSharp Developer
JavaScript For CSharp DeveloperJavaScript For CSharp Developer
JavaScript For CSharp DeveloperSarvesh Kushwaha
 
Beginning Object-Oriented JavaScript
Beginning Object-Oriented JavaScriptBeginning Object-Oriented JavaScript
Beginning Object-Oriented JavaScriptStoyan Stefanov
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScriptFu Cheng
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript BasicsMindfire Solutions
 
Converting your JS library to a jQuery plugin
Converting your JS library to a jQuery pluginConverting your JS library to a jQuery plugin
Converting your JS library to a jQuery pluginthehoagie
 
JavaScript - Chapter 5 - Operators
 JavaScript - Chapter 5 - Operators JavaScript - Chapter 5 - Operators
JavaScript - Chapter 5 - OperatorsWebStackAcademy
 
Understanding Object Oriented Javascript - Coffee@DBG June
Understanding Object Oriented Javascript - Coffee@DBG JuneUnderstanding Object Oriented Javascript - Coffee@DBG June
Understanding Object Oriented Javascript - Coffee@DBG JuneDeepu S Nath
 
Javascript ES6
Javascript ES6Javascript ES6
Javascript ES6Huy Doan
 
Javascript basics for automation testing
Javascript  basics for automation testingJavascript  basics for automation testing
Javascript basics for automation testingVikas Thange
 
TDD and mobile development: some forgotten techniques, illustrated with Android
TDD and mobile development: some forgotten techniques, illustrated with AndroidTDD and mobile development: some forgotten techniques, illustrated with Android
TDD and mobile development: some forgotten techniques, illustrated with AndroidCodemotion
 
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)raja kvk
 
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptObject Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptForziatech
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScriptDonald Sipe
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScriptMichael Girouard
 

Tendances (20)

JavaScript operators
JavaScript operatorsJavaScript operators
JavaScript operators
 
Javascript tid-bits
Javascript tid-bitsJavascript tid-bits
Javascript tid-bits
 
Java script object model
Java script object modelJava script object model
Java script object model
 
JavaScript For CSharp Developer
JavaScript For CSharp DeveloperJavaScript For CSharp Developer
JavaScript For CSharp Developer
 
Beginning Object-Oriented JavaScript
Beginning Object-Oriented JavaScriptBeginning Object-Oriented JavaScript
Beginning Object-Oriented JavaScript
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript Basics
 
Converting your JS library to a jQuery plugin
Converting your JS library to a jQuery pluginConverting your JS library to a jQuery plugin
Converting your JS library to a jQuery plugin
 
Javascript
JavascriptJavascript
Javascript
 
JavaScript - Chapter 5 - Operators
 JavaScript - Chapter 5 - Operators JavaScript - Chapter 5 - Operators
JavaScript - Chapter 5 - Operators
 
Understanding Object Oriented Javascript - Coffee@DBG June
Understanding Object Oriented Javascript - Coffee@DBG JuneUnderstanding Object Oriented Javascript - Coffee@DBG June
Understanding Object Oriented Javascript - Coffee@DBG June
 
Javascript ES6
Javascript ES6Javascript ES6
Javascript ES6
 
Javascript basics for automation testing
Javascript  basics for automation testingJavascript  basics for automation testing
Javascript basics for automation testing
 
Java Script Best Practices
Java Script Best PracticesJava Script Best Practices
Java Script Best Practices
 
TDD and mobile development: some forgotten techniques, illustrated with Android
TDD and mobile development: some forgotten techniques, illustrated with AndroidTDD and mobile development: some forgotten techniques, illustrated with Android
TDD and mobile development: some forgotten techniques, illustrated with Android
 
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)
 
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptObject Oriented Programming In JavaScript
Object Oriented Programming In JavaScript
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
 

Similaire à Scala Newbies Welcomed at Autumn Meetup

Everything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-insEverything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-insAndrew Dupont
 
Scalable JavaScript
Scalable JavaScriptScalable JavaScript
Scalable JavaScriptYnon Perek
 
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.ppt
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.pptDESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.ppt
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.pptAntoJoseph36
 
The things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and AkkaThe things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and AkkaKonrad Malawski
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScriptJulie Iskander
 
Front end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript coreFront end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript coreWeb Zhao
 
CDI do básico ao avançado
CDI do básico ao avançadoCDI do básico ao avançado
CDI do básico ao avançadoAlberto Souza
 
JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)Eduard Tomàs
 
JavaScript in 2016
JavaScript in 2016JavaScript in 2016
JavaScript in 2016Codemotion
 
Awesomeness of JavaScript…almost
Awesomeness of JavaScript…almostAwesomeness of JavaScript…almost
Awesomeness of JavaScript…almostQuinton Sheppard
 
Objects, Testing, and Responsibility
Objects, Testing, and ResponsibilityObjects, Testing, and Responsibility
Objects, Testing, and Responsibilitymachuga
 
Property based tests and where to find them - Andrzej Jóźwiak - TomTom Webina...
Property based tests and where to find them - Andrzej Jóźwiak - TomTom Webina...Property based tests and where to find them - Andrzej Jóźwiak - TomTom Webina...
Property based tests and where to find them - Andrzej Jóźwiak - TomTom Webina...Andrzej Jóźwiak
 
Getting the Most Out of jQuery Widgets
Getting the Most Out of jQuery WidgetsGetting the Most Out of jQuery Widgets
Getting the Most Out of jQuery Widgetsvelveeta_512
 
Modeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based GamesModeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based GamesRay Toal
 
Effective Java with Groovy - How Language Influences Adoption of Good Practices
Effective Java with Groovy - How Language Influences Adoption of Good PracticesEffective Java with Groovy - How Language Influences Adoption of Good Practices
Effective Java with Groovy - How Language Influences Adoption of Good PracticesNaresha K
 
Ciconf 2012 - Better than Ad-hoc
Ciconf 2012 - Better than Ad-hocCiconf 2012 - Better than Ad-hoc
Ciconf 2012 - Better than Ad-hocCalvin Froedge
 

Similaire à Scala Newbies Welcomed at Autumn Meetup (20)

Everything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-insEverything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-ins
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
OOP
OOPOOP
OOP
 
25-functions.ppt
25-functions.ppt25-functions.ppt
25-functions.ppt
 
Scalable JavaScript
Scalable JavaScriptScalable JavaScript
Scalable JavaScript
 
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.ppt
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.pptDESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.ppt
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.ppt
 
The things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and AkkaThe things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and Akka
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
 
Front end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript coreFront end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript core
 
CDI do básico ao avançado
CDI do básico ao avançadoCDI do básico ao avançado
CDI do básico ao avançado
 
JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)
 
JavaScript in 2016
JavaScript in 2016JavaScript in 2016
JavaScript in 2016
 
Awesomeness of JavaScript…almost
Awesomeness of JavaScript…almostAwesomeness of JavaScript…almost
Awesomeness of JavaScript…almost
 
Objects, Testing, and Responsibility
Objects, Testing, and ResponsibilityObjects, Testing, and Responsibility
Objects, Testing, and Responsibility
 
JavaScript Essentials
JavaScript EssentialsJavaScript Essentials
JavaScript Essentials
 
Property based tests and where to find them - Andrzej Jóźwiak - TomTom Webina...
Property based tests and where to find them - Andrzej Jóźwiak - TomTom Webina...Property based tests and where to find them - Andrzej Jóźwiak - TomTom Webina...
Property based tests and where to find them - Andrzej Jóźwiak - TomTom Webina...
 
Getting the Most Out of jQuery Widgets
Getting the Most Out of jQuery WidgetsGetting the Most Out of jQuery Widgets
Getting the Most Out of jQuery Widgets
 
Modeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based GamesModeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based Games
 
Effective Java with Groovy - How Language Influences Adoption of Good Practices
Effective Java with Groovy - How Language Influences Adoption of Good PracticesEffective Java with Groovy - How Language Influences Adoption of Good Practices
Effective Java with Groovy - How Language Influences Adoption of Good Practices
 
Ciconf 2012 - Better than Ad-hoc
Ciconf 2012 - Better than Ad-hocCiconf 2012 - Better than Ad-hoc
Ciconf 2012 - Better than Ad-hoc
 

Plus de Ignasi Marimon-Clos i Sunyol

Plus de Ignasi Marimon-Clos i Sunyol (9)

The Emperor Has No Docs (Geecon Oct'23)
The Emperor Has No Docs (Geecon Oct'23)The Emperor Has No Docs (Geecon Oct'23)
The Emperor Has No Docs (Geecon Oct'23)
 
Jeroglificos, Minotauros y la factura de la luz
Jeroglificos, Minotauros y la factura de la luzJeroglificos, Minotauros y la factura de la luz
Jeroglificos, Minotauros y la factura de la luz
 
Contributing to Akka (Hacktoberfest 2020)
Contributing to Akka (Hacktoberfest 2020)Contributing to Akka (Hacktoberfest 2020)
Contributing to Akka (Hacktoberfest 2020)
 
Contributing to OSS (Scalator 2020-01-22)
Contributing to OSS (Scalator 2020-01-22)Contributing to OSS (Scalator 2020-01-22)
Contributing to OSS (Scalator 2020-01-22)
 
Reactive Microsystems (Sw Crafters Barcelona 2018)
Reactive Microsystems (Sw Crafters Barcelona 2018)Reactive Microsystems (Sw Crafters Barcelona 2018)
Reactive Microsystems (Sw Crafters Barcelona 2018)
 
Lagom Workshop BarcelonaJUG 2017-06-08
Lagom Workshop  BarcelonaJUG 2017-06-08Lagom Workshop  BarcelonaJUG 2017-06-08
Lagom Workshop BarcelonaJUG 2017-06-08
 
Intro scala for rubyists (ironhack)
Intro scala for rubyists (ironhack)Intro scala for rubyists (ironhack)
Intro scala for rubyists (ironhack)
 
Functional Programming in JAVA 8
Functional Programming in JAVA 8Functional Programming in JAVA 8
Functional Programming in JAVA 8
 
Spray & Maven Intro for Scala Barcelona Developers Meetup
Spray & Maven Intro for Scala Barcelona Developers MeetupSpray & Maven Intro for Scala Barcelona Developers Meetup
Spray & Maven Intro for Scala Barcelona Developers Meetup
 

Dernier

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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 

Dernier (20)

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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

Scala Newbies Welcomed at Autumn Meetup

  • 1. Scala Developers Barcelona (#scalabcn) Welcome Scala Newbies Autumn Edition (sept 2013) sponsored by special appearance Jordi Pradel (@agile_jordi) Ignasi Marimon-Clos (@ignasi35) divendres 27 de setembre de 13
  • 2. thanks! divendres 27 de setembre de 13
  • 3. about me n. /iŋ'nazi/ 1) problem solver, Garbage Collector, mostly java, learning scala, some agile 2) kayaker 3) under construction 4) wears glasses divendres 27 de setembre de 13
  • 4. about me jordi pradel - @agile_jordi 1) agile software developer 2) agile punk 3) scala practitioner 4) glasses, braid divendres 27 de setembre de 13
  • 5. about you divendres 27 de setembre de 13
  • 6. Start with why divendres 27 de setembre de 13
  • 7. This is your (jee) life public class PurchaseProcessorFactory { public PurchaseProcessor forPoyPol() { return new PurchaseProcessor() { @Override public void process(Purchase t) { // process t using PoyPol system } }; } public PurchaseProcessor forViso() { return new PurchaseProcessor() { @Override public void process(Purchase t) { // process t using Viso } }; } } divendres 27 de setembre de 13
  • 8. This is your (jee) life package com.meetup.java; import java.util.Collections; import java.util.List; public class Purchase { private final List<Item> _items; public Purchase(List<Item> items) { super(); _items = items; } public List<Item> getItems() { return Collections.unmodifiableList(_items); } @Override public String toString() { return "Purchase [_items=" + _items + "]"; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((_items == null) ? 0 : _items.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) package com.meetup.java; public class Item { private final String _productId; private final int _rupees; public Item(String _productId, int _rupees) { super(); this._productId = _productId; this._rupees = _rupees; } @Override public String toString() { return "Item [_productId=" + _productId + ", _rupees=" + _rupees + "]"; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((_productId == null) ? 0 : _productId.hashCode()); result = prime * result + _rupees; return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Item other = (Item) obj; if (_productId == null) { if (other._productId != null) return false; } else if (!_productId.equals(other._productId)) return false;divendres 27 de setembre de 13
  • 9. What’s wrong there? • class per file (sort of) • unnecessary redefinition of stuff • duplicate intent • (DRY is not only about copy/paste) • unmaintainability • JAVA divendres 27 de setembre de 13
  • 10. Let’s redo that package com.meetup.scala case class Item(productId : String, rupees : Int) case class Purchase(items : List[Item]) trait Processor[T] { def process(t : T) : Unit } trait PurchaseProcessor extends Processor[Purchase] object PurchaseProcessor { val forPoyPol = new PurchaseProcessor { def process(p : Purchase) = println(p) // do real stuff here } val forViso = new PurchaseProcessor { def process(p : Purchase) = println(p) // do real stuff here } } fits in one slide (and fixes one bug!) divendres 27 de setembre de 13
  • 11. Entering decompiler (Insert picture of Morpheus holding red pill and blue pill) divendres 27 de setembre de 13
  • 12. case classes • all boilerplate gone • no equals/hashCode/toString maintenance • immutable • named params • optional params (not shown) • pattern matching divendres 27 de setembre de 13
  • 13. pater-WAT ?? divendres 27 de setembre de 13
  • 14. Pattern Matching def run(input : Any) = { input match { case s : String => println(s) case i : Int => println("A number: " + i) case _ => println("something else") } } //> run: (input: Any)Unit run("A long time ago in a galaxy far far away...") //> A long time ago in a galaxy / /> far far away... run(234) //> A number: 234 run(() => 42) //> something else Worksheet rocks! REPL rocks! divendres 27 de setembre de 13
  • 15. Functions! run(() => 42) //> something else WTF??? • Functions as first class citizens • Functional Progamming! Bitches! • parens + arrow + statements • ‘return’ keyword is optional • SOLUTION:A function with no params that simply returns ’42’ divendres 27 de setembre de 13
  • 16. Functional Programming • referential transparency • immutability (see case classes) • no side effects • separate data from behavior • monads * * We don’t know what monads are but a talk about FP requires using the word monad divendres 27 de setembre de 13
  • 17. Back to coding! divendres 27 de setembre de 13
  • 18. so far • conciseness • case classes • traits • multi-hierarchy • pattern matching • Functions • immutability • monads * • spaces/parens/dots • return keyword divendres 27 de setembre de 13
  • 19. divendres 27 de setembre de 13
  • 20. Yak shaving • Any seemingly pointless activity which is actually necessary to solve a problem which solves a problem which, several levels of recursion later, solves the real problem you're working on. http://www.urbandictionary.com/define.php?term=yak%20shaving divendres 27 de setembre de 13
  • 21. conclusions • A lot of syntactic sugar • Many small features but all related • functional! • object oriented (unlike clojure/erlang/...) • typesafe without the pain • Classes, Objects, Companions, Traits... divendres 27 de setembre de 13
  • 22. other stuff • Macros • Currying, partially applied functions, ... • Structural Typing (see? we _do_ have duck typing!) • implicits • Value classes • Lazy evaluation • Tail recursion • ... divendres 27 de setembre de 13
  • 23. want more? • Intro to scala: http://scalacamp.pl/intro/#/start • Twitter’s Scala School: http://twitter.github.io/scala_school/ • 99 problems in scala: http://aperiodic.net/phil/scala/s-99/ • Scala Puzzles: http://scalapuzzlers.com/ • “Programming in Scala” (1st ed free online: http://www.artima.com/pins1ed/) • Scala Developers Barcelona Meetup divendres 27 de setembre de 13
  • 24. thanks! divendres 27 de setembre de 13
  • 25. Oh! And we know what monads are. ;-) divendres 27 de setembre de 13