I gave an introduction to Scala at Novi Sad on 29.05.2014. The corresponding code examples can be found here: https://github.com/lukaspustina/A-Glimpse-Of-Scala-Java-Meet-Up-in-Novi-Sad
A Glimpse of ScalaDr. Lukas Pustina@drivebytestingcodecentric AG
View Slide
Which Programming Languagewould you use now on top ofJVM? Scala!James Gosling, Father of Java
Scala is funand designed for the future.
@drivebytesting
What to expect
Syntax vs. IdiomsHow to use a language.
Before we start
Open your mind
Let’s program our mindsThe brain has bugs
Exposure EffectWe prefer things we know and are familiar with
“Gott würfelt nicht!”“God doesn’t role the dice!” — Albert Einstein
Bundesarchiv, Bild183-R57262 / CC-BY-SA
Today’sChallenges
CPU Memory
!Von NeumannBottleneck
Can Programming BeLiberated from the vonNeumann StyleA Functional Style and Its Algebra of Programs —John Backus, 1977
CPU MemoryCache
CPU MemoryCache Cache
CPU MemoryCache CacheCoreCoreCoreCore
!False Sharing
CacheCacheCacheCoreCore
!I/O Waits
This is the futureMassive parallel computing
?ThreadsThe software engineers’ answer
A UniversalModular Actor Formalism forArtificial IntelligenceCarl Hewitt, Peter Bishop, Richard Steiger 1973
Reactive ProgrammingImmutability, Functional, Actors are one approach.
A Glimpse ofScala
SCAlable LAnguageA multi-paradigm language
Return ofComputer ScienceBear with me :)
Object oriented,functional languageMulti-paradigm language
OO and func• State Mutation vs. Immutability• Object Composition vs. Functional Composition• Class Hierarchies vs. Pattern Matching
Type InferenceThe type of variables and functions is interfered fromassignments and return values.
ImmutabilityImmutability right in the language: val and immutablecollections.
Functions as1st class citizensPass a function as you would pass an Int, a String, oran arbitrary object.
Hello WorldThe first program in the REPL
[lukas@muffin] ~ ➜ scala!Welcome to Scala version 2.11.1 (Java HotSpot(TM) 64-Bit Server VM,Java 1.7.0_51).!Type in expressions to have them evaluated.!Type :help for more information.!!scala> print("Hello World")!Hello World
A Closer Look
With great power …… comes great responsibility.
EndDr. Lukas Pustina@drivebytestingcodecentric AG