SlideShare une entreprise Scribd logo
1  sur  114
Télécharger pour lire hors ligne
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Scala: An OO Surprise 
Apostolos Syropoulos 
Xanthi, Greece 
4th European Lisp Symposium 
March 31st - April 1st, 2011 
TUHH, Hamburg University of Technology, 
Hamburg, Germany 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Outline 
1. Introduction 
What is Scala? 
Object Orientation 
Scalability 
2. Functional Features 
3. Parser Builders 
4. XML Processing 
5. XML Processing 
6. Concurrent Programming
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
A versatile programming language 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
A versatile programming language 
A purely object-oriented language. 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
A versatile programming language 
A purely object-oriented language. 
Runs on the Java Virtual Machine. 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
A versatile programming language 
A purely object-oriented language. 
Runs on the Java Virtual Machine. 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
A versatile programming language 
A purely object-oriented language. 
Runs on the Java Virtual Machine. 
A scalable language. 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
A versatile programming language 
A purely object-oriented language. 
Runs on the Java Virtual Machine. 
A scalable language. 
Has features found in functional programming 
languages, but it is not a functional langauge! 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
A versatile programming language 
A purely object-oriented language. 
Runs on the Java Virtual Machine. 
A scalable language. 
Has features found in functional programming 
languages, but it is not a functional langauge! 
Allows concurrent programing. 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
A versatile programming language 
A purely object-oriented language. 
Runs on the Java Virtual Machine. 
A scalable language. 
Has features found in functional programming 
languages, but it is not a functional langauge! 
Allows concurrent programing. 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
A versatile programming language 
A purely object-oriented language. 
Runs on the Java Virtual Machine. 
A scalable language. 
Has features found in functional programming 
languages, but it is not a functional langauge! 
Allows concurrent programing. 
Includes facilities for GUI programming. 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
A versatile programming language 
A purely object-oriented language. 
Runs on the Java Virtual Machine. 
A scalable language. 
Has features found in functional programming 
languages, but it is not a functional langauge! 
Allows concurrent programing. 
Includes facilities for GUI programming. 
Seamless integration of XML. 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
A versatile programming language 
A purely object-oriented language. 
Runs on the Java Virtual Machine. 
A scalable language. 
Has features found in functional programming 
languages, but it is not a functional langauge! 
Allows concurrent programing. 
Includes facilities for GUI programming. 
Seamless integration of XML. 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
A versatile programming language 
A purely object-oriented language. 
Runs on the Java Virtual Machine. 
A scalable language. 
Has features found in functional programming 
languages, but it is not a functional langauge! 
Allows concurrent programing. 
Includes facilities for GUI programming. 
Seamless integration of XML. 
Provides parser combinators. 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Principles of Object Orientation 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Principles of Object Orientation 
Abstraction (i.e., a software object is an 
idealization of a real world object). 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Principles of Object Orientation 
Abstraction (i.e., a software object is an 
idealization of a real world object). 
Encapsulation (i.e., a data protection 
mechanism). 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Principles of Object Orientation 
Abstraction (i.e., a software object is an 
idealization of a real world object). 
Encapsulation (i.e., a data protection 
mechanism). 
Inheritance (i.e., an object may extend the 
functionality of another object). 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Principles of Object Orientation 
Abstraction (i.e., a software object is an 
idealization of a real world object). 
Encapsulation (i.e., a data protection 
mechanism). 
Inheritance (i.e., an object may extend the 
functionality of another object). 
Polymorphism (i.e., software modules may have 
different instances with identical behavior). 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
What makes a programming language 
scalable? 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
What makes a programming language 
scalable? 
Any language that can be extended seamlessly 
is scalable. 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
What makes a programming language 
scalable? 
Any language that can be extended seamlessly 
is scalable. 
Gyu L. Steel Jr.: “[A] language design can no 
longer be a thing. It must be a pattern–a pattern 
for growth–a pattern for growing the pattern for 
defining the patterns that programmers can use 
for their real work and their main goal.” 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
What makes a programming language 
scalable? 
Any language that can be extended seamlessly 
is scalable. 
Gyu L. Steel Jr.: “[A] language design can no 
longer be a thing. It must be a pattern–a pattern 
for growth–a pattern for growing the pattern for 
defining the patterns that programmers can use 
for their real work and their main goal.” 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
What makes a programming language 
scalable? 
Any language that can be extended seamlessly 
is scalable. 
Gyu L. Steel Jr.: “[A] language design can no 
longer be a thing. It must be a pattern–a pattern 
for growth–a pattern for growing the pattern for 
defining the patterns that programmers can use 
for their real work and their main goal.” 
There two forms of growth: variable vocabulary 
or variable semantics. 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
What makes a programming language 
scalable? 
Any language that can be extended seamlessly 
is scalable. 
Gyu L. Steel Jr.: “[A] language design can no 
longer be a thing. It must be a pattern–a pattern 
for growth–a pattern for growing the pattern for 
defining the patterns that programmers can use 
for their real work and their main goal.” 
There two forms of growth: variable vocabulary 
or variable semantics. 
Generic types, operator overloading, and 
user-defined light-weight types form the kernel 
of every scalable language. 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
A Generic Stack
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
A Generic Stack 
class Stack [γ] (n: Int) { 
private var S = new Array[γ](n) 
private var top = 0; 
def push(elem: γ) { 
top = top + 1 
S(top) = elem 
} 
def pop () : γ = { 
var oldtop = top 
top = top - 1 
S(oldtop) 
} 
}
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
User-Defined Light-Weight Complex 
Numbers 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
User-Defined Light-Weight Complex 
Numbers 
class Complex(val re: Double, val im: Double) { 
def + (x: Complex) = 
new Complex(re + x.re, im + x.im) 
def unary_- = new Complex(-Re, -Im) 
. . . . . . . . . . . . . . . . . . 
override def toString = if(re == 0 && im == 0) "0" … 
} 
object Complex{ 
def apply(re: Double)(im: Double) = 
. . . . . . 
new Complex(re, im) 
} 
object i extends Complex(0.0, 1.0) 
. . . . . . . . . . . . . . . . . . . 
var a = 5 + 3.0*i // a complex number!!!
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Call-By-Name or how to define new 
commands 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Call-By-Name or how to define new 
commands 
def loop(pre: => Unit)(cond: => Boolean) 
(post: => Unit): Unit = { 
. . . . . . 
pre 
if (!cond) { 
post 
loop(pre)(cond)(post) 
} 
else 
() 
} 
var x=6; var y=0 
loop { 
x=x-1; y=y+1 
} (x == 0 ) { 
println(x); println(y) 
}
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Scala’s Functional Features 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Scala’s Functional Features 
Functions are software modules (objects in 
Scala’s parlance). 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Scala’s Functional Features 
Functions are software modules (objects in 
Scala’s parlance). 
Users can define anonymous functions. 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Scala’s Functional Features 
Functions are software modules (objects in 
Scala’s parlance). 
Users can define anonymous functions. 
var inc = (x:Int) => x+1 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Scala’s Functional Features 
Functions are software modules (objects in 
Scala’s parlance). 
Users can define anonymous functions. 
var inc = (x:Int) => x+1 
. . . . . . 
Supports closures.
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Scala’s Functional Features 
Functions are software modules (objects in 
Scala’s parlance). 
Users can define anonymous functions. 
var inc = (x:Int) => x+1 
. . . . . . 
Supports closures. 
var mul = (x: Int) => (y:Int) => x*y 
var mul3 = mul(3)
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Scala’s Functional Features 
Functions are software modules (objects in 
Scala’s parlance). 
Users can define anonymous functions. 
var inc = (x:Int) => x+1 
. . . . . . 
Supports closures. 
var mul = (x: Int) => (y:Int) => x*y 
var mul3 = mul(3) 
Pattern matching.
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Data Structures with Class Hierarchies 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Data Structures with Class Hierarchies 
. . . . . . 
Haskell binary tree
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Data Structures with Class Hierarchies 
. . . . . . 
Haskell binary tree 
datatype BinTree = Empty | 
Node(Int, BinTree, BinTree)
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Data Structures with Class Hierarchies 
. . . . . . 
Haskell binary tree 
datatype BinTree = Empty | 
Node(Int, BinTree, BinTree) 
Scala binary tree
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Data Structures with Class Hierarchies 
. . . . . . 
Haskell binary tree 
datatype BinTree = Empty | 
Node(Int, BinTree, BinTree) 
Scala binary tree 
abstract class BinTree 
case object EmptyTree extends BinTree 
case class Node(elem : Int, 
left : BinTree, 
right: BinTree) extends BinTree
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Pattern Matching in Action 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Pattern Matching in Action 
. . . . . . 
Depth of a binary tree
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Pattern Matching in Action 
. . . . . . 
Depth of a binary tree 
def depth(t: BinTree): Int = { 
t match { 
case EmptyTree => 0 
case Node(_,EmptyTree,r) => 1 + depth(r) 
case Node(_,l,EmptyTree) => 1 + depth(l) 
case Node(_,l,r) => Math.max(depth(l), 
depth(r)) + 1 
} 
}
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Constructing Parsers with Parser Builders 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Constructing Parsers with Parser Builders 
Tools that can be combined to build real parsers. 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Constructing Parsers with Parser Builders 
Tools that can be combined to build real parsers. 
A toy parser that accepts binary numerals. 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Constructing Parsers with Parser Builders 
Tools that can be combined to build real parsers. 
A toy parser that accepts binary numerals. 
import scala.util.parsing.combinator._ 
class BinDigit extends JavaTokenParsers { 
def D = "0" | "1" 
def B = D~rep(D) 
def parse(text : String) = parseAll(B,text) 
} 
var P = new BinDigit 
println("input : "+args(0)) 
println(P.parse(args(0))) 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
XML Processing
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
XML Processing 
Variables can be assigned XML content.
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
XML Processing 
Variables can be assigned XML content. 
var poem = 
<poem> <title> Magic Everywhere </title> 
<poet realname="yes"> Tom Jones </poet> 
<stanza> <verse> magic everywhere </verse> 
</stanza> </poem> 
println(poem)
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
XML Processing 
Variables can be assigned XML content. 
var poem = 
<poem> <title> Magic Everywhere </title> 
<poet realname="yes"> Tom Jones </poet> 
<stanza> <verse> magic everywhere </verse> 
</stanza> </poem> 
println(poem) 
Or they can be assigned XML content stored in files.
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
XML Processing 
Variables can be assigned XML content. 
var poem = 
<poem> <title> Magic Everywhere </title> 
<poet realname="yes"> Tom Jones </poet> 
<stanza> <verse> magic everywhere </verse> 
</stanza> </poem> 
println(poem) 
Or they can be assigned XML content stored in files. 
val x = XML.loadFile("listdir.html")
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
XML Processing
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
XML Processing 
Saving XML content.
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
XML Processing 
Saving XML content. 
var z = <person> 
<name>Blaise</name> <surname>Pascal</surname> 
</person> 
XML.save("persons.xml",z)
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
XML Processing 
Saving XML content. 
var z = <person> 
<name>Blaise</name> <surname>Pascal</surname> 
</person> 
XML.save("persons.xml",z) 
Example: Find all poems that have been published 
after 1960 and print the title and the poet of each 
such poem.
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
XML Processing 
Saving XML content. 
var z = <person> 
<name>Blaise</name> <surname>Pascal</surname> 
</person> 
XML.save("persons.xml",z) 
Example: Find all poems that have been published 
after 1960 and print the title and the poet of each 
such poem. 
for ( val poem <- poems  "poem" ) { 
if ( (poem  "year").text.trim.toInt > 1960 ) { 
var poet = (poem  "poet").text 
var title = (poem  "title").text 
println("""+title+"" by "+poet) 
}
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Truths
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Truths 
EETimes Europe 
(http://www.electronics-eetimes.com): “As 
Moore’s Law runs out of steam and computing 
goes mobile, technologists are searching for 
ways to make the leap to new parallel 
programming frameworks that can leverage 
low-power multicore architectures.”
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Truths 
EETimes Europe 
(http://www.electronics-eetimes.com): “As 
Moore’s Law runs out of steam and computing 
goes mobile, technologists are searching for 
ways to make the leap to new parallel 
programming frameworks that can leverage 
low-power multicore architectures.”
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Truths 
EETimes Europe 
(http://www.electronics-eetimes.com): “As 
Moore’s Law runs out of steam and computing 
goes mobile, technologists are searching for 
ways to make the leap to new parallel 
programming frameworks that can leverage 
low-power multicore architectures.” 
Concurrent programming is not only the next 
logical step in software development, but the 
next necessary step.
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Truths 
EETimes Europe 
(http://www.electronics-eetimes.com): “As 
Moore’s Law runs out of steam and computing 
goes mobile, technologists are searching for 
ways to make the leap to new parallel 
programming frameworks that can leverage 
low-power multicore architectures.” 
Concurrent programming is not only the next 
logical step in software development, but the 
next necessary step.
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Truths 
EETimes Europe 
(http://www.electronics-eetimes.com): “As 
Moore’s Law runs out of steam and computing 
goes mobile, technologists are searching for 
ways to make the leap to new parallel 
programming frameworks that can leverage 
low-power multicore architectures.” 
Concurrent programming is not only the next 
logical step in software development, but the 
next necessary step. 
All modern programming languages must 
provide constructs and libraries that will ease 
the construction of concurrent programs
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Scala and Concurrency 
Scala programmers can code concurrent structures 
with…
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Scala and Concurrency 
Scala programmers can code concurrent structures 
with… 
threads (i.e., Java’s legacy to Scala)
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Scala and Concurrency 
Scala programmers can code concurrent structures 
with… 
threads (i.e., Java’s legacy to Scala)
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Scala and Concurrency 
Scala programmers can code concurrent structures 
with… 
threads (i.e., Java’s legacy to Scala) 
mailboxes (something like actors)
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Scala and Concurrency 
Scala programmers can code concurrent structures 
with… 
threads (i.e., Java’s legacy to Scala) 
mailboxes (something like actors)
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Scala and Concurrency 
Scala programmers can code concurrent structures 
with… 
threads (i.e., Java’s legacy to Scala) 
mailboxes (something like actors) 
actors
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Creating threaded applications by 
extending class Thread 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Creating threaded applications by 
extending class Thread 
class PrintProgressMark(val mark: Char, 
val delay :Int) extends Thread { 
. . . . . . 
private var i = 0 
override def run(): Unit = 
try { 
while (i <= 100) { 
print(mark); i += 1; Thread.sleep(delay); 
} 
} catch { case ex : InterruptedException => return } 
} 
object threadExample { 
def main(args: Array[String]) { 
new PrintProgressMark('+', 40).start 
new PrintProgressMark('*', 100).start 
} 
}
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Creating threaded applications by using 
trait Runnable 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Creating threaded applications by using 
trait Runnable 
class PrintProgressMark2(val mark: Char, 
val delay :Int) extends Runnable { 
. . . . . . 
private var i = 0 
override def run(): Unit = 
try { 
while (i <= 100) { 
print(mark); i += 1; Thread.sleep(delay_) 
} 
} catch { case ex : InterruptedException => return } 
} 
object threadExample2 { 
def main(args: Array[String]) { 
var plus = new PrintProgressMark2('+', 40) 
var ast = new PrintProgressMark2('*', 100) 
new Thread(plus).start(); new Thread(ast).start() 
} }
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
What is an actor? 
An actor is a computational agent which maps each 
incoming communication to a triple consisting of…
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
What is an actor? 
An actor is a computational agent which maps each 
incoming communication to a triple consisting of… 
a finite set of communications sent to other 
actors;
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
What is an actor? 
An actor is a computational agent which maps each 
incoming communication to a triple consisting of… 
a finite set of communications sent to other 
actors;
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
What is an actor? 
An actor is a computational agent which maps each 
incoming communication to a triple consisting of… 
a finite set of communications sent to other 
actors; 
a new behavior that will govern the response to 
the next communication processed; and,
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
What is an actor? 
An actor is a computational agent which maps each 
incoming communication to a triple consisting of… 
a finite set of communications sent to other 
actors; 
a new behavior that will govern the response to 
the next communication processed; and,
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
What is an actor? 
An actor is a computational agent which maps each 
incoming communication to a triple consisting of… 
a finite set of communications sent to other 
actors; 
a new behavior that will govern the response to 
the next communication processed; and, 
a finite set of new actors created.
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
What is an actor? 
An actor is a computational agent which maps each 
incoming communication to a triple consisting of… 
a finite set of communications sent to other 
actors; 
a new behavior that will govern the response to 
the next communication processed; and, 
a finite set of new actors created.
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
What is an actor? 
An actor is a computational agent which maps each 
incoming communication to a triple consisting of… 
a finite set of communications sent to other 
actors; 
a new behavior that will govern the response to 
the next communication processed; and, 
a finite set of new actors created. 
Thus,
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
What is an actor? 
An actor is a computational agent which maps each 
incoming communication to a triple consisting of… 
a finite set of communications sent to other 
actors; 
a new behavior that will govern the response to 
the next communication processed; and, 
a finite set of new actors created. 
Thus, 
behaviors are history sensitive;
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
What is an actor? 
An actor is a computational agent which maps each 
incoming communication to a triple consisting of… 
a finite set of communications sent to other 
actors; 
a new behavior that will govern the response to 
the next communication processed; and, 
a finite set of new actors created. 
Thus, 
behaviors are history sensitive;
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
What is an actor? 
An actor is a computational agent which maps each 
incoming communication to a triple consisting of… 
a finite set of communications sent to other 
actors; 
a new behavior that will govern the response to 
the next communication processed; and, 
a finite set of new actors created. 
Thus, 
behaviors are history sensitive; 
there is no presumed sequentiality in the actions 
an actor performs; and,
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
What is an actor? 
An actor is a computational agent which maps each 
incoming communication to a triple consisting of… 
a finite set of communications sent to other 
actors; 
a new behavior that will govern the response to 
the next communication processed; and, 
a finite set of new actors created. 
Thus, 
behaviors are history sensitive; 
there is no presumed sequentiality in the actions 
an actor performs; and,
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
What is an actor? 
An actor is a computational agent which maps each 
incoming communication to a triple consisting of… 
a finite set of communications sent to other 
actors; 
a new behavior that will govern the response to 
the next communication processed; and, 
a finite set of new actors created. 
Thus, 
behaviors are history sensitive; 
there is no presumed sequentiality in the actions 
an actor performs; and, 
actor creation is an integral of the computational 
model.
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
A first example in actor programming 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
A first example in actor programming 
import scala.actors.Actor._ 
object actorsExample { 
def main(args: Array[String]) { 
var PrintProgressPlus = actor { 
var i = 0 
while (i <= max) { 
print('+'); i += 1; Thread.sleep(40) 
} } 
var PrintProgressTimes = actor { 
var i = 0 
while (i <= max) { 
print('*'); i += 1; Thread.sleep(100) 
} } 
1 // <--- block must end in result expression, 
} } // not in definition 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Defining a class that subclasses trait 
Actor 
. . . . . .
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
Defining a class that subclasses trait 
Actor 
import scala.actors._ 
class PrintProgressMark(val mark: Char, 
val delay :Int) extends Actor { 
. . . . . . 
private var i = 0 
def act: Unit = { 
while (i <= 100) { 
print(mark); i += 1; Thread.sleep(delay_) 
} 
} 
} 
object actorsExample { 
def main(args: Array[String]) { 
new PrintProgressMark('+', 40).start 
new PrintProgressMark('*', 100).start 
} 
}
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Computing Factorials 
Carl Hewitt in “Viewing Cotrol Structures as Patterns 
of Passing Messages” (Artificial Intelligence 8, 3 
(1977), 323–364)
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Computing Factorials 
Carl Hewitt in “Viewing Cotrol Structures as Patterns 
of Passing Messages” (Artificial Intelligence 8, 3 
(1977), 323–364) 
“present[s] an approach to modelling intelligence in 
terms of a society of communicating 
knowledge-based problem solving experts”;
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Computing Factorials 
Carl Hewitt in “Viewing Cotrol Structures as Patterns 
of Passing Messages” (Artificial Intelligence 8, 3 
(1977), 323–364) 
“present[s] an approach to modelling intelligence in 
terms of a society of communicating 
knowledge-based problem solving experts”;
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Computing Factorials 
Carl Hewitt in “Viewing Cotrol Structures as Patterns 
of Passing Messages” (Artificial Intelligence 8, 3 
(1977), 323–364) 
“present[s] an approach to modelling intelligence in 
terms of a society of communicating 
knowledge-based problem solving experts”; 
“each of the experts can be viewed as a society that 
can be further decomposed in the same way until the 
primitive actors of the system are reached”;
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Computing Factorials 
Carl Hewitt in “Viewing Cotrol Structures as Patterns 
of Passing Messages” (Artificial Intelligence 8, 3 
(1977), 323–364) 
“present[s] an approach to modelling intelligence in 
terms of a society of communicating 
knowledge-based problem solving experts”; 
“each of the experts can be viewed as a society that 
can be further decomposed in the same way until the 
primitive actors of the system are reached”;
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Computing Factorials 
Carl Hewitt in “Viewing Cotrol Structures as Patterns 
of Passing Messages” (Artificial Intelligence 8, 3 
(1977), 323–364) 
“present[s] an approach to modelling intelligence in 
terms of a society of communicating 
knowledge-based problem solving experts”; 
“each of the experts can be viewed as a society that 
can be further decomposed in the same way until the 
primitive actors of the system are reached”; 
he was “investigating the nature of the 
communication mechanisms needed for effective 
problem-solving by a society of experts and the 
conventions of civilized discourse that make this 
possible.”
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Computing Factorials
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Computing Factorials 
Hewitt demonstrates these “principles” by 
showing how to compute the factorial function 
with actors:
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Computing Factorials 
Hewitt demonstrates these “principles” by 
showing how to compute the factorial function 
with actors:
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Computing Factorials 
Hewitt demonstrates these “principles” by 
showing how to compute the factorial function 
with actors: 
1. using a resursive procedure, that is, a procedure 
that uses replication and
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Computing Factorials 
Hewitt demonstrates these “principles” by 
showing how to compute the factorial function 
with actors: 
1. using a resursive procedure, that is, a procedure 
that uses replication and
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Computing Factorials 
Hewitt demonstrates these “principles” by 
showing how to compute the factorial function 
with actors: 
1. using a resursive procedure, that is, a procedure 
that uses replication and 
2. an iterative procudure, that is, a procedure that 
relies on message passing to deliver a result.
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Actor Replication
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Actor Replication 
case class Val(a: Actor, n: Int) 
case class Res(n: Int) 
class Fact extends Actor { 
def act = 
react { 
case Val(a,0) => a ! Res(1) 
case Val(a,n) => 
var p = new Fact 
p.start 
p ! Val(self,n-1) 
react { case Val(_, m) => a ! Val(a, n*m) 
case Res(m) => a ! Val(a, n*m)} 
} 
}
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Using Class Fact
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Using Class Fact 
object actorsExample { 
def main(args: Array[String]) { 
var factorial = actor { 
react { 
case Val(a,n) => 
var q = new Fact 
q.start 
q ! Val(self,n) 
react { case Val(_,f) => a ! Val(a,f) } 
} 
} 
factorial ! Val(self,6) 
react { case Val(_, n) => println(n) } 
} 
}
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Iterative Actor
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Iterative Actor 
case class InitVal(a: Actor, n: Int) 
case class Val(a: Actor, n: Int, m: Int) 
object actorsExample { 
def main(args: Array[String]) { 
val loopActor = actor { 
var ResActor : Actor = null 
loop{ 
react { 
case Val(_,acc,1) => 
ResActor ! acc; exit("done") 
case Val(a,1,count) => 
ResActor = a 
self ! Val(self,count,count-1) 
case Val(a,acc,count) => 
self ! Val(self,acc*count,count-1) 
} 
} 
}
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Using Class Fact
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
Using Class Fact 
var factorial = actor { 
react { 
case InitVal(a,0) => a ! InitVal(a, 1) 
case InitVal(a,1) => a ! InitVal(a, 1) 
case InitVal(a,n) => 
loopActor ! Val(self,1,n) 
react { case f: Int => a ! InitVal(a,f) } 
} 
} 
factorial ! InitVal(self,6) 
receive { case InitVal(_, n) => println(n) } 
} 
}
Scala: An 
OO Surprise 
Syropoulos 
Introduction 
What is Scala? 
Object Orientation 
Scalability 
Functional 
Features 
Parser 
Builders 
XML 
Processing 
XML 
Processing 
Concurrent 
Program-ming 
. . . . . . 
The end! 
Thank you so much for your attention!

Contenu connexe

Tendances

Why Scala for Web 2.0?
Why Scala for Web 2.0?Why Scala for Web 2.0?
Why Scala for Web 2.0?Alex Payne
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to ScalaRahul Jain
 
[A4]de view2012 scala-michinisougu
[A4]de view2012 scala-michinisougu[A4]de view2012 scala-michinisougu
[A4]de view2012 scala-michinisouguNAVER D2
 
CeedMath & CeedGL, Let's talk 3D...
CeedMath & CeedGL, Let's talk 3D...CeedMath & CeedGL, Let's talk 3D...
CeedMath & CeedGL, Let's talk 3D...rsebbe
 
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationMartin Odersky
 
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGNIntroducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGNManish Pandit
 
Using Scala for building DSLs
Using Scala for building DSLsUsing Scala for building DSLs
Using Scala for building DSLsIndicThreads
 
Writing DSL's in Scala
Writing DSL's in ScalaWriting DSL's in Scala
Writing DSL's in ScalaAbhijit Sharma
 
Kotlin & arrow: the functional way
Kotlin & arrow:  the functional wayKotlin & arrow:  the functional way
Kotlin & arrow: the functional waynluaces
 
Kotlin & Arrow the functional way
Kotlin & Arrow the functional wayKotlin & Arrow the functional way
Kotlin & Arrow the functional wayThoughtworks
 
Xtend - A Language Made for Java Developers
Xtend - A Language Made for Java DevelopersXtend - A Language Made for Java Developers
Xtend - A Language Made for Java DevelopersSebastian Zarnekow
 

Tendances (18)

Android with kotlin course
Android with kotlin courseAndroid with kotlin course
Android with kotlin course
 
Why Scala for Web 2.0?
Why Scala for Web 2.0?Why Scala for Web 2.0?
Why Scala for Web 2.0?
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
[A4]de view2012 scala-michinisougu
[A4]de view2012 scala-michinisougu[A4]de view2012 scala-michinisougu
[A4]de view2012 scala-michinisougu
 
Preparing for Scala 3
Preparing for Scala 3Preparing for Scala 3
Preparing for Scala 3
 
Scala-Ls1
Scala-Ls1Scala-Ls1
Scala-Ls1
 
CeedMath & CeedGL, Let's talk 3D...
CeedMath & CeedGL, Let's talk 3D...CeedMath & CeedGL, Let's talk 3D...
CeedMath & CeedGL, Let's talk 3D...
 
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentation
 
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGNIntroducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
 
Using Scala for building DSLs
Using Scala for building DSLsUsing Scala for building DSLs
Using Scala for building DSLs
 
Writing DSL's in Scala
Writing DSL's in ScalaWriting DSL's in Scala
Writing DSL's in Scala
 
Kotlin & arrow: the functional way
Kotlin & arrow:  the functional wayKotlin & arrow:  the functional way
Kotlin & arrow: the functional way
 
Why Scala?
Why Scala?Why Scala?
Why Scala?
 
Kotlin & Arrow the functional way
Kotlin & Arrow the functional wayKotlin & Arrow the functional way
Kotlin & Arrow the functional way
 
OCL in EMF
OCL in EMFOCL in EMF
OCL in EMF
 
Xtend - A Language Made for Java Developers
Xtend - A Language Made for Java DevelopersXtend - A Language Made for Java Developers
Xtend - A Language Made for Java Developers
 
Lecture 1 oop
Lecture 1 oopLecture 1 oop
Lecture 1 oop
 
Kotlin
KotlinKotlin
Kotlin
 

En vedette (17)

An Overview of Social Media
An Overview of Social MediaAn Overview of Social Media
An Overview of Social Media
 
kewarganegeraan
kewarganegeraankewarganegeraan
kewarganegeraan
 
AT Pokemon Go
AT Pokemon GoAT Pokemon Go
AT Pokemon Go
 
Computing under Vagueness
Computing under VaguenessComputing under Vagueness
Computing under Vagueness
 
Interaction and P systems
Interaction and P systemsInteraction and P systems
Interaction and P systems
 
Defamation on the Internet
Defamation on the InternetDefamation on the Internet
Defamation on the Internet
 
Information Systems Security: An Overview
Information Systems Security: An OverviewInformation Systems Security: An Overview
Information Systems Security: An Overview
 
Internet Defamation
Internet DefamationInternet Defamation
Internet Defamation
 
LT_Internet_Addiction
LT_Internet_AddictionLT_Internet_Addiction
LT_Internet_Addiction
 
Fuzzy Topological Systems
Fuzzy Topological SystemsFuzzy Topological Systems
Fuzzy Topological Systems
 
P Systems and Distributed Computing
P Systems and Distributed ComputingP Systems and Distributed Computing
P Systems and Distributed Computing
 
Online defamation
Online defamationOnline defamation
Online defamation
 
le livre des idees
le livre des ideesle livre des idees
le livre des idees
 
RO internet impact on child and adolescent brain
RO internet impact on child and adolescent brainRO internet impact on child and adolescent brain
RO internet impact on child and adolescent brain
 
Themes of kanthapura by raja rao.
Themes of kanthapura by raja rao.Themes of kanthapura by raja rao.
Themes of kanthapura by raja rao.
 
Dramatic poesy- French vs English
Dramatic poesy- French vs EnglishDramatic poesy- French vs English
Dramatic poesy- French vs English
 
Spina bifida
Spina bifidaSpina bifida
Spina bifida
 

Similaire à Scala: An OO Surprise

Evolution Of Object Oriented Technology
Evolution Of Object Oriented TechnologyEvolution Of Object Oriented Technology
Evolution Of Object Oriented TechnologySharon Roberts
 
Scala Introduction - Meetup Scaladores RJ
Scala Introduction - Meetup Scaladores RJScala Introduction - Meetup Scaladores RJ
Scala Introduction - Meetup Scaladores RJRodrigo Lima
 
Elasticsearch Basics
Elasticsearch BasicsElasticsearch Basics
Elasticsearch BasicsShifa Khan
 
02 java programming basic
02  java programming basic02  java programming basic
02 java programming basicZeeshan-Shaikh
 
The Evolution of Scala / Scala進化論
The Evolution of Scala / Scala進化論The Evolution of Scala / Scala進化論
The Evolution of Scala / Scala進化論scalaconfjp
 
A Strong Object Recognition Using Lbp, Ltp And Rlbp
A Strong Object Recognition Using Lbp, Ltp And RlbpA Strong Object Recognition Using Lbp, Ltp And Rlbp
A Strong Object Recognition Using Lbp, Ltp And RlbpRikki Wright
 
Computer Programming Language
Computer Programming LanguageComputer Programming Language
Computer Programming LanguageRishabhParmar23
 
Languages used by web app development services remotestac x
Languages used by web app development services  remotestac xLanguages used by web app development services  remotestac x
Languages used by web app development services remotestac xRemote Stacx
 
Scala
ScalaScala
Scalasryx
 
Why Scala Presentation
Why Scala  PresentationWhy Scala  Presentation
Why Scala Presentationguestc185e0e
 
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...Codemotion
 
Introduction to Scala JS
Introduction to Scala JSIntroduction to Scala JS
Introduction to Scala JSKnoldus Inc.
 
A Tour Of Scala
A Tour Of ScalaA Tour Of Scala
A Tour Of Scalafanf42
 
Programming in Scala - Lecture One
Programming in Scala - Lecture OneProgramming in Scala - Lecture One
Programming in Scala - Lecture OneAngelo Corsaro
 
Object-Oriented Programming in Java (Module 1)
Object-Oriented Programming in Java (Module 1)Object-Oriented Programming in Java (Module 1)
Object-Oriented Programming in Java (Module 1)muhammadmubinmacadad2
 
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...Codemotion
 
Infographic on Scala Programming Language
Infographic on Scala Programming LanguageInfographic on Scala Programming Language
Infographic on Scala Programming LanguagePaddy Lock
 
Scala Overview INFX 1616
Scala Overview INFX 1616Scala Overview INFX 1616
Scala Overview INFX 1616Patrick Walter
 

Similaire à Scala: An OO Surprise (20)

Evolution Of Object Oriented Technology
Evolution Of Object Oriented TechnologyEvolution Of Object Oriented Technology
Evolution Of Object Oriented Technology
 
Scala Introduction - Meetup Scaladores RJ
Scala Introduction - Meetup Scaladores RJScala Introduction - Meetup Scaladores RJ
Scala Introduction - Meetup Scaladores RJ
 
Elasticsearch Basics
Elasticsearch BasicsElasticsearch Basics
Elasticsearch Basics
 
02 java programming basic
02  java programming basic02  java programming basic
02 java programming basic
 
The Evolution of Scala / Scala進化論
The Evolution of Scala / Scala進化論The Evolution of Scala / Scala進化論
The Evolution of Scala / Scala進化論
 
A Strong Object Recognition Using Lbp, Ltp And Rlbp
A Strong Object Recognition Using Lbp, Ltp And RlbpA Strong Object Recognition Using Lbp, Ltp And Rlbp
A Strong Object Recognition Using Lbp, Ltp And Rlbp
 
Computer Programming Language
Computer Programming LanguageComputer Programming Language
Computer Programming Language
 
Languages used by web app development services remotestac x
Languages used by web app development services  remotestac xLanguages used by web app development services  remotestac x
Languages used by web app development services remotestac x
 
Scala
ScalaScala
Scala
 
Why Scala Presentation
Why Scala  PresentationWhy Scala  Presentation
Why Scala Presentation
 
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...
 
Introduction to Scala JS
Introduction to Scala JSIntroduction to Scala JS
Introduction to Scala JS
 
A Tour Of Scala
A Tour Of ScalaA Tour Of Scala
A Tour Of Scala
 
Programming in Scala - Lecture One
Programming in Scala - Lecture OneProgramming in Scala - Lecture One
Programming in Scala - Lecture One
 
Object-Oriented Programming in Java (Module 1)
Object-Oriented Programming in Java (Module 1)Object-Oriented Programming in Java (Module 1)
Object-Oriented Programming in Java (Module 1)
 
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...
Sviluppare applicazioni nell'era dei "Big Data" con Scala e Spark - Mario Car...
 
OOP Java
OOP JavaOOP Java
OOP Java
 
Infographic on Scala Programming Language
Infographic on Scala Programming LanguageInfographic on Scala Programming Language
Infographic on Scala Programming Language
 
Scala Overview INFX 1616
Scala Overview INFX 1616Scala Overview INFX 1616
Scala Overview INFX 1616
 
Core java
Core javaCore java
Core java
 

Plus de Apostolos Syropoulos

A Presentation of Braga. It was made by students of school
A Presentation of Braga. It was made by students of schoolA Presentation of Braga. It was made by students of school
A Presentation of Braga. It was made by students of schoolApostolos Syropoulos
 
A short presentation of Italy made by students of a school in Cosimo, Sicily,...
A short presentation of Italy made by students of a school in Cosimo, Sicily,...A short presentation of Italy made by students of a school in Cosimo, Sicily,...
A short presentation of Italy made by students of a school in Cosimo, Sicily,...Apostolos Syropoulos
 
Social Media Algorithms - Part of the "Computers in out Life" Erasmus+ Project
Social Media Algorithms - Part of the "Computers in out Life" Erasmus+ ProjectSocial Media Algorithms - Part of the "Computers in out Life" Erasmus+ Project
Social Media Algorithms - Part of the "Computers in out Life" Erasmus+ ProjectApostolos Syropoulos
 
A gentle introduction to Artificial Intelligence
A gentle introduction to Artificial IntelligenceA gentle introduction to Artificial Intelligence
A gentle introduction to Artificial IntelligenceApostolos Syropoulos
 
ΑΡΧΟΝΤΙΚΟ ΠΑΜΟΥΚΤΣΟΓΛΟΥ - Pamouktsoglu Mansion
ΑΡΧΟΝΤΙΚΟ ΠΑΜΟΥΚΤΣΟΓΛΟΥ - Pamouktsoglu MansionΑΡΧΟΝΤΙΚΟ ΠΑΜΟΥΚΤΣΟΓΛΟΥ - Pamouktsoglu Mansion
ΑΡΧΟΝΤΙΚΟ ΠΑΜΟΥΚΤΣΟΓΛΟΥ - Pamouktsoglu MansionApostolos Syropoulos
 
Το Ορφανοτροφείο Θηλέων Ξάνθης
Το Ορφανοτροφείο Θηλέων ΞάνθηςΤο Ορφανοτροφείο Θηλέων Ξάνθης
Το Ορφανοτροφείο Θηλέων ΞάνθηςApostolos Syropoulos
 
Το Αρχαιολογικό Μουσείο Αβδήρων
Το Αρχαιολογικό Μουσείο ΑβδήρωνΤο Αρχαιολογικό Μουσείο Αβδήρων
Το Αρχαιολογικό Μουσείο ΑβδήρωνApostolos Syropoulos
 
Ταφικά έθιμα στα αρχαία Άβδηρα
Ταφικά έθιμα στα αρχαία ΆβδηραΤαφικά έθιμα στα αρχαία Άβδηρα
Ταφικά έθιμα στα αρχαία ΆβδηραApostolos Syropoulos
 
Το ορφανοτροφείο της Ξάνθης
Το ορφανοτροφείο της ΞάνθηςΤο ορφανοτροφείο της Ξάνθης
Το ορφανοτροφείο της ΞάνθηςApostolos Syropoulos
 
Μικρασιατική κατατστροφή - Μέρος 3
Μικρασιατική κατατστροφή - Μέρος 3Μικρασιατική κατατστροφή - Μέρος 3
Μικρασιατική κατατστροφή - Μέρος 3Apostolos Syropoulos
 
Μικρασιατική κατατστροφή - Μέρος 2
Μικρασιατική κατατστροφή - Μέρος 2Μικρασιατική κατατστροφή - Μέρος 2
Μικρασιατική κατατστροφή - Μέρος 2Apostolos Syropoulos
 
Αφιέρωμα στη Μικρά Ασία
Αφιέρωμα στη Μικρά ΑσίαΑφιέρωμα στη Μικρά Ασία
Αφιέρωμα στη Μικρά ΑσίαApostolos Syropoulos
 
ΕΚΠΑΙΔΕΥΤΙΚΗ ΔΡΑΣΗ «ΙΧΝΙΛΑΤΩΝΤΑΣ ΤΟ ΠΑΡΕΛΘΟΝ ΤΟΥ ΤΟΠΟΥ ΜΑΣ».pptx
ΕΚΠΑΙΔΕΥΤΙΚΗ ΔΡΑΣΗ «ΙΧΝΙΛΑΤΩΝΤΑΣ ΤΟ ΠΑΡΕΛΘΟΝ ΤΟΥ ΤΟΠΟΥ ΜΑΣ».pptxΕΚΠΑΙΔΕΥΤΙΚΗ ΔΡΑΣΗ «ΙΧΝΙΛΑΤΩΝΤΑΣ ΤΟ ΠΑΡΕΛΘΟΝ ΤΟΥ ΤΟΠΟΥ ΜΑΣ».pptx
ΕΚΠΑΙΔΕΥΤΙΚΗ ΔΡΑΣΗ «ΙΧΝΙΛΑΤΩΝΤΑΣ ΤΟ ΠΑΡΕΛΘΟΝ ΤΟΥ ΤΟΠΟΥ ΜΑΣ».pptxApostolos Syropoulos
 
Συγγραφή μαθηματικού κειμένου με χρήση του XeLaTeX (Writing mathematical tex...
Συγγραφή μαθηματικού κειμένου με χρήση του XeLaTeX (Writing  mathematical tex...Συγγραφή μαθηματικού κειμένου με χρήση του XeLaTeX (Writing  mathematical tex...
Συγγραφή μαθηματικού κειμένου με χρήση του XeLaTeX (Writing mathematical tex...Apostolos Syropoulos
 
Inflected Forms of Nouns and Adjectives
Inflected Forms of Nouns and AdjectivesInflected Forms of Nouns and Adjectives
Inflected Forms of Nouns and AdjectivesApostolos Syropoulos
 
Computational Thinking and...the Greek Alphabet
Computational Thinking and...the Greek AlphabetComputational Thinking and...the Greek Alphabet
Computational Thinking and...the Greek AlphabetApostolos Syropoulos
 
Το Αποτύπωμα του 1821 στον Τόπο μου
Το Αποτύπωμα του 1821 στον Τόπο μουΤο Αποτύπωμα του 1821 στον Τόπο μου
Το Αποτύπωμα του 1821 στον Τόπο μουApostolos Syropoulos
 
Παγκόσμια ημέρα της σταθεράς π=3,14...
Παγκόσμια ημέρα της σταθεράς π=3,14...Παγκόσμια ημέρα της σταθεράς π=3,14...
Παγκόσμια ημέρα της σταθεράς π=3,14...Apostolos Syropoulos
 

Plus de Apostolos Syropoulos (20)

A Presentation of Braga. It was made by students of school
A Presentation of Braga. It was made by students of schoolA Presentation of Braga. It was made by students of school
A Presentation of Braga. It was made by students of school
 
A short presentation of Italy made by students of a school in Cosimo, Sicily,...
A short presentation of Italy made by students of a school in Cosimo, Sicily,...A short presentation of Italy made by students of a school in Cosimo, Sicily,...
A short presentation of Italy made by students of a school in Cosimo, Sicily,...
 
Social Media Algorithms - Part of the "Computers in out Life" Erasmus+ Project
Social Media Algorithms - Part of the "Computers in out Life" Erasmus+ ProjectSocial Media Algorithms - Part of the "Computers in out Life" Erasmus+ Project
Social Media Algorithms - Part of the "Computers in out Life" Erasmus+ Project
 
A gentle introduction to Artificial Intelligence
A gentle introduction to Artificial IntelligenceA gentle introduction to Artificial Intelligence
A gentle introduction to Artificial Intelligence
 
ΑΡΧΟΝΤΙΚΟ ΠΑΜΟΥΚΤΣΟΓΛΟΥ - Pamouktsoglu Mansion
ΑΡΧΟΝΤΙΚΟ ΠΑΜΟΥΚΤΣΟΓΛΟΥ - Pamouktsoglu MansionΑΡΧΟΝΤΙΚΟ ΠΑΜΟΥΚΤΣΟΓΛΟΥ - Pamouktsoglu Mansion
ΑΡΧΟΝΤΙΚΟ ΠΑΜΟΥΚΤΣΟΓΛΟΥ - Pamouktsoglu Mansion
 
Το Ορφανοτροφείο Θηλέων Ξάνθης
Το Ορφανοτροφείο Θηλέων ΞάνθηςΤο Ορφανοτροφείο Θηλέων Ξάνθης
Το Ορφανοτροφείο Θηλέων Ξάνθης
 
Το Αρχαιολογικό Μουσείο Αβδήρων
Το Αρχαιολογικό Μουσείο ΑβδήρωνΤο Αρχαιολογικό Μουσείο Αβδήρων
Το Αρχαιολογικό Μουσείο Αβδήρων
 
Ταφικά έθιμα στα αρχαία Άβδηρα
Ταφικά έθιμα στα αρχαία ΆβδηραΤαφικά έθιμα στα αρχαία Άβδηρα
Ταφικά έθιμα στα αρχαία Άβδηρα
 
Το ορφανοτροφείο της Ξάνθης
Το ορφανοτροφείο της ΞάνθηςΤο ορφανοτροφείο της Ξάνθης
Το ορφανοτροφείο της Ξάνθης
 
Μικρασιατική κατατστροφή - Μέρος 3
Μικρασιατική κατατστροφή - Μέρος 3Μικρασιατική κατατστροφή - Μέρος 3
Μικρασιατική κατατστροφή - Μέρος 3
 
Μικρασιατική κατατστροφή - Μέρος 2
Μικρασιατική κατατστροφή - Μέρος 2Μικρασιατική κατατστροφή - Μέρος 2
Μικρασιατική κατατστροφή - Μέρος 2
 
Αφιέρωμα στη Μικρά Ασία
Αφιέρωμα στη Μικρά ΑσίαΑφιέρωμα στη Μικρά Ασία
Αφιέρωμα στη Μικρά Ασία
 
ΕΚΠΑΙΔΕΥΤΙΚΗ ΔΡΑΣΗ «ΙΧΝΙΛΑΤΩΝΤΑΣ ΤΟ ΠΑΡΕΛΘΟΝ ΤΟΥ ΤΟΠΟΥ ΜΑΣ».pptx
ΕΚΠΑΙΔΕΥΤΙΚΗ ΔΡΑΣΗ «ΙΧΝΙΛΑΤΩΝΤΑΣ ΤΟ ΠΑΡΕΛΘΟΝ ΤΟΥ ΤΟΠΟΥ ΜΑΣ».pptxΕΚΠΑΙΔΕΥΤΙΚΗ ΔΡΑΣΗ «ΙΧΝΙΛΑΤΩΝΤΑΣ ΤΟ ΠΑΡΕΛΘΟΝ ΤΟΥ ΤΟΠΟΥ ΜΑΣ».pptx
ΕΚΠΑΙΔΕΥΤΙΚΗ ΔΡΑΣΗ «ΙΧΝΙΛΑΤΩΝΤΑΣ ΤΟ ΠΑΡΕΛΘΟΝ ΤΟΥ ΤΟΠΟΥ ΜΑΣ».pptx
 
How to Convert Units of Measure
How to Convert Units of MeasureHow to Convert Units of Measure
How to Convert Units of Measure
 
Συγγραφή μαθηματικού κειμένου με χρήση του XeLaTeX (Writing mathematical tex...
Συγγραφή μαθηματικού κειμένου με χρήση του XeLaTeX (Writing  mathematical tex...Συγγραφή μαθηματικού κειμένου με χρήση του XeLaTeX (Writing  mathematical tex...
Συγγραφή μαθηματικού κειμένου με χρήση του XeLaTeX (Writing mathematical tex...
 
Inflected Forms of Nouns and Adjectives
Inflected Forms of Nouns and AdjectivesInflected Forms of Nouns and Adjectives
Inflected Forms of Nouns and Adjectives
 
Learning Simple Phrases in Greek
Learning Simple Phrases in GreekLearning Simple Phrases in Greek
Learning Simple Phrases in Greek
 
Computational Thinking and...the Greek Alphabet
Computational Thinking and...the Greek AlphabetComputational Thinking and...the Greek Alphabet
Computational Thinking and...the Greek Alphabet
 
Το Αποτύπωμα του 1821 στον Τόπο μου
Το Αποτύπωμα του 1821 στον Τόπο μουΤο Αποτύπωμα του 1821 στον Τόπο μου
Το Αποτύπωμα του 1821 στον Τόπο μου
 
Παγκόσμια ημέρα της σταθεράς π=3,14...
Παγκόσμια ημέρα της σταθεράς π=3,14...Παγκόσμια ημέρα της σταθεράς π=3,14...
Παγκόσμια ημέρα της σταθεράς π=3,14...
 

Dernier

ALL ABOUT MIXTURES IN GRADE 7 CLASS PPTX
ALL ABOUT MIXTURES IN GRADE 7 CLASS PPTXALL ABOUT MIXTURES IN GRADE 7 CLASS PPTX
ALL ABOUT MIXTURES IN GRADE 7 CLASS PPTXDole Philippines School
 
CHROMATOGRAPHY PALLAVI RAWAT.pptx
CHROMATOGRAPHY  PALLAVI RAWAT.pptxCHROMATOGRAPHY  PALLAVI RAWAT.pptx
CHROMATOGRAPHY PALLAVI RAWAT.pptxpallavirawat456
 
Pests of Bengal gram_Identification_Dr.UPR.pdf
Pests of Bengal gram_Identification_Dr.UPR.pdfPests of Bengal gram_Identification_Dr.UPR.pdf
Pests of Bengal gram_Identification_Dr.UPR.pdfPirithiRaju
 
Call Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 Genuine
Call Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 GenuineCall Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 Genuine
Call Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 Genuinethapagita
 
OECD bibliometric indicators: Selected highlights, April 2024
OECD bibliometric indicators: Selected highlights, April 2024OECD bibliometric indicators: Selected highlights, April 2024
OECD bibliometric indicators: Selected highlights, April 2024innovationoecd
 
Bioteknologi kelas 10 kumer smapsa .pptx
Bioteknologi kelas 10 kumer smapsa .pptxBioteknologi kelas 10 kumer smapsa .pptx
Bioteknologi kelas 10 kumer smapsa .pptx023NiWayanAnggiSriWa
 
《Queensland毕业文凭-昆士兰大学毕业证成绩单》
《Queensland毕业文凭-昆士兰大学毕业证成绩单》《Queensland毕业文凭-昆士兰大学毕业证成绩单》
《Queensland毕业文凭-昆士兰大学毕业证成绩单》rnrncn29
 
The dark energy paradox leads to a new structure of spacetime.pptx
The dark energy paradox leads to a new structure of spacetime.pptxThe dark energy paradox leads to a new structure of spacetime.pptx
The dark energy paradox leads to a new structure of spacetime.pptxEran Akiva Sinbar
 
Pests of soyabean_Binomics_IdentificationDr.UPR.pdf
Pests of soyabean_Binomics_IdentificationDr.UPR.pdfPests of soyabean_Binomics_IdentificationDr.UPR.pdf
Pests of soyabean_Binomics_IdentificationDr.UPR.pdfPirithiRaju
 
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...lizamodels9
 
Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024AyushiRastogi48
 
trihybrid cross , test cross chi squares
trihybrid cross , test cross chi squarestrihybrid cross , test cross chi squares
trihybrid cross , test cross chi squaresusmanzain586
 
Pests of castor_Binomics_Identification_Dr.UPR.pdf
Pests of castor_Binomics_Identification_Dr.UPR.pdfPests of castor_Binomics_Identification_Dr.UPR.pdf
Pests of castor_Binomics_Identification_Dr.UPR.pdfPirithiRaju
 
User Guide: Magellan MX™ Weather Station
User Guide: Magellan MX™ Weather StationUser Guide: Magellan MX™ Weather Station
User Guide: Magellan MX™ Weather StationColumbia Weather Systems
 
Harmful and Useful Microorganisms Presentation
Harmful and Useful Microorganisms PresentationHarmful and Useful Microorganisms Presentation
Harmful and Useful Microorganisms Presentationtahreemzahra82
 
(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)
(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)
(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)riyaescorts54
 
User Guide: Orion™ Weather Station (Columbia Weather Systems)
User Guide: Orion™ Weather Station (Columbia Weather Systems)User Guide: Orion™ Weather Station (Columbia Weather Systems)
User Guide: Orion™ Weather Station (Columbia Weather Systems)Columbia Weather Systems
 
Microteaching on terms used in filtration .Pharmaceutical Engineering
Microteaching on terms used in filtration .Pharmaceutical EngineeringMicroteaching on terms used in filtration .Pharmaceutical Engineering
Microteaching on terms used in filtration .Pharmaceutical EngineeringPrajakta Shinde
 
Dubai Calls Girl Lisa O525547819 Lexi Call Girls In Dubai
Dubai Calls Girl Lisa O525547819 Lexi Call Girls In DubaiDubai Calls Girl Lisa O525547819 Lexi Call Girls In Dubai
Dubai Calls Girl Lisa O525547819 Lexi Call Girls In Dubaikojalkojal131
 

Dernier (20)

Let’s Say Someone Did Drop the Bomb. Then What?
Let’s Say Someone Did Drop the Bomb. Then What?Let’s Say Someone Did Drop the Bomb. Then What?
Let’s Say Someone Did Drop the Bomb. Then What?
 
ALL ABOUT MIXTURES IN GRADE 7 CLASS PPTX
ALL ABOUT MIXTURES IN GRADE 7 CLASS PPTXALL ABOUT MIXTURES IN GRADE 7 CLASS PPTX
ALL ABOUT MIXTURES IN GRADE 7 CLASS PPTX
 
CHROMATOGRAPHY PALLAVI RAWAT.pptx
CHROMATOGRAPHY  PALLAVI RAWAT.pptxCHROMATOGRAPHY  PALLAVI RAWAT.pptx
CHROMATOGRAPHY PALLAVI RAWAT.pptx
 
Pests of Bengal gram_Identification_Dr.UPR.pdf
Pests of Bengal gram_Identification_Dr.UPR.pdfPests of Bengal gram_Identification_Dr.UPR.pdf
Pests of Bengal gram_Identification_Dr.UPR.pdf
 
Call Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 Genuine
Call Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 GenuineCall Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 Genuine
Call Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 Genuine
 
OECD bibliometric indicators: Selected highlights, April 2024
OECD bibliometric indicators: Selected highlights, April 2024OECD bibliometric indicators: Selected highlights, April 2024
OECD bibliometric indicators: Selected highlights, April 2024
 
Bioteknologi kelas 10 kumer smapsa .pptx
Bioteknologi kelas 10 kumer smapsa .pptxBioteknologi kelas 10 kumer smapsa .pptx
Bioteknologi kelas 10 kumer smapsa .pptx
 
《Queensland毕业文凭-昆士兰大学毕业证成绩单》
《Queensland毕业文凭-昆士兰大学毕业证成绩单》《Queensland毕业文凭-昆士兰大学毕业证成绩单》
《Queensland毕业文凭-昆士兰大学毕业证成绩单》
 
The dark energy paradox leads to a new structure of spacetime.pptx
The dark energy paradox leads to a new structure of spacetime.pptxThe dark energy paradox leads to a new structure of spacetime.pptx
The dark energy paradox leads to a new structure of spacetime.pptx
 
Pests of soyabean_Binomics_IdentificationDr.UPR.pdf
Pests of soyabean_Binomics_IdentificationDr.UPR.pdfPests of soyabean_Binomics_IdentificationDr.UPR.pdf
Pests of soyabean_Binomics_IdentificationDr.UPR.pdf
 
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
 
Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024
 
trihybrid cross , test cross chi squares
trihybrid cross , test cross chi squarestrihybrid cross , test cross chi squares
trihybrid cross , test cross chi squares
 
Pests of castor_Binomics_Identification_Dr.UPR.pdf
Pests of castor_Binomics_Identification_Dr.UPR.pdfPests of castor_Binomics_Identification_Dr.UPR.pdf
Pests of castor_Binomics_Identification_Dr.UPR.pdf
 
User Guide: Magellan MX™ Weather Station
User Guide: Magellan MX™ Weather StationUser Guide: Magellan MX™ Weather Station
User Guide: Magellan MX™ Weather Station
 
Harmful and Useful Microorganisms Presentation
Harmful and Useful Microorganisms PresentationHarmful and Useful Microorganisms Presentation
Harmful and Useful Microorganisms Presentation
 
(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)
(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)
(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)
 
User Guide: Orion™ Weather Station (Columbia Weather Systems)
User Guide: Orion™ Weather Station (Columbia Weather Systems)User Guide: Orion™ Weather Station (Columbia Weather Systems)
User Guide: Orion™ Weather Station (Columbia Weather Systems)
 
Microteaching on terms used in filtration .Pharmaceutical Engineering
Microteaching on terms used in filtration .Pharmaceutical EngineeringMicroteaching on terms used in filtration .Pharmaceutical Engineering
Microteaching on terms used in filtration .Pharmaceutical Engineering
 
Dubai Calls Girl Lisa O525547819 Lexi Call Girls In Dubai
Dubai Calls Girl Lisa O525547819 Lexi Call Girls In DubaiDubai Calls Girl Lisa O525547819 Lexi Call Girls In Dubai
Dubai Calls Girl Lisa O525547819 Lexi Call Girls In Dubai
 

Scala: An OO Surprise

  • 1. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Scala: An OO Surprise Apostolos Syropoulos Xanthi, Greece 4th European Lisp Symposium March 31st - April 1st, 2011 TUHH, Hamburg University of Technology, Hamburg, Germany . . . . . .
  • 2. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Outline 1. Introduction What is Scala? Object Orientation Scalability 2. Functional Features 3. Parser Builders 4. XML Processing 5. XML Processing 6. Concurrent Programming
  • 3. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming A versatile programming language . . . . . .
  • 4. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming A versatile programming language A purely object-oriented language. . . . . . .
  • 5. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming A versatile programming language A purely object-oriented language. Runs on the Java Virtual Machine. . . . . . .
  • 6. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming A versatile programming language A purely object-oriented language. Runs on the Java Virtual Machine. . . . . . .
  • 7. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming A versatile programming language A purely object-oriented language. Runs on the Java Virtual Machine. A scalable language. . . . . . .
  • 8. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming A versatile programming language A purely object-oriented language. Runs on the Java Virtual Machine. A scalable language. Has features found in functional programming languages, but it is not a functional langauge! . . . . . .
  • 9. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming A versatile programming language A purely object-oriented language. Runs on the Java Virtual Machine. A scalable language. Has features found in functional programming languages, but it is not a functional langauge! Allows concurrent programing. . . . . . .
  • 10. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming A versatile programming language A purely object-oriented language. Runs on the Java Virtual Machine. A scalable language. Has features found in functional programming languages, but it is not a functional langauge! Allows concurrent programing. . . . . . .
  • 11. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming A versatile programming language A purely object-oriented language. Runs on the Java Virtual Machine. A scalable language. Has features found in functional programming languages, but it is not a functional langauge! Allows concurrent programing. Includes facilities for GUI programming. . . . . . .
  • 12. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming A versatile programming language A purely object-oriented language. Runs on the Java Virtual Machine. A scalable language. Has features found in functional programming languages, but it is not a functional langauge! Allows concurrent programing. Includes facilities for GUI programming. Seamless integration of XML. . . . . . .
  • 13. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming A versatile programming language A purely object-oriented language. Runs on the Java Virtual Machine. A scalable language. Has features found in functional programming languages, but it is not a functional langauge! Allows concurrent programing. Includes facilities for GUI programming. Seamless integration of XML. . . . . . .
  • 14. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming A versatile programming language A purely object-oriented language. Runs on the Java Virtual Machine. A scalable language. Has features found in functional programming languages, but it is not a functional langauge! Allows concurrent programing. Includes facilities for GUI programming. Seamless integration of XML. Provides parser combinators. . . . . . .
  • 15. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Principles of Object Orientation . . . . . .
  • 16. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Principles of Object Orientation Abstraction (i.e., a software object is an idealization of a real world object). . . . . . .
  • 17. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Principles of Object Orientation Abstraction (i.e., a software object is an idealization of a real world object). Encapsulation (i.e., a data protection mechanism). . . . . . .
  • 18. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Principles of Object Orientation Abstraction (i.e., a software object is an idealization of a real world object). Encapsulation (i.e., a data protection mechanism). Inheritance (i.e., an object may extend the functionality of another object). . . . . . .
  • 19. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Principles of Object Orientation Abstraction (i.e., a software object is an idealization of a real world object). Encapsulation (i.e., a data protection mechanism). Inheritance (i.e., an object may extend the functionality of another object). Polymorphism (i.e., software modules may have different instances with identical behavior). . . . . . .
  • 20. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming What makes a programming language scalable? . . . . . .
  • 21. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming What makes a programming language scalable? Any language that can be extended seamlessly is scalable. . . . . . .
  • 22. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming What makes a programming language scalable? Any language that can be extended seamlessly is scalable. Gyu L. Steel Jr.: “[A] language design can no longer be a thing. It must be a pattern–a pattern for growth–a pattern for growing the pattern for defining the patterns that programmers can use for their real work and their main goal.” . . . . . .
  • 23. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming What makes a programming language scalable? Any language that can be extended seamlessly is scalable. Gyu L. Steel Jr.: “[A] language design can no longer be a thing. It must be a pattern–a pattern for growth–a pattern for growing the pattern for defining the patterns that programmers can use for their real work and their main goal.” . . . . . .
  • 24. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming What makes a programming language scalable? Any language that can be extended seamlessly is scalable. Gyu L. Steel Jr.: “[A] language design can no longer be a thing. It must be a pattern–a pattern for growth–a pattern for growing the pattern for defining the patterns that programmers can use for their real work and their main goal.” There two forms of growth: variable vocabulary or variable semantics. . . . . . .
  • 25. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming What makes a programming language scalable? Any language that can be extended seamlessly is scalable. Gyu L. Steel Jr.: “[A] language design can no longer be a thing. It must be a pattern–a pattern for growth–a pattern for growing the pattern for defining the patterns that programmers can use for their real work and their main goal.” There two forms of growth: variable vocabulary or variable semantics. Generic types, operator overloading, and user-defined light-weight types form the kernel of every scalable language. . . . . . .
  • 26. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . A Generic Stack
  • 27. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . A Generic Stack class Stack [γ] (n: Int) { private var S = new Array[γ](n) private var top = 0; def push(elem: γ) { top = top + 1 S(top) = elem } def pop () : γ = { var oldtop = top top = top - 1 S(oldtop) } }
  • 28. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming User-Defined Light-Weight Complex Numbers . . . . . .
  • 29. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming User-Defined Light-Weight Complex Numbers class Complex(val re: Double, val im: Double) { def + (x: Complex) = new Complex(re + x.re, im + x.im) def unary_- = new Complex(-Re, -Im) . . . . . . . . . . . . . . . . . . override def toString = if(re == 0 && im == 0) "0" … } object Complex{ def apply(re: Double)(im: Double) = . . . . . . new Complex(re, im) } object i extends Complex(0.0, 1.0) . . . . . . . . . . . . . . . . . . . var a = 5 + 3.0*i // a complex number!!!
  • 30. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Call-By-Name or how to define new commands . . . . . .
  • 31. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Call-By-Name or how to define new commands def loop(pre: => Unit)(cond: => Boolean) (post: => Unit): Unit = { . . . . . . pre if (!cond) { post loop(pre)(cond)(post) } else () } var x=6; var y=0 loop { x=x-1; y=y+1 } (x == 0 ) { println(x); println(y) }
  • 32. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Scala’s Functional Features . . . . . .
  • 33. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Scala’s Functional Features Functions are software modules (objects in Scala’s parlance). . . . . . .
  • 34. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Scala’s Functional Features Functions are software modules (objects in Scala’s parlance). Users can define anonymous functions. . . . . . .
  • 35. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Scala’s Functional Features Functions are software modules (objects in Scala’s parlance). Users can define anonymous functions. var inc = (x:Int) => x+1 . . . . . .
  • 36. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Scala’s Functional Features Functions are software modules (objects in Scala’s parlance). Users can define anonymous functions. var inc = (x:Int) => x+1 . . . . . . Supports closures.
  • 37. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Scala’s Functional Features Functions are software modules (objects in Scala’s parlance). Users can define anonymous functions. var inc = (x:Int) => x+1 . . . . . . Supports closures. var mul = (x: Int) => (y:Int) => x*y var mul3 = mul(3)
  • 38. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Scala’s Functional Features Functions are software modules (objects in Scala’s parlance). Users can define anonymous functions. var inc = (x:Int) => x+1 . . . . . . Supports closures. var mul = (x: Int) => (y:Int) => x*y var mul3 = mul(3) Pattern matching.
  • 39. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Data Structures with Class Hierarchies . . . . . .
  • 40. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Data Structures with Class Hierarchies . . . . . . Haskell binary tree
  • 41. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Data Structures with Class Hierarchies . . . . . . Haskell binary tree datatype BinTree = Empty | Node(Int, BinTree, BinTree)
  • 42. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Data Structures with Class Hierarchies . . . . . . Haskell binary tree datatype BinTree = Empty | Node(Int, BinTree, BinTree) Scala binary tree
  • 43. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Data Structures with Class Hierarchies . . . . . . Haskell binary tree datatype BinTree = Empty | Node(Int, BinTree, BinTree) Scala binary tree abstract class BinTree case object EmptyTree extends BinTree case class Node(elem : Int, left : BinTree, right: BinTree) extends BinTree
  • 44. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Pattern Matching in Action . . . . . .
  • 45. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Pattern Matching in Action . . . . . . Depth of a binary tree
  • 46. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Pattern Matching in Action . . . . . . Depth of a binary tree def depth(t: BinTree): Int = { t match { case EmptyTree => 0 case Node(_,EmptyTree,r) => 1 + depth(r) case Node(_,l,EmptyTree) => 1 + depth(l) case Node(_,l,r) => Math.max(depth(l), depth(r)) + 1 } }
  • 47. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Constructing Parsers with Parser Builders . . . . . .
  • 48. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Constructing Parsers with Parser Builders Tools that can be combined to build real parsers. . . . . . .
  • 49. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Constructing Parsers with Parser Builders Tools that can be combined to build real parsers. A toy parser that accepts binary numerals. . . . . . .
  • 50. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Constructing Parsers with Parser Builders Tools that can be combined to build real parsers. A toy parser that accepts binary numerals. import scala.util.parsing.combinator._ class BinDigit extends JavaTokenParsers { def D = "0" | "1" def B = D~rep(D) def parse(text : String) = parseAll(B,text) } var P = new BinDigit println("input : "+args(0)) println(P.parse(args(0))) . . . . . .
  • 51. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . XML Processing
  • 52. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . XML Processing Variables can be assigned XML content.
  • 53. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . XML Processing Variables can be assigned XML content. var poem = <poem> <title> Magic Everywhere </title> <poet realname="yes"> Tom Jones </poet> <stanza> <verse> magic everywhere </verse> </stanza> </poem> println(poem)
  • 54. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . XML Processing Variables can be assigned XML content. var poem = <poem> <title> Magic Everywhere </title> <poet realname="yes"> Tom Jones </poet> <stanza> <verse> magic everywhere </verse> </stanza> </poem> println(poem) Or they can be assigned XML content stored in files.
  • 55. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . XML Processing Variables can be assigned XML content. var poem = <poem> <title> Magic Everywhere </title> <poet realname="yes"> Tom Jones </poet> <stanza> <verse> magic everywhere </verse> </stanza> </poem> println(poem) Or they can be assigned XML content stored in files. val x = XML.loadFile("listdir.html")
  • 56. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . XML Processing
  • 57. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . XML Processing Saving XML content.
  • 58. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . XML Processing Saving XML content. var z = <person> <name>Blaise</name> <surname>Pascal</surname> </person> XML.save("persons.xml",z)
  • 59. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . XML Processing Saving XML content. var z = <person> <name>Blaise</name> <surname>Pascal</surname> </person> XML.save("persons.xml",z) Example: Find all poems that have been published after 1960 and print the title and the poet of each such poem.
  • 60. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . XML Processing Saving XML content. var z = <person> <name>Blaise</name> <surname>Pascal</surname> </person> XML.save("persons.xml",z) Example: Find all poems that have been published after 1960 and print the title and the poet of each such poem. for ( val poem <- poems "poem" ) { if ( (poem "year").text.trim.toInt > 1960 ) { var poet = (poem "poet").text var title = (poem "title").text println("""+title+"" by "+poet) }
  • 61. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Truths
  • 62. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Truths EETimes Europe (http://www.electronics-eetimes.com): “As Moore’s Law runs out of steam and computing goes mobile, technologists are searching for ways to make the leap to new parallel programming frameworks that can leverage low-power multicore architectures.”
  • 63. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Truths EETimes Europe (http://www.electronics-eetimes.com): “As Moore’s Law runs out of steam and computing goes mobile, technologists are searching for ways to make the leap to new parallel programming frameworks that can leverage low-power multicore architectures.”
  • 64. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Truths EETimes Europe (http://www.electronics-eetimes.com): “As Moore’s Law runs out of steam and computing goes mobile, technologists are searching for ways to make the leap to new parallel programming frameworks that can leverage low-power multicore architectures.” Concurrent programming is not only the next logical step in software development, but the next necessary step.
  • 65. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Truths EETimes Europe (http://www.electronics-eetimes.com): “As Moore’s Law runs out of steam and computing goes mobile, technologists are searching for ways to make the leap to new parallel programming frameworks that can leverage low-power multicore architectures.” Concurrent programming is not only the next logical step in software development, but the next necessary step.
  • 66. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Truths EETimes Europe (http://www.electronics-eetimes.com): “As Moore’s Law runs out of steam and computing goes mobile, technologists are searching for ways to make the leap to new parallel programming frameworks that can leverage low-power multicore architectures.” Concurrent programming is not only the next logical step in software development, but the next necessary step. All modern programming languages must provide constructs and libraries that will ease the construction of concurrent programs
  • 67. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Scala and Concurrency Scala programmers can code concurrent structures with…
  • 68. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Scala and Concurrency Scala programmers can code concurrent structures with… threads (i.e., Java’s legacy to Scala)
  • 69. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Scala and Concurrency Scala programmers can code concurrent structures with… threads (i.e., Java’s legacy to Scala)
  • 70. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Scala and Concurrency Scala programmers can code concurrent structures with… threads (i.e., Java’s legacy to Scala) mailboxes (something like actors)
  • 71. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Scala and Concurrency Scala programmers can code concurrent structures with… threads (i.e., Java’s legacy to Scala) mailboxes (something like actors)
  • 72. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Scala and Concurrency Scala programmers can code concurrent structures with… threads (i.e., Java’s legacy to Scala) mailboxes (something like actors) actors
  • 73. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Creating threaded applications by extending class Thread . . . . . .
  • 74. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Creating threaded applications by extending class Thread class PrintProgressMark(val mark: Char, val delay :Int) extends Thread { . . . . . . private var i = 0 override def run(): Unit = try { while (i <= 100) { print(mark); i += 1; Thread.sleep(delay); } } catch { case ex : InterruptedException => return } } object threadExample { def main(args: Array[String]) { new PrintProgressMark('+', 40).start new PrintProgressMark('*', 100).start } }
  • 75. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Creating threaded applications by using trait Runnable . . . . . .
  • 76. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Creating threaded applications by using trait Runnable class PrintProgressMark2(val mark: Char, val delay :Int) extends Runnable { . . . . . . private var i = 0 override def run(): Unit = try { while (i <= 100) { print(mark); i += 1; Thread.sleep(delay_) } } catch { case ex : InterruptedException => return } } object threadExample2 { def main(args: Array[String]) { var plus = new PrintProgressMark2('+', 40) var ast = new PrintProgressMark2('*', 100) new Thread(plus).start(); new Thread(ast).start() } }
  • 77. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . What is an actor? An actor is a computational agent which maps each incoming communication to a triple consisting of…
  • 78. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . What is an actor? An actor is a computational agent which maps each incoming communication to a triple consisting of… a finite set of communications sent to other actors;
  • 79. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . What is an actor? An actor is a computational agent which maps each incoming communication to a triple consisting of… a finite set of communications sent to other actors;
  • 80. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . What is an actor? An actor is a computational agent which maps each incoming communication to a triple consisting of… a finite set of communications sent to other actors; a new behavior that will govern the response to the next communication processed; and,
  • 81. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . What is an actor? An actor is a computational agent which maps each incoming communication to a triple consisting of… a finite set of communications sent to other actors; a new behavior that will govern the response to the next communication processed; and,
  • 82. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . What is an actor? An actor is a computational agent which maps each incoming communication to a triple consisting of… a finite set of communications sent to other actors; a new behavior that will govern the response to the next communication processed; and, a finite set of new actors created.
  • 83. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . What is an actor? An actor is a computational agent which maps each incoming communication to a triple consisting of… a finite set of communications sent to other actors; a new behavior that will govern the response to the next communication processed; and, a finite set of new actors created.
  • 84. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . What is an actor? An actor is a computational agent which maps each incoming communication to a triple consisting of… a finite set of communications sent to other actors; a new behavior that will govern the response to the next communication processed; and, a finite set of new actors created. Thus,
  • 85. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . What is an actor? An actor is a computational agent which maps each incoming communication to a triple consisting of… a finite set of communications sent to other actors; a new behavior that will govern the response to the next communication processed; and, a finite set of new actors created. Thus, behaviors are history sensitive;
  • 86. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . What is an actor? An actor is a computational agent which maps each incoming communication to a triple consisting of… a finite set of communications sent to other actors; a new behavior that will govern the response to the next communication processed; and, a finite set of new actors created. Thus, behaviors are history sensitive;
  • 87. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . What is an actor? An actor is a computational agent which maps each incoming communication to a triple consisting of… a finite set of communications sent to other actors; a new behavior that will govern the response to the next communication processed; and, a finite set of new actors created. Thus, behaviors are history sensitive; there is no presumed sequentiality in the actions an actor performs; and,
  • 88. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . What is an actor? An actor is a computational agent which maps each incoming communication to a triple consisting of… a finite set of communications sent to other actors; a new behavior that will govern the response to the next communication processed; and, a finite set of new actors created. Thus, behaviors are history sensitive; there is no presumed sequentiality in the actions an actor performs; and,
  • 89. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . What is an actor? An actor is a computational agent which maps each incoming communication to a triple consisting of… a finite set of communications sent to other actors; a new behavior that will govern the response to the next communication processed; and, a finite set of new actors created. Thus, behaviors are history sensitive; there is no presumed sequentiality in the actions an actor performs; and, actor creation is an integral of the computational model.
  • 90. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming A first example in actor programming . . . . . .
  • 91. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming A first example in actor programming import scala.actors.Actor._ object actorsExample { def main(args: Array[String]) { var PrintProgressPlus = actor { var i = 0 while (i <= max) { print('+'); i += 1; Thread.sleep(40) } } var PrintProgressTimes = actor { var i = 0 while (i <= max) { print('*'); i += 1; Thread.sleep(100) } } 1 // <--- block must end in result expression, } } // not in definition . . . . . .
  • 92. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Defining a class that subclasses trait Actor . . . . . .
  • 93. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming Defining a class that subclasses trait Actor import scala.actors._ class PrintProgressMark(val mark: Char, val delay :Int) extends Actor { . . . . . . private var i = 0 def act: Unit = { while (i <= 100) { print(mark); i += 1; Thread.sleep(delay_) } } } object actorsExample { def main(args: Array[String]) { new PrintProgressMark('+', 40).start new PrintProgressMark('*', 100).start } }
  • 94. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Computing Factorials Carl Hewitt in “Viewing Cotrol Structures as Patterns of Passing Messages” (Artificial Intelligence 8, 3 (1977), 323–364)
  • 95. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Computing Factorials Carl Hewitt in “Viewing Cotrol Structures as Patterns of Passing Messages” (Artificial Intelligence 8, 3 (1977), 323–364) “present[s] an approach to modelling intelligence in terms of a society of communicating knowledge-based problem solving experts”;
  • 96. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Computing Factorials Carl Hewitt in “Viewing Cotrol Structures as Patterns of Passing Messages” (Artificial Intelligence 8, 3 (1977), 323–364) “present[s] an approach to modelling intelligence in terms of a society of communicating knowledge-based problem solving experts”;
  • 97. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Computing Factorials Carl Hewitt in “Viewing Cotrol Structures as Patterns of Passing Messages” (Artificial Intelligence 8, 3 (1977), 323–364) “present[s] an approach to modelling intelligence in terms of a society of communicating knowledge-based problem solving experts”; “each of the experts can be viewed as a society that can be further decomposed in the same way until the primitive actors of the system are reached”;
  • 98. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Computing Factorials Carl Hewitt in “Viewing Cotrol Structures as Patterns of Passing Messages” (Artificial Intelligence 8, 3 (1977), 323–364) “present[s] an approach to modelling intelligence in terms of a society of communicating knowledge-based problem solving experts”; “each of the experts can be viewed as a society that can be further decomposed in the same way until the primitive actors of the system are reached”;
  • 99. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Computing Factorials Carl Hewitt in “Viewing Cotrol Structures as Patterns of Passing Messages” (Artificial Intelligence 8, 3 (1977), 323–364) “present[s] an approach to modelling intelligence in terms of a society of communicating knowledge-based problem solving experts”; “each of the experts can be viewed as a society that can be further decomposed in the same way until the primitive actors of the system are reached”; he was “investigating the nature of the communication mechanisms needed for effective problem-solving by a society of experts and the conventions of civilized discourse that make this possible.”
  • 100. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Computing Factorials
  • 101. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Computing Factorials Hewitt demonstrates these “principles” by showing how to compute the factorial function with actors:
  • 102. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Computing Factorials Hewitt demonstrates these “principles” by showing how to compute the factorial function with actors:
  • 103. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Computing Factorials Hewitt demonstrates these “principles” by showing how to compute the factorial function with actors: 1. using a resursive procedure, that is, a procedure that uses replication and
  • 104. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Computing Factorials Hewitt demonstrates these “principles” by showing how to compute the factorial function with actors: 1. using a resursive procedure, that is, a procedure that uses replication and
  • 105. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Computing Factorials Hewitt demonstrates these “principles” by showing how to compute the factorial function with actors: 1. using a resursive procedure, that is, a procedure that uses replication and 2. an iterative procudure, that is, a procedure that relies on message passing to deliver a result.
  • 106. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Actor Replication
  • 107. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Actor Replication case class Val(a: Actor, n: Int) case class Res(n: Int) class Fact extends Actor { def act = react { case Val(a,0) => a ! Res(1) case Val(a,n) => var p = new Fact p.start p ! Val(self,n-1) react { case Val(_, m) => a ! Val(a, n*m) case Res(m) => a ! Val(a, n*m)} } }
  • 108. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Using Class Fact
  • 109. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Using Class Fact object actorsExample { def main(args: Array[String]) { var factorial = actor { react { case Val(a,n) => var q = new Fact q.start q ! Val(self,n) react { case Val(_,f) => a ! Val(a,f) } } } factorial ! Val(self,6) react { case Val(_, n) => println(n) } } }
  • 110. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Iterative Actor
  • 111. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Iterative Actor case class InitVal(a: Actor, n: Int) case class Val(a: Actor, n: Int, m: Int) object actorsExample { def main(args: Array[String]) { val loopActor = actor { var ResActor : Actor = null loop{ react { case Val(_,acc,1) => ResActor ! acc; exit("done") case Val(a,1,count) => ResActor = a self ! Val(self,count,count-1) case Val(a,acc,count) => self ! Val(self,acc*count,count-1) } } }
  • 112. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Using Class Fact
  • 113. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . Using Class Fact var factorial = actor { react { case InitVal(a,0) => a ! InitVal(a, 1) case InitVal(a,1) => a ! InitVal(a, 1) case InitVal(a,n) => loopActor ! Val(self,1,n) react { case f: Int => a ! InitVal(a,f) } } } factorial ! InitVal(self,6) receive { case InitVal(_, n) => println(n) } } }
  • 114. Scala: An OO Surprise Syropoulos Introduction What is Scala? Object Orientation Scalability Functional Features Parser Builders XML Processing XML Processing Concurrent Program-ming . . . . . . The end! Thank you so much for your attention!