SlideShare ist ein Scribd-Unternehmen logo
1 von 33
Downloaden Sie, um offline zu lesen
Introducing Scala
IQSS Tech-Talk, 2013-06-27
Michael Bar-Sinai
Sunday, 4 August, 13
Based in part on Scala for the impatient, Scala for
java programmers tutorial at Typesafe.com, and Prof.
Mayer Goldberg advanced programming class in
Ben-Gurion university of the Negev, Israel
Sunday, 4 August, 13
In a Few Bullets
Developed in 2001, by Martin Odersky, EPFL Professor
Runs on the JVM (also, CLR)
Statically typed and with concise syntax
Object oriented and functional
Clean and elegant design
Strong collection framework
Expression-only, DSL friendly, advanced features
Sunday, 4 August, 13
In a Few Bullets
Developed in 2001, by Martin Odersky, EPFL Professor
Runs on the JVM (also, CLR)
Statically typed and with concise syntax
Object oriented and functional
Clean and elegant design
Strong collection framework
Expression-only, DSL friendly, advanced features
Sunday, 4 August, 13
In a Few Bullets
Developed in 2001, by Martin Odersky, EPFL Professor
Runs on the JVM (also, CLR)
Statically typed and with concise syntax
Object oriented and functional
Clean and elegant design
Strong collection framework
Expression-only, DSL friendly, advanced features
Sunday, 4 August, 13
Sunday, 4 August, 13
What is a...
Computation?
Sunday, 4 August, 13
What is a computation?
PROCEDURAL
Finite automaton working on
an inïŹnite tape
...0 1 110101110
Sunday, 4 August, 13
What is a computation?
PROCEDURAL FUNCTIONAL
Finite automaton working on
an inïŹnite tape
...0 1 110101110
Data ïŹ‚owing through a
program
f(x) /2 R
f(6) 2 R
Sunday, 4 August, 13
REPL
SEE ACCOMPANYING FILES
Sunday, 4 August, 13
List Operations
Run some binary operator on the list items and an
intermediate results
fold, reduce, scan
Concurrent: aggregate,
reduce
ndlrowolleH
Sunday, 4 August, 13
List Operations
Run some binary operator on the list items and an
intermediate results
fold, reduce, scan
Concurrent: aggregate,
reduce
ndlrowolleH
Sunday, 4 August, 13
Expressions vs. Statements
STATEMENT
if ( map contains x ) {
map(x) = computeNewX(map(x))
} else {
map(x) = computeNewX( 0 )
}
Sunday, 4 August, 13
Expressions vs. Statements
STATEMENT
EXPRESSION
if ( map contains x ) {
map(x) = computeNewX(map(x))
} else {
map(x) = computeNewX( 0 )
}
map(x) = if ( map contains x )
computeNewX( map(x) )
else
computeNewX( 0 )
Sunday, 4 August, 13
Expressions vs. Statements
STATEMENT
EXPRESSION
if ( map contains x ) {
map(x) = computeNewX(map(x))
} else {
map(x) = computeNewX( 0 )
}
map(x) = if ( map contains x )
computeNewX( map(x) )
else
computeNewX( 0 )
ACTUAL SCALA CODE
map(x) = computeNewX( map.getOrElse(x,0) )
Sunday, 4 August, 13
Class Syntax
Classes have a primary constructor that is part of
the class deïŹnition
Clients can’t distinguish between getters and
direct ïŹeld access
Better privacy control
Sunday, 4 August, 13
Classes
class Person( var name:String, val id:Int ) {
! def greet = "Hello, my name is %s".format(name)
}
class Person2( name:String, val id:Int ) {
! def greet = "Hello, my name is %s".format(name)
}
class Person3( name:String, val id:Int ) {
! val greet = "Hello, my name is %s".format(name)
}
Sunday, 4 August, 13
Classes (cont.)
class Person4( aName:String, anId:Int ) {
! private val id = anId
! private[this] var pName = aName
! def name = pName
! def name_=( newName:String ) { pName = newName }
! override def toString = "[Person4 id:%d name:%s]".format(id,name)
}
Sunday, 4 August, 13
Multiple Inheritance
Would have been nice if it worked
It doesn’t
Java allowed only multiple
inheritance of interfaces
JDK8 would update this, slightly
Scala simulates multiple inheritance
using type linearization
Would have been nice if it worked
...it mostly does
A
B1
B2
C
A
B1
B2
C
Sunday, 4 August, 13
Traits
Almost like class:
Can have ïŹelds, protocols and behavior
(implementations)
Can’t have constructor parameters
Can require minimal interface from
implementing classes
Class can extend as many as needed
Types are generated at declaration point
Sunday, 4 August, 13
Objects
and the absence of static
Replace the static parts in java
Manual declaration of a runtime singletons
Classes can have “companion objects” that have
the same name
Good place for utility methods or special “apply”
methods
App trait allows script-like behavior
Sunday, 4 August, 13
Pattern Matching
Control structure that allows
switching
type inquiry
variable de-composition
Specialized Classes optimized for this
Sunday, 4 August, 13
Simple Pattern Matching
def toFuzzyStringInt( i:Int ) = i match {
! case 0 => "Nada"
! case 1 => "One"
! case 2 => "A Pair"
! case 12 => "a dozen"
! case _ if i<0 => "Less that zero"
! case _ => "%,d".format(i)
}
Sunday, 4 August, 13
Switch by Type
def prettyPrint( a:Any ) = a match {
! case i:Int => "%,d".format(i)
! case s:String => "[%s]".format(s)
! case sym:Symbol => ":%s".format(sym)
! case _ => a.toString
}
Sunday, 4 August, 13
Decomposition
First, meet the case class:
Regular class, but with immutable declared ïŹelds,
toString, equals and hashCode automatically
deïŹned
sealed abstract class Tree
case class Sum( l:Tree, r:Tree ) extends Tree
case class Var( n:String ) extends Tree
case class Con( v:Int ) extends Tree
Sunday, 4 August, 13
Decomposition
def evalTree( t:Tree, e:Map[String,Int] ): Int =
t match {
! case Sum(l,r) => evalTree(l, e) + evalTree(r,e)
! case Var( n ) => e(n)
! case Con( i ) => i
}
Allows downcasting, accessing sub-classes ïŹelds and
varying actions based on the class of the parameter, in a
single syntactical maneuver
Sunday, 4 August, 13
... In the real world
(merged,original) match {
case ( Pass(_), ( _, _) ) => true
case ( Unfixable(_), ( _, _) ) => false
case ( Fixable(_,t,_), (t1,t2) ) => f.ld<ld(t1)+ld(t2)
}
Given two strings, we need to decide whether it is more likely that they are
two separate words or one broken word
Sunday, 4 August, 13
... In the real world
(merged,original) match {
case ( Pass(_), ( _, _) ) => true
case ( Unfixable(_), ( _, _) ) => false
case ( Fixable(_,t,_), (t1,t2) ) => f.ld<ld(t1)+ld(t2)
}
ere are two ways of constructing a software design: One way is to make it so
simple that there are obviously no deficiencies, and the other way is to make it
so complicated that there are no obvious deficiencies. e first method is far
more diïŹƒcult.
-- C. A. R. Hoare, Turing Award lecture, 1980
Given two strings, we need to decide whether it is more likely that they are
two separate words or one broken word
Sunday, 4 August, 13
Option[T]
And the death of the NullPointerException
Indicates possibly missing values
Has two implementations: None and Some(t)
“Collection of at most one item”
Convention more than a language feature
Sunday, 4 August, 13
Functions as values
Creating new functions from existing ones
Powerful tool, but can get messy
Allows for DSL creation
def bind1( f:(Int,Int)=>Int, v:Int ) =
(a:Int)=>f(a,v)
Sunday, 4 August, 13
Not Covered
Creation of DSLs
Implicit conversions
Continuations
Frameworks
XML
Parsers/Combinators
Macros
Annotations
Genericity
Type System
Actors
Regular Expressions
Extractors
... many more
Sunday, 4 August, 13
Pointers
www.scala-lang.org
Typesafe.com
Scala for the Impatient, by Cay Horstmann (http://
horstmann.com/scala/)
First chapters available after registering with at Typesafe’s site
(google)
Sunday, 4 August, 13
Introducing Scala
IQSS Tech-Talk, 2013-06-27
Michael Bar-Sinai
THANKS
Sunday, 4 August, 13

Weitere Àhnliche Inhalte

Was ist angesagt?

Serverless Analytics with Amazon Redshift Spectrum, AWS Glue, and Amazon Quic...
Serverless Analytics with Amazon Redshift Spectrum, AWS Glue, and Amazon Quic...Serverless Analytics with Amazon Redshift Spectrum, AWS Glue, and Amazon Quic...
Serverless Analytics with Amazon Redshift Spectrum, AWS Glue, and Amazon Quic...Amazon Web Services
 
Composite pattern
Composite patternComposite pattern
Composite patternShakil Ahmed
 
Indexing Text and HTML Files with Solr
Indexing Text and HTML Files with SolrIndexing Text and HTML Files with Solr
Indexing Text and HTML Files with SolrLucidworks (Archived)
 
mySQL Workbench Guide (στα ΕλληΜÎčÎșÎŹ)
mySQL Workbench Guide (στα ΕλληΜÎčÎșÎŹ)mySQL Workbench Guide (στα ΕλληΜÎčÎșÎŹ)
mySQL Workbench Guide (στα ΕλληΜÎčÎșÎŹ)Fotis Kokkoras
 
Î Î±ÏÎżÏ…ÏƒÎŻÎ±ÏƒÎ· micro:bit & MakeCode
Î Î±ÏÎżÏ…ÏƒÎŻÎ±ÏƒÎ· micro:bit & MakeCodeÎ Î±ÏÎżÏ…ÏƒÎŻÎ±ÏƒÎ· micro:bit & MakeCode
Î Î±ÏÎżÏ…ÏƒÎŻÎ±ÏƒÎ· micro:bit & MakeCodePenelope Markellou
 
ă€æŒ”çż’ă€‘Reă‚ČăƒŒăƒ ç†è«–ć…„é–€ 珏2曞 -ăƒ©ăƒ™ăƒ«æł•ă‚’ć­ŠăŒă†-ă€€ć‰ăƒ»ćŸŒç·š
ă€æŒ”çż’ă€‘Reă‚ČăƒŒăƒ ç†è«–ć…„é–€ 珏2曞 -ăƒ©ăƒ™ăƒ«æł•ă‚’ć­ŠăŒă†-ă€€ć‰ăƒ»ćŸŒç·šă€æŒ”çż’ă€‘Reă‚ČăƒŒăƒ ç†è«–ć…„é–€ 珏2曞 -ăƒ©ăƒ™ăƒ«æł•ă‚’ć­ŠăŒă†-ă€€ć‰ăƒ»ćŸŒç·š
ă€æŒ”çż’ă€‘Reă‚ČăƒŒăƒ ç†è«–ć…„é–€ 珏2曞 -ăƒ©ăƒ™ăƒ«æł•ă‚’ć­ŠăŒă†-ă€€ć‰ăƒ»ćŸŒç·šssusere0a682
 
Session12 J2ME Generic Connection Framework
Session12 J2ME Generic Connection FrameworkSession12 J2ME Generic Connection Framework
Session12 J2ME Generic Connection Frameworkmuthusvm
 
ÎŸÎŽÎ·ÎłÏŒÏ‚ Dropbox ÎłÎčα ΔÎșπαÎčΎΔυτÎčÎșÎżÏÏ‚
ÎŸÎŽÎ·ÎłÏŒÏ‚ Dropbox ÎłÎčα ΔÎșπαÎčΎΔυτÎčÎșÎżÏÏ‚ÎŸÎŽÎ·ÎłÏŒÏ‚ Dropbox ÎłÎčα ΔÎșπαÎčΎΔυτÎčÎșÎżÏÏ‚
ÎŸÎŽÎ·ÎłÏŒÏ‚ Dropbox ÎłÎčα ΔÎșπαÎčΎΔυτÎčÎșÎżÏÏ‚Nikos Kaklamanos
 
Tokenization on the Node - Data Protection for Security and Compliance
Tokenization on the Node - Data Protection for Security and ComplianceTokenization on the Node - Data Protection for Security and Compliance
Tokenization on the Node - Data Protection for Security and ComplianceUlf Mattsson
 
ΕÎčÏƒÎ±ÎłÏ‰ÎłÎź στÎčς αρχές της ΔπÎčÏƒÏ„ÎźÎŒÎ·Ï‚ τωΜ Η/΄
ΕÎčÏƒÎ±ÎłÏ‰ÎłÎź στÎčς αρχές της ΔπÎčÏƒÏ„ÎźÎŒÎ·Ï‚ τωΜ Η/΄ΕÎčÏƒÎ±ÎłÏ‰ÎłÎź στÎčς αρχές της ΔπÎčÏƒÏ„ÎźÎŒÎ·Ï‚ τωΜ Η/΄
ΕÎčÏƒÎ±ÎłÏ‰ÎłÎź στÎčς αρχές της ΔπÎčÏƒÏ„ÎźÎŒÎ·Ï‚ τωΜ Η/΄Ministry of Education
 
Tα ÎŽÎżÎŒÎčÎșÎŹ Όέρη Ï„ÎżÏ… ÎŽÎčÎșÏ„ÏÎżÏ… Ï…Ï€ÎżÎ»ÎżÎłÎčστώΜ
Tα ÎŽÎżÎŒÎčÎșÎŹ Όέρη Ï„ÎżÏ… ÎŽÎčÎșÏ„ÏÎżÏ… Ï…Ï€ÎżÎ»ÎżÎłÎčστώΜTα ÎŽÎżÎŒÎčÎșÎŹ Όέρη Ï„ÎżÏ… ÎŽÎčÎșÏ„ÏÎżÏ… Ï…Ï€ÎżÎ»ÎżÎłÎčστώΜ
Tα ÎŽÎżÎŒÎčÎșÎŹ Όέρη Ï„ÎżÏ… ÎŽÎčÎșÏ„ÏÎżÏ… Ï…Ï€ÎżÎ»ÎżÎłÎčστώΜbasflor
 
Refactoring Applications using SOLID Principles
Refactoring Applications using SOLID PrinciplesRefactoring Applications using SOLID Principles
Refactoring Applications using SOLID PrinciplesSteven Smith
 
ÎœÎ”ÎžÎżÎŽÎżÎ»ÎżÎłÎŻÎ± ΑσÎșÎźÏƒÎ”Ï‰Îœ IP ΔπÎčÎșÎ”Ï†Î±Î»ÎŻÎŽÎ±
ÎœÎ”ÎžÎżÎŽÎżÎ»ÎżÎłÎŻÎ± ΑσÎșÎźÏƒÎ”Ï‰Îœ IP ΔπÎčÎșÎ”Ï†Î±Î»ÎŻÎŽÎ±ÎœÎ”ÎžÎżÎŽÎżÎ»ÎżÎłÎŻÎ± ΑσÎșÎźÏƒÎ”Ï‰Îœ IP ΔπÎčÎșÎ”Ï†Î±Î»ÎŻÎŽÎ±
ÎœÎ”ÎžÎżÎŽÎżÎ»ÎżÎłÎŻÎ± ΑσÎșÎźÏƒÎ”Ï‰Îœ IP ΔπÎčÎșÎ”Ï†Î±Î»ÎŻÎŽÎ±Katerina Drimili
 
Migrating Monolithic Applications with the Strangler Pattern
Migrating Monolithic Applications with the Strangler Pattern Migrating Monolithic Applications with the Strangler Pattern
Migrating Monolithic Applications with the Strangler Pattern Thanh Nguyen
 
IDP Proxy Concept: Accessing Identity Data Sources Everywhere!
IDP Proxy Concept: Accessing Identity Data Sources Everywhere!IDP Proxy Concept: Accessing Identity Data Sources Everywhere!
IDP Proxy Concept: Accessing Identity Data Sources Everywhere!ForgeRock
 
Pengenalan OOP dan Framework Code Igniter
Pengenalan OOP dan Framework Code IgniterPengenalan OOP dan Framework Code Igniter
Pengenalan OOP dan Framework Code IgniterRudy Prasetya
 
GĂ©rer sa dette technique avec SonarQube
GĂ©rer sa dette technique avec SonarQubeGĂ©rer sa dette technique avec SonarQube
GĂ©rer sa dette technique avec SonarQubePierre-Henri Gache
 
Overview and Best Practices for Amazon Elastic Block Store - September 2016 W...
Overview and Best Practices for Amazon Elastic Block Store - September 2016 W...Overview and Best Practices for Amazon Elastic Block Store - September 2016 W...
Overview and Best Practices for Amazon Elastic Block Store - September 2016 W...Amazon Web Services
 
Teams Nation 2022 - Securing Microsoft 365 data with service encryption
Teams Nation 2022 - Securing Microsoft 365 data with service encryptionTeams Nation 2022 - Securing Microsoft 365 data with service encryption
Teams Nation 2022 - Securing Microsoft 365 data with service encryptionThomas Stensitzki
 

Was ist angesagt? (20)

Serverless Analytics with Amazon Redshift Spectrum, AWS Glue, and Amazon Quic...
Serverless Analytics with Amazon Redshift Spectrum, AWS Glue, and Amazon Quic...Serverless Analytics with Amazon Redshift Spectrum, AWS Glue, and Amazon Quic...
Serverless Analytics with Amazon Redshift Spectrum, AWS Glue, and Amazon Quic...
 
Composite pattern
Composite patternComposite pattern
Composite pattern
 
Indexing Text and HTML Files with Solr
Indexing Text and HTML Files with SolrIndexing Text and HTML Files with Solr
Indexing Text and HTML Files with Solr
 
mySQL Workbench Guide (στα ΕλληΜÎčÎșÎŹ)
mySQL Workbench Guide (στα ΕλληΜÎčÎșÎŹ)mySQL Workbench Guide (στα ΕλληΜÎčÎșÎŹ)
mySQL Workbench Guide (στα ΕλληΜÎčÎșÎŹ)
 
Î Î±ÏÎżÏ…ÏƒÎŻÎ±ÏƒÎ· micro:bit & MakeCode
Î Î±ÏÎżÏ…ÏƒÎŻÎ±ÏƒÎ· micro:bit & MakeCodeÎ Î±ÏÎżÏ…ÏƒÎŻÎ±ÏƒÎ· micro:bit & MakeCode
Î Î±ÏÎżÏ…ÏƒÎŻÎ±ÏƒÎ· micro:bit & MakeCode
 
ă€æŒ”çż’ă€‘Reă‚ČăƒŒăƒ ç†è«–ć…„é–€ 珏2曞 -ăƒ©ăƒ™ăƒ«æł•ă‚’ć­ŠăŒă†-ă€€ć‰ăƒ»ćŸŒç·š
ă€æŒ”çż’ă€‘Reă‚ČăƒŒăƒ ç†è«–ć…„é–€ 珏2曞 -ăƒ©ăƒ™ăƒ«æł•ă‚’ć­ŠăŒă†-ă€€ć‰ăƒ»ćŸŒç·šă€æŒ”çż’ă€‘Reă‚ČăƒŒăƒ ç†è«–ć…„é–€ 珏2曞 -ăƒ©ăƒ™ăƒ«æł•ă‚’ć­ŠăŒă†-ă€€ć‰ăƒ»ćŸŒç·š
ă€æŒ”çż’ă€‘Reă‚ČăƒŒăƒ ç†è«–ć…„é–€ 珏2曞 -ăƒ©ăƒ™ăƒ«æł•ă‚’ć­ŠăŒă†-ă€€ć‰ăƒ»ćŸŒç·š
 
Session12 J2ME Generic Connection Framework
Session12 J2ME Generic Connection FrameworkSession12 J2ME Generic Connection Framework
Session12 J2ME Generic Connection Framework
 
ARP-RARP
ARP-RARPARP-RARP
ARP-RARP
 
ÎŸÎŽÎ·ÎłÏŒÏ‚ Dropbox ÎłÎčα ΔÎșπαÎčΎΔυτÎčÎșÎżÏÏ‚
ÎŸÎŽÎ·ÎłÏŒÏ‚ Dropbox ÎłÎčα ΔÎșπαÎčΎΔυτÎčÎșÎżÏÏ‚ÎŸÎŽÎ·ÎłÏŒÏ‚ Dropbox ÎłÎčα ΔÎșπαÎčΎΔυτÎčÎșÎżÏÏ‚
ÎŸÎŽÎ·ÎłÏŒÏ‚ Dropbox ÎłÎčα ΔÎșπαÎčΎΔυτÎčÎșÎżÏÏ‚
 
Tokenization on the Node - Data Protection for Security and Compliance
Tokenization on the Node - Data Protection for Security and ComplianceTokenization on the Node - Data Protection for Security and Compliance
Tokenization on the Node - Data Protection for Security and Compliance
 
ΕÎčÏƒÎ±ÎłÏ‰ÎłÎź στÎčς αρχές της ΔπÎčÏƒÏ„ÎźÎŒÎ·Ï‚ τωΜ Η/΄
ΕÎčÏƒÎ±ÎłÏ‰ÎłÎź στÎčς αρχές της ΔπÎčÏƒÏ„ÎźÎŒÎ·Ï‚ τωΜ Η/΄ΕÎčÏƒÎ±ÎłÏ‰ÎłÎź στÎčς αρχές της ΔπÎčÏƒÏ„ÎźÎŒÎ·Ï‚ τωΜ Η/΄
ΕÎčÏƒÎ±ÎłÏ‰ÎłÎź στÎčς αρχές της ΔπÎčÏƒÏ„ÎźÎŒÎ·Ï‚ τωΜ Η/΄
 
Tα ÎŽÎżÎŒÎčÎșÎŹ Όέρη Ï„ÎżÏ… ÎŽÎčÎșÏ„ÏÎżÏ… Ï…Ï€ÎżÎ»ÎżÎłÎčστώΜ
Tα ÎŽÎżÎŒÎčÎșÎŹ Όέρη Ï„ÎżÏ… ÎŽÎčÎșÏ„ÏÎżÏ… Ï…Ï€ÎżÎ»ÎżÎłÎčστώΜTα ÎŽÎżÎŒÎčÎșÎŹ Όέρη Ï„ÎżÏ… ÎŽÎčÎșÏ„ÏÎżÏ… Ï…Ï€ÎżÎ»ÎżÎłÎčστώΜ
Tα ÎŽÎżÎŒÎčÎșÎŹ Όέρη Ï„ÎżÏ… ÎŽÎčÎșÏ„ÏÎżÏ… Ï…Ï€ÎżÎ»ÎżÎłÎčστώΜ
 
Refactoring Applications using SOLID Principles
Refactoring Applications using SOLID PrinciplesRefactoring Applications using SOLID Principles
Refactoring Applications using SOLID Principles
 
ÎœÎ”ÎžÎżÎŽÎżÎ»ÎżÎłÎŻÎ± ΑσÎșÎźÏƒÎ”Ï‰Îœ IP ΔπÎčÎșÎ”Ï†Î±Î»ÎŻÎŽÎ±
ÎœÎ”ÎžÎżÎŽÎżÎ»ÎżÎłÎŻÎ± ΑσÎșÎźÏƒÎ”Ï‰Îœ IP ΔπÎčÎșÎ”Ï†Î±Î»ÎŻÎŽÎ±ÎœÎ”ÎžÎżÎŽÎżÎ»ÎżÎłÎŻÎ± ΑσÎșÎźÏƒÎ”Ï‰Îœ IP ΔπÎčÎșÎ”Ï†Î±Î»ÎŻÎŽÎ±
ÎœÎ”ÎžÎżÎŽÎżÎ»ÎżÎłÎŻÎ± ΑσÎșÎźÏƒÎ”Ï‰Îœ IP ΔπÎčÎșÎ”Ï†Î±Î»ÎŻÎŽÎ±
 
Migrating Monolithic Applications with the Strangler Pattern
Migrating Monolithic Applications with the Strangler Pattern Migrating Monolithic Applications with the Strangler Pattern
Migrating Monolithic Applications with the Strangler Pattern
 
IDP Proxy Concept: Accessing Identity Data Sources Everywhere!
IDP Proxy Concept: Accessing Identity Data Sources Everywhere!IDP Proxy Concept: Accessing Identity Data Sources Everywhere!
IDP Proxy Concept: Accessing Identity Data Sources Everywhere!
 
Pengenalan OOP dan Framework Code Igniter
Pengenalan OOP dan Framework Code IgniterPengenalan OOP dan Framework Code Igniter
Pengenalan OOP dan Framework Code Igniter
 
GĂ©rer sa dette technique avec SonarQube
GĂ©rer sa dette technique avec SonarQubeGĂ©rer sa dette technique avec SonarQube
GĂ©rer sa dette technique avec SonarQube
 
Overview and Best Practices for Amazon Elastic Block Store - September 2016 W...
Overview and Best Practices for Amazon Elastic Block Store - September 2016 W...Overview and Best Practices for Amazon Elastic Block Store - September 2016 W...
Overview and Best Practices for Amazon Elastic Block Store - September 2016 W...
 
Teams Nation 2022 - Securing Microsoft 365 data with service encryption
Teams Nation 2022 - Securing Microsoft 365 data with service encryptionTeams Nation 2022 - Securing Microsoft 365 data with service encryption
Teams Nation 2022 - Securing Microsoft 365 data with service encryption
 

Ähnlich wie Invitation to Scala

Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Martin Odersky
 
The Scala Programming Language
The Scala Programming LanguageThe Scala Programming Language
The Scala Programming Languageleague
 
Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?Jesper Kamstrup Linnet
 
Scala introduction
Scala introductionScala introduction
Scala introductionYardena Meymann
 
Introduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanIntroduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanJimin Hsieh
 
Effective Scala @ Jfokus
Effective Scala @ JfokusEffective Scala @ Jfokus
Effective Scala @ JfokusHenrik Engström
 
Lambda? You Keep Using that Letter
Lambda? You Keep Using that LetterLambda? You Keep Using that Letter
Lambda? You Keep Using that LetterKevlin Henney
 
2016-11-12 02 НоĐșĐŸĐ»Đ°Đč Đ›ĐžĐœĐșДр. Đ§Đ”ĐŒŃƒ Java ĐŒĐŸĐ¶Đ”Ń‚ ĐżĐŸŃƒŃ‡ĐžŃ‚ŃŒŃŃ у Haskell Đž ĐœĐ°ĐŸĐ±ĐŸŃ€ĐŸŃ‚
2016-11-12 02 НоĐșĐŸĐ»Đ°Đč Đ›ĐžĐœĐșДр. Đ§Đ”ĐŒŃƒ Java ĐŒĐŸĐ¶Đ”Ń‚ ĐżĐŸŃƒŃ‡ĐžŃ‚ŃŒŃŃ у Haskell Đž ĐœĐ°ĐŸĐ±ĐŸŃ€ĐŸŃ‚2016-11-12 02 НоĐșĐŸĐ»Đ°Đč Đ›ĐžĐœĐșДр. Đ§Đ”ĐŒŃƒ Java ĐŒĐŸĐ¶Đ”Ń‚ ĐżĐŸŃƒŃ‡ĐžŃ‚ŃŒŃŃ у Haskell Đž ĐœĐ°ĐŸĐ±ĐŸŃ€ĐŸŃ‚
2016-11-12 02 НоĐșĐŸĐ»Đ°Đč Đ›ĐžĐœĐșДр. Đ§Đ”ĐŒŃƒ Java ĐŒĐŸĐ¶Đ”Ń‚ ĐżĐŸŃƒŃ‡ĐžŃ‚ŃŒŃŃ у Haskell Đž ĐœĐ°ĐŸĐ±ĐŸŃ€ĐŸŃ‚ĐžĐŒŃĐșОД Ий-ŃŃƒĐ±Đ±ĐŸŃ‚ĐœĐžĐșĐž
 
Stepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to ScalaStepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to ScalaDerek Chen-Becker
 
Programming in Scala - Lecture Three
Programming in Scala - Lecture ThreeProgramming in Scala - Lecture Three
Programming in Scala - Lecture ThreeAngelo Corsaro
 
Ajax and JavaScript Bootcamp
Ajax and JavaScript BootcampAjax and JavaScript Bootcamp
Ajax and JavaScript BootcampAndreCharland
 
Data structures cs301 power point slides lecture 01
Data structures   cs301 power point slides lecture 01Data structures   cs301 power point slides lecture 01
Data structures cs301 power point slides lecture 01shaziabibi5
 
A Brief Introduction to Scala for Java Developers
A Brief Introduction to Scala for Java DevelopersA Brief Introduction to Scala for Java Developers
A Brief Introduction to Scala for Java DevelopersMiles Sabin
 
Miles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java DevelopersMiles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java DevelopersSkills Matter
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdfHiroshi Ono
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdfHiroshi Ono
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdfHiroshi Ono
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdfHiroshi Ono
 
Programming in Scala: Notes
Programming in Scala: NotesProgramming in Scala: Notes
Programming in Scala: NotesRoberto Casadei
 

Ähnlich wie Invitation to Scala (20)

R language
R languageR language
R language
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
 
The Scala Programming Language
The Scala Programming LanguageThe Scala Programming Language
The Scala Programming Language
 
Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?
 
Scala introduction
Scala introductionScala introduction
Scala introduction
 
Introduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanIntroduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf Taiwan
 
Effective Scala @ Jfokus
Effective Scala @ JfokusEffective Scala @ Jfokus
Effective Scala @ Jfokus
 
Lambda? You Keep Using that Letter
Lambda? You Keep Using that LetterLambda? You Keep Using that Letter
Lambda? You Keep Using that Letter
 
2016-11-12 02 НоĐșĐŸĐ»Đ°Đč Đ›ĐžĐœĐșДр. Đ§Đ”ĐŒŃƒ Java ĐŒĐŸĐ¶Đ”Ń‚ ĐżĐŸŃƒŃ‡ĐžŃ‚ŃŒŃŃ у Haskell Đž ĐœĐ°ĐŸĐ±ĐŸŃ€ĐŸŃ‚
2016-11-12 02 НоĐșĐŸĐ»Đ°Đč Đ›ĐžĐœĐșДр. Đ§Đ”ĐŒŃƒ Java ĐŒĐŸĐ¶Đ”Ń‚ ĐżĐŸŃƒŃ‡ĐžŃ‚ŃŒŃŃ у Haskell Đž ĐœĐ°ĐŸĐ±ĐŸŃ€ĐŸŃ‚2016-11-12 02 НоĐșĐŸĐ»Đ°Đč Đ›ĐžĐœĐșДр. Đ§Đ”ĐŒŃƒ Java ĐŒĐŸĐ¶Đ”Ń‚ ĐżĐŸŃƒŃ‡ĐžŃ‚ŃŒŃŃ у Haskell Đž ĐœĐ°ĐŸĐ±ĐŸŃ€ĐŸŃ‚
2016-11-12 02 НоĐșĐŸĐ»Đ°Đč Đ›ĐžĐœĐșДр. Đ§Đ”ĐŒŃƒ Java ĐŒĐŸĐ¶Đ”Ń‚ ĐżĐŸŃƒŃ‡ĐžŃ‚ŃŒŃŃ у Haskell Đž ĐœĐ°ĐŸĐ±ĐŸŃ€ĐŸŃ‚
 
Stepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to ScalaStepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to Scala
 
Programming in Scala - Lecture Three
Programming in Scala - Lecture ThreeProgramming in Scala - Lecture Three
Programming in Scala - Lecture Three
 
Ajax and JavaScript Bootcamp
Ajax and JavaScript BootcampAjax and JavaScript Bootcamp
Ajax and JavaScript Bootcamp
 
Data structures cs301 power point slides lecture 01
Data structures   cs301 power point slides lecture 01Data structures   cs301 power point slides lecture 01
Data structures cs301 power point slides lecture 01
 
A Brief Introduction to Scala for Java Developers
A Brief Introduction to Scala for Java DevelopersA Brief Introduction to Scala for Java Developers
A Brief Introduction to Scala for Java Developers
 
Miles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java DevelopersMiles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java Developers
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
 
Programming in Scala: Notes
Programming in Scala: NotesProgramming in Scala: Notes
Programming in Scala: Notes
 

Mehr von Michael Bar-Sinai

Sharing Sensitive Data With Confidence: The DataTags system
Sharing Sensitive Data With Confidence: The DataTags systemSharing Sensitive Data With Confidence: The DataTags system
Sharing Sensitive Data With Confidence: The DataTags systemMichael Bar-Sinai
 
DataTags, The Tags Toolset, and Dataverse Integration
DataTags, The Tags Toolset, and Dataverse IntegrationDataTags, The Tags Toolset, and Dataverse Integration
DataTags, The Tags Toolset, and Dataverse IntegrationMichael Bar-Sinai
 

Mehr von Michael Bar-Sinai (6)

BPjs deep dive 2019
BPjs deep dive 2019BPjs deep dive 2019
BPjs deep dive 2019
 
BPjs for IoT class
BPjs for IoT classBPjs for IoT class
BPjs for IoT class
 
Deep Dive into BPjs
Deep Dive into BPjsDeep Dive into BPjs
Deep Dive into BPjs
 
Sharing Sensitive Data With Confidence: The DataTags system
Sharing Sensitive Data With Confidence: The DataTags systemSharing Sensitive Data With Confidence: The DataTags system
Sharing Sensitive Data With Confidence: The DataTags system
 
DataTags, The Tags Toolset, and Dataverse Integration
DataTags, The Tags Toolset, and Dataverse IntegrationDataTags, The Tags Toolset, and Dataverse Integration
DataTags, The Tags Toolset, and Dataverse Integration
 
Draw More, Work Less
Draw More, Work LessDraw More, Work Less
Draw More, Work Less
 

KĂŒrzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
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
 
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
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 

KĂŒrzlich hochgeladen (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

Invitation to Scala

  • 1. Introducing Scala IQSS Tech-Talk, 2013-06-27 Michael Bar-Sinai Sunday, 4 August, 13
  • 2. Based in part on Scala for the impatient, Scala for java programmers tutorial at Typesafe.com, and Prof. Mayer Goldberg advanced programming class in Ben-Gurion university of the Negev, Israel Sunday, 4 August, 13
  • 3. In a Few Bullets Developed in 2001, by Martin Odersky, EPFL Professor Runs on the JVM (also, CLR) Statically typed and with concise syntax Object oriented and functional Clean and elegant design Strong collection framework Expression-only, DSL friendly, advanced features Sunday, 4 August, 13
  • 4. In a Few Bullets Developed in 2001, by Martin Odersky, EPFL Professor Runs on the JVM (also, CLR) Statically typed and with concise syntax Object oriented and functional Clean and elegant design Strong collection framework Expression-only, DSL friendly, advanced features Sunday, 4 August, 13
  • 5. In a Few Bullets Developed in 2001, by Martin Odersky, EPFL Professor Runs on the JVM (also, CLR) Statically typed and with concise syntax Object oriented and functional Clean and elegant design Strong collection framework Expression-only, DSL friendly, advanced features Sunday, 4 August, 13
  • 8. What is a computation? PROCEDURAL Finite automaton working on an inïŹnite tape ...0 1 110101110 Sunday, 4 August, 13
  • 9. What is a computation? PROCEDURAL FUNCTIONAL Finite automaton working on an inïŹnite tape ...0 1 110101110 Data ïŹ‚owing through a program f(x) /2 R f(6) 2 R Sunday, 4 August, 13
  • 11. List Operations Run some binary operator on the list items and an intermediate results fold, reduce, scan Concurrent: aggregate, reduce ndlrowolleH Sunday, 4 August, 13
  • 12. List Operations Run some binary operator on the list items and an intermediate results fold, reduce, scan Concurrent: aggregate, reduce ndlrowolleH Sunday, 4 August, 13
  • 13. Expressions vs. Statements STATEMENT if ( map contains x ) { map(x) = computeNewX(map(x)) } else { map(x) = computeNewX( 0 ) } Sunday, 4 August, 13
  • 14. Expressions vs. Statements STATEMENT EXPRESSION if ( map contains x ) { map(x) = computeNewX(map(x)) } else { map(x) = computeNewX( 0 ) } map(x) = if ( map contains x ) computeNewX( map(x) ) else computeNewX( 0 ) Sunday, 4 August, 13
  • 15. Expressions vs. Statements STATEMENT EXPRESSION if ( map contains x ) { map(x) = computeNewX(map(x)) } else { map(x) = computeNewX( 0 ) } map(x) = if ( map contains x ) computeNewX( map(x) ) else computeNewX( 0 ) ACTUAL SCALA CODE map(x) = computeNewX( map.getOrElse(x,0) ) Sunday, 4 August, 13
  • 16. Class Syntax Classes have a primary constructor that is part of the class deïŹnition Clients can’t distinguish between getters and direct ïŹeld access Better privacy control Sunday, 4 August, 13
  • 17. Classes class Person( var name:String, val id:Int ) { ! def greet = "Hello, my name is %s".format(name) } class Person2( name:String, val id:Int ) { ! def greet = "Hello, my name is %s".format(name) } class Person3( name:String, val id:Int ) { ! val greet = "Hello, my name is %s".format(name) } Sunday, 4 August, 13
  • 18. Classes (cont.) class Person4( aName:String, anId:Int ) { ! private val id = anId ! private[this] var pName = aName ! def name = pName ! def name_=( newName:String ) { pName = newName } ! override def toString = "[Person4 id:%d name:%s]".format(id,name) } Sunday, 4 August, 13
  • 19. Multiple Inheritance Would have been nice if it worked It doesn’t Java allowed only multiple inheritance of interfaces JDK8 would update this, slightly Scala simulates multiple inheritance using type linearization Would have been nice if it worked ...it mostly does A B1 B2 C A B1 B2 C Sunday, 4 August, 13
  • 20. Traits Almost like class: Can have ïŹelds, protocols and behavior (implementations) Can’t have constructor parameters Can require minimal interface from implementing classes Class can extend as many as needed Types are generated at declaration point Sunday, 4 August, 13
  • 21. Objects and the absence of static Replace the static parts in java Manual declaration of a runtime singletons Classes can have “companion objects” that have the same name Good place for utility methods or special “apply” methods App trait allows script-like behavior Sunday, 4 August, 13
  • 22. Pattern Matching Control structure that allows switching type inquiry variable de-composition Specialized Classes optimized for this Sunday, 4 August, 13
  • 23. Simple Pattern Matching def toFuzzyStringInt( i:Int ) = i match { ! case 0 => "Nada" ! case 1 => "One" ! case 2 => "A Pair" ! case 12 => "a dozen" ! case _ if i<0 => "Less that zero" ! case _ => "%,d".format(i) } Sunday, 4 August, 13
  • 24. Switch by Type def prettyPrint( a:Any ) = a match { ! case i:Int => "%,d".format(i) ! case s:String => "[%s]".format(s) ! case sym:Symbol => ":%s".format(sym) ! case _ => a.toString } Sunday, 4 August, 13
  • 25. Decomposition First, meet the case class: Regular class, but with immutable declared ïŹelds, toString, equals and hashCode automatically deïŹned sealed abstract class Tree case class Sum( l:Tree, r:Tree ) extends Tree case class Var( n:String ) extends Tree case class Con( v:Int ) extends Tree Sunday, 4 August, 13
  • 26. Decomposition def evalTree( t:Tree, e:Map[String,Int] ): Int = t match { ! case Sum(l,r) => evalTree(l, e) + evalTree(r,e) ! case Var( n ) => e(n) ! case Con( i ) => i } Allows downcasting, accessing sub-classes ïŹelds and varying actions based on the class of the parameter, in a single syntactical maneuver Sunday, 4 August, 13
  • 27. ... In the real world (merged,original) match { case ( Pass(_), ( _, _) ) => true case ( Unfixable(_), ( _, _) ) => false case ( Fixable(_,t,_), (t1,t2) ) => f.ld<ld(t1)+ld(t2) } Given two strings, we need to decide whether it is more likely that they are two separate words or one broken word Sunday, 4 August, 13
  • 28. ... In the real world (merged,original) match { case ( Pass(_), ( _, _) ) => true case ( Unfixable(_), ( _, _) ) => false case ( Fixable(_,t,_), (t1,t2) ) => f.ld<ld(t1)+ld(t2) } ere are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. e first method is far more diïŹƒcult. -- C. A. R. Hoare, Turing Award lecture, 1980 Given two strings, we need to decide whether it is more likely that they are two separate words or one broken word Sunday, 4 August, 13
  • 29. Option[T] And the death of the NullPointerException Indicates possibly missing values Has two implementations: None and Some(t) “Collection of at most one item” Convention more than a language feature Sunday, 4 August, 13
  • 30. Functions as values Creating new functions from existing ones Powerful tool, but can get messy Allows for DSL creation def bind1( f:(Int,Int)=>Int, v:Int ) = (a:Int)=>f(a,v) Sunday, 4 August, 13
  • 31. Not Covered Creation of DSLs Implicit conversions Continuations Frameworks XML Parsers/Combinators Macros Annotations Genericity Type System Actors Regular Expressions Extractors ... many more Sunday, 4 August, 13
  • 32. Pointers www.scala-lang.org Typesafe.com Scala for the Impatient, by Cay Horstmann (http:// horstmann.com/scala/) First chapters available after registering with at Typesafe’s site (google) Sunday, 4 August, 13
  • 33. Introducing Scala IQSS Tech-Talk, 2013-06-27 Michael Bar-Sinai THANKS Sunday, 4 August, 13