This document discusses Scala and its features. It provides an example of building a chat application in 30 lines of code using Lift framework. It also demonstrates pattern matching, functional data structures like lists and tuples, for comprehensions, and common Scala tools and frameworks. The document promotes Scala as a pragmatic and scalable language that blends object-oriented and functional programming. It encourages learning more about Scala.
Scala er et Java-relateret, statisk typet programmeringssprog i hastig fremmarch. Sproget kombinerer aspekter fra objekt- og funktionsorienterede sprog og fokuserer på skalerbarhed og effektivitet, både på det kodemæssige og afviklingsmæssige niveau. Syntaksen er elegant og koncis. Samtidig indeholder sproget stærke konstruktioner til understøttelse af parallelle applikationer, der udnytter fremtidens hardwarearkitekturer.
Short (45 min) version of my 'Pragmatic Real-World Scala' talk. Discussing patterns and idioms discovered during 1.5 years of building a production system for finance; portfolio management and simulation.
Scala is becoming the language of choice for many development teams. This talk highlights how Scala excels in the world of multi-core processing and explores how it compares to Java 8.
Video Presentation: http://youtu.be/8vxTowBXJSg
Scala er et Java-relateret, statisk typet programmeringssprog i hastig fremmarch. Sproget kombinerer aspekter fra objekt- og funktionsorienterede sprog og fokuserer på skalerbarhed og effektivitet, både på det kodemæssige og afviklingsmæssige niveau. Syntaksen er elegant og koncis. Samtidig indeholder sproget stærke konstruktioner til understøttelse af parallelle applikationer, der udnytter fremtidens hardwarearkitekturer.
Java som sprog har ikke bevæget sig meget de seneste år. Vi har stadig ikke closures eller funktionelle aspekter som f.eks. C# har haft siden version 3. Er Scala svaret på enhver Javaudviklers bønner eller er sproget kun interessant for tågehoveder som mig, som begynder at synes bedre og bedre om funktionsorientering? Er den store portion syntaktisk sukker, Scala bringer på bordet, bare tomme kalorier?
Scala er et Java-relateret, statisk typet programmeringssprog i hastig fremmarch. Sproget kombinerer aspekter fra objekt- og funktionsorienterede sprog og fokuserer på skalerbarhed og effektivitet, både på det kodemæssige og afviklingsmæssige niveau. Syntaksen er elegant og koncis. Samtidig indeholder sproget stærke konstruktioner til understøttelse af parallelle applikationer, der udnytter fremtidens hardwarearkitekturer.
Short (45 min) version of my 'Pragmatic Real-World Scala' talk. Discussing patterns and idioms discovered during 1.5 years of building a production system for finance; portfolio management and simulation.
Scala is becoming the language of choice for many development teams. This talk highlights how Scala excels in the world of multi-core processing and explores how it compares to Java 8.
Video Presentation: http://youtu.be/8vxTowBXJSg
Scala er et Java-relateret, statisk typet programmeringssprog i hastig fremmarch. Sproget kombinerer aspekter fra objekt- og funktionsorienterede sprog og fokuserer på skalerbarhed og effektivitet, både på det kodemæssige og afviklingsmæssige niveau. Syntaksen er elegant og koncis. Samtidig indeholder sproget stærke konstruktioner til understøttelse af parallelle applikationer, der udnytter fremtidens hardwarearkitekturer.
Java som sprog har ikke bevæget sig meget de seneste år. Vi har stadig ikke closures eller funktionelle aspekter som f.eks. C# har haft siden version 3. Er Scala svaret på enhver Javaudviklers bønner eller er sproget kun interessant for tågehoveder som mig, som begynder at synes bedre og bedre om funktionsorientering? Er den store portion syntaktisk sukker, Scala bringer på bordet, bare tomme kalorier?
From Java to Scala - advantages and possible risksSeniorDevOnly
Oleksii Petinov during his presentation gave the audience the overview of his vision of Scala pros and contras. In his vision Scala smoothly integrates features of object-oriented and functional languages, enabling Java and other programmers to be more productive.
There is admittedly some truth to the statement that “Scala is complex”, but the learning curve is well worth the investment.
Be Smart, Constrain Your Types to Free Your Brain!Jorge Vásquez
Admit it: You have used a String to model email values, even though most strings aren’t valid emails (don’t worry, we all have!). Imprecise data models are easy, but they crash applications and corrupt external systems. On the other hand, precise data models take time and generate boilerplate.
So-called newtype libraries have stepped up to the challenge, making it easier to model data precisely using runtime validation. However, newtype libraries aren’t able to validate constants at compile-time, and they don’t generally work with Scala 3.
Enter ZIO Prelude Smart Types, which make it simple to model data types precisely, without any boilerplate, runtime overhead, or compile-time overhead. ZIO Prelude Smart Types work at compile-time and runtime, and they have a uniform API across Scala 2 & 3.
Join ZIO Prelude contributor Jorge Vásquez as he teaches you how to be smart, and constrain your types to free your brain!
Clojure is a new language that combines the power of Lisp with an existing hosted VM ecosystem (the Java VM). Clojure is a dynamically typed, functional, compiled language with performance on par with Java.
At the heart of all programming lies the need for abstraction, be it abstraction over our data or abstraction over the processes that operate upon it. Clojure provides a core set of powerful abstractions and ways to compose them. These abstractions are based in a heritage of Lisp but also cover many aspects of object-oriented programming as well.
This talk will examine these abstractions and introduce you to both Clojure and functional programming. Attendees are not expected to be familiar with either Clojure or FP.
In the past year there has been a tremendous amount of activity on Scala APIs for Hadoop. In this talk we`ll talk about writing Map/Reduce jobs in a more functional manner and explore the three most popular Scala packages for Hadoop: Scalding, Scoobi and Scrunch. Detailed usage examples will be provided for each along with some real world use cases.
From Java to Scala - advantages and possible risksSeniorDevOnly
Oleksii Petinov during his presentation gave the audience the overview of his vision of Scala pros and contras. In his vision Scala smoothly integrates features of object-oriented and functional languages, enabling Java and other programmers to be more productive.
There is admittedly some truth to the statement that “Scala is complex”, but the learning curve is well worth the investment.
Be Smart, Constrain Your Types to Free Your Brain!Jorge Vásquez
Admit it: You have used a String to model email values, even though most strings aren’t valid emails (don’t worry, we all have!). Imprecise data models are easy, but they crash applications and corrupt external systems. On the other hand, precise data models take time and generate boilerplate.
So-called newtype libraries have stepped up to the challenge, making it easier to model data precisely using runtime validation. However, newtype libraries aren’t able to validate constants at compile-time, and they don’t generally work with Scala 3.
Enter ZIO Prelude Smart Types, which make it simple to model data types precisely, without any boilerplate, runtime overhead, or compile-time overhead. ZIO Prelude Smart Types work at compile-time and runtime, and they have a uniform API across Scala 2 & 3.
Join ZIO Prelude contributor Jorge Vásquez as he teaches you how to be smart, and constrain your types to free your brain!
Clojure is a new language that combines the power of Lisp with an existing hosted VM ecosystem (the Java VM). Clojure is a dynamically typed, functional, compiled language with performance on par with Java.
At the heart of all programming lies the need for abstraction, be it abstraction over our data or abstraction over the processes that operate upon it. Clojure provides a core set of powerful abstractions and ways to compose them. These abstractions are based in a heritage of Lisp but also cover many aspects of object-oriented programming as well.
This talk will examine these abstractions and introduce you to both Clojure and functional programming. Attendees are not expected to be familiar with either Clojure or FP.
In the past year there has been a tremendous amount of activity on Scala APIs for Hadoop. In this talk we`ll talk about writing Map/Reduce jobs in a more functional manner and explore the three most popular Scala packages for Hadoop: Scalding, Scoobi and Scrunch. Detailed usage examples will be provided for each along with some real world use cases.
Выступление в рамках спецкурса "Немейнстримовые технологии разработки", читаемого в НГУ. http://bit.ly/mainstreamless
Аудио дорожка работает, но нужно иметь некоторое терпение, так как грузится она не моментально.
In this presentation, You will get to know about Function Literal,Higher Order Function,Partial Function,Partial Applied Function,Nested Function,Closures.
Scala is a general purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional languages, enabling Java and other programmers to be more productive." This session is an introduction of Scala for Java developers.
Presentation & Fetured Video Included.
10. Pragmatic Since 2003
Sponsored by EPFL
Martin Odersky
Seamless Java interoperability
Friendly and supportive Production
community ready
Runs on the JVM Statically typed
13. High-level
Java version
boolean hasUpperCase = false;
for (int i = 0; i < name.length(); i++) {
if (Character.isUpperCase(name.charAt(i)))
{
hasUpperCase = true;
break;
}
}
14. High-level
Scala version
val hasUpperCase = name.exists(_.isUpperCase)
15. Concise
// Java
public class Person {
private String name;
private int age;
public Person(String name,
int age) {
this.name = name;
this.age = age; // Scala
}
public String getName() { class Person(
return name; var name: String,
}
public int getAge() { var age: Int)
return age;
}
public void setName(String name) {
this.name = name;
}
public void setAge(age: int) {
this.age = age;
}
}
39. Rich interface
trait RichIterable[A] {
def iterator: Iterator[A] // contract method
def foreach(f: A => Unit) = {
val iter = iterator
while (iter.hasNext) f(iter.next)
}
def foldLeft[B](seed: B)(f: (B, A) => B) = {
var result = seed
foreach(e => result = f(result, e))
result
}
}
40. Rich interface
val richSet =
new java.util.HashSet[Int]
with RichIterable[Int]
richSet.add(1)
richSet.add(2)
richSet.foldLeft(0)((x, y) => x + y)
3
43. Stackable modifications
val set =
new java.util.HashSet[String]
with IgnoreCaseSet
set.add(“HI THERE“) // uppercase
set.contains(“hi there“) // lowercase
true
45. Run the stack of interceptors
val set =
new java.util.HashSet[String]
with IgnoreCaseSet
with LoggableSet
set.add(“HI THERE“)
“Add: HI THERE”
Prints in uppercase
46. Change the order
val set =
new java.util.HashSet[String]
with LoggableSet
with IgnoreCaseSet
set.add(“HI THERE“)
“Add: hi there”
Prints in lowercase
54. Composition
val order = new Order(customer)
with Entity
with InventoryItemSet
with Invoicable
with PurchaseLimiter
with MailNotifier
with ACL
with Versioned
with Transactional
89. Like SQL queries
for {
att <- attendees
if att.name == “Fred”
lang <- att.spokenLanguages
if lang == “Danish”
} println(att)
Find all attendees named Fred that speaks Danish
90. for / yield
val companiesForAttendeesFromLondon =
for {
att <- attendees
if att.address.city == “London”
} yield att.company
91. Everything returns a value
for (thing <- thingsFromHere)
yield getRealThing(thing)
92. Everything returns a value
val things =
for (thing <- thingsFromHere)
yield getRealThing(thing)
93. Everything returns a value
if (fromHere) {
for (thing <- thingsFromHere)
yield getRealThing(thing)
} else {
for (thing <- thingsFromThere)
yield thing
}
94. Everything returns a value
val things =
if (fromHere) {
for (thing <- thingsFromHere)
yield getRealThing(thing)
} else {
for (thing <- thingsFromThere)
yield thing
}
95. Everything returns a value
try {
if (fromHere) {
for (thing <- thingsFromHere)
yield getRealThing(thing)
} else {
for (thing <- thingsFromThere)
yield thing
}
} catch {
case e => error(e); Nil
}
96. Everything returns a value
val things =
try {
if (fromHere) {
for (thing <- thingsFromHere)
yield getRealThing(thing)
} else {
for (thing <- thingsFromThere)
yield thing
}
} catch {
case e => error(e); Nil
}
97. Everything returns a value
def getThingsFromSomewhere(
fromHere: Boolean): List[Thing] = {
try {
if (fromHere) {
for (thing <- thingsFromHere)
yield getRealThing(thing)
} else {
for (thing <- thingsFromThere)
yield thing
}
} catch {
case e => error(e); Nil
}
}
99. Pattern matching
def matchAny(a: Any): Any = a match {
case 1 => “one”
case “two” => 2
case i: Int => “scala.Int”
case <tag>{ t }</tag> => t
case head :: tail => head
case _ => “default”
}