Scala: functional programming for the imperative mind
Scala is a programming language that runs on the JVM and fuses functional and object-oriented paradigms. It aims to provide functional programming for programmers with an imperative mindset. Key features include functions as first-class values, pattern matching, traits for composition, and seamless interoperability with Java. While some features appear to be language features, many are actually implemented via libraries. The Scala community is growing with adoption by companies and increasing support in tools and publications.
Overview of Scala, its history, and its characteristics like running on JVM, being statically typed, and supporting functional and object-oriented programming.
Discussion of functional programming principles including focus on functions, immutability, and recursion. Key concepts include pure vs. impure functional programming.
Emphasizes the advantages of functional programming such as improved concurrency, expressiveness through higher order functions, and superior type systems.
An overview of Scala's features including its object-oriented aspect, type inference, and pure object orientation avoiding primitive types.
First-class functions in Scala, examples of function literals, and functional types showcasing how functions can be values.
Discussion on passing functions in Scala, contrasting it with anonymous classes, and the related ease and benefits of closures.
Explains traits as rich interfaces and their functionalities such as mixin capabilities. Pattern matching features are discussed as an improvement for type checking.
Explains the concept of actors in Scala, focusing on message-based concurrency and how actors exchange immutable messages efficiently.
Mentions additional library features and tools that support Scala, emphasizing the need to choose language cores wisely.
Requirements for transitioning code from Java to Scala, focusing on designing classes and managing different data types effectively.
Information about Scala's version history, community support, and tool integration with IDEs like Eclipse and IntelliJ.
Scala's increasing adoption in the industry with reports of companies switching to it. Insights from influential figures on its relevance against Java.
Summary on Scala's ease of use compared to Java, its powerful features, and adoption due to Java interoperability and dissatisfaction with Java.
Provides links and resources for further information about Scala and its community.
Invitation for any questions related to the presentation content on Scala.
#2 Intro, gaan het hebben over Scala
Wellicht al eens gehoord over FP, lijkt groeiende interesse
wat is imperatief? Ook wel procedureel, met state, het is wat we in Java eigenlijk doen.
#3 Intro, gaan het hebben over Scala
Wellicht al eens gehoord over FP, lijkt groeiende interesse
wat is imperatief? Ook wel procedureel, met state, het is wat we in Java eigenlijk doen.
#4 Intro, gaan het hebben over Scala
Wellicht al eens gehoord over FP, lijkt groeiende interesse
wat is imperatief? Ook wel procedureel, met state, het is wat we in Java eigenlijk doen.
#6 Odersky: co-designer generics, original author javac.
Wellicht had hier oracle logo moeten staan :)
#7 *Voordelen JVM (enorm veel tijd in optimalisatie, platform agnostisch etc.), ook wat nadelen (niet echt ingericht op FP constructies).
* OO, maar dan ook puur, en met extra functionaliteit
* Scripting: REPL shell
#8 Scala redelijk uniek in samenvoegen OO+FP
OCaml en F# zijn toch meer FP met een OO systeem er aan geplakt.
#10 Recursie niet alleen in functies, ook in data (bomen, lijsten)
#11 Recursie niet alleen in functies, ook in data (bomen, lijsten)
#12 Recursie niet alleen in functies, ook in data (bomen, lijsten)
#13 Recursie niet alleen in functies, ook in data (bomen, lijsten)
#14 Recursie niet alleen in functies, ook in data (bomen, lijsten)
#15 Recursie niet alleen in functies, ook in data (bomen, lijsten)
#16 Recursie niet alleen in functies, ook in data (bomen, lijsten)
#17 Recursie niet alleen in functies, ook in data (bomen, lijsten)
#18 Recursie niet alleen in functies, ook in data (bomen, lijsten)
#19 Recursie niet alleen in functies, ook in data (bomen, lijsten)
#20 Recursie niet alleen in functies, ook in data (bomen, lijsten)
#21 Nieuwe paradigma’s hebben killer-app nodig
OO had GUIs, bij FP concurrency?
Typesysteem: niet noodzakelijk voor FP, traditioneel wel focus
#22 Zonder diep in te gaan, voor we features gaan bekijken, dit is hoe Scala FP bevat.
#24 *default modifier is public
*Type after identifier, type Unit == void
*zowel Scala->Java als Java->Scala interop. Dus, elkaars classes instantieren overerven etc.
*Abstract class ipv interfaces
#25 Extenden van Java class (extends ook voor interfaces)
Type Unit -> void in Java
hashCode -> hashCode() , haakjes weglaten.
Soort van autoboxing, maar beter
#26 * + is methode naam, kan je zelf op een class implementeren
* Leestekens legale identifiers in Scala
* Operator notatie ook te gebruiken met ‘normale’ methode namen
* In Java discussie: operator overloadig BigInts (en wat voor matrix etc.)? Scala: just do it.
#27 * + is methode naam, kan je zelf op een class implementeren
* Leestekens legale identifiers in Scala
* Operator notatie ook te gebruiken met ‘normale’ methode namen
* In Java discussie: operator overloadig BigInts (en wat voor matrix etc.)? Scala: just do it.
#28 * + is methode naam, kan je zelf op een class implementeren
* Leestekens legale identifiers in Scala
* Operator notatie ook te gebruiken met ‘normale’ methode namen
* In Java discussie: operator overloadig BigInts (en wat voor matrix etc.)? Scala: just do it.
#29 * + is methode naam, kan je zelf op een class implementeren
* Leestekens legale identifiers in Scala
* Operator notatie ook te gebruiken met ‘normale’ methode namen
* In Java discussie: operator overloadig BigInts (en wat voor matrix etc.)? Scala: just do it.
#30 * + is methode naam, kan je zelf op een class implementeren
* Leestekens legale identifiers in Scala
* Operator notatie ook te gebruiken met ‘normale’ methode namen
* In Java discussie: operator overloadig BigInts (en wat voor matrix etc.)? Scala: just do it.
#31 *Java statics niet echt OO. Scala: Classes->te instantieren, singleton objects->één instantie
*Zelfde naam: companions -> toegang tot private members
*haakjes mogen weg bij methode aanroep zonder params; puntkomma’s ook optioneel!
*main methode op object Main, entrypoint applicatie
#32 * Vorige slide goed opgelet: geen return type!
#40 * Zijn natuurlijk allemaal op ISKA over closures geweest, maar toch een opfrisser
* Java heeft Anon. classes -> beperkingen, verbose (interface nodig), daarom weinig gebruikt
#41 * Zijn natuurlijk allemaal op ISKA over closures geweest, maar toch een opfrisser
* Java heeft Anon. classes -> beperkingen, verbose (interface nodig), daarom weinig gebruikt
#42 * Zijn natuurlijk allemaal op ISKA over closures geweest, maar toch een opfrisser
* Java heeft Anon. classes -> beperkingen, verbose (interface nodig), daarom weinig gebruikt
#43 * Zijn natuurlijk allemaal op ISKA over closures geweest, maar toch een opfrisser
* Java heeft Anon. classes -> beperkingen, verbose (interface nodig), daarom weinig gebruikt
#44 * Function0 tot Function22 op deze manier beschikbaar
#45 * Function0 tot Function22 op deze manier beschikbaar
#46 * Function0 tot Function22 op deze manier beschikbaar
#47 * Function0 tot Function22 op deze manier beschikbaar
#48 * Function0 tot Function22 op deze manier beschikbaar
#49 * Function0 tot Function22 op deze manier beschikbaar
#50 * Function0 tot Function22 op deze manier beschikbaar
#51
Scala gaat nog verder, zelf control structures maken (by-name params)
#52 * First trait/class with extends, then 0 or more times with
* Traits can have any member: defs, abstract defs, fields traits can extend from each other
#53 * Traits are used in this fashion a lot for the Scala collection libs
#54 * abstract override: target of super not known at design-time!
* calls resolve right-to-left
* selftype annotation: type of this can assume type of class where trait is mixed in!
#55 * abstract override: target of super not known at design-time!
* calls resolve right-to-left
* selftype annotation: type of this can assume type of class where trait is mixed in!
#56 * abstract override: target of super not known at design-time!
* calls resolve right-to-left
* selftype annotation: type of this can assume type of class where trait is mixed in!
#57 * geen new keyword nodig: case class is class + companion object met apply method!
* Sealed abstract class: compiler kan checken of alle cases gedekt zijn
#58 * geen new keyword nodig: case class is class + companion object met apply method!
* Sealed abstract class: compiler kan checken of alle cases gedekt zijn
#59 * geen new keyword nodig: case class is class + companion object met apply method!
* Sealed abstract class: compiler kan checken of alle cases gedekt zijn
#60 * Twee doelen: selecteren goede case, en binden van variabelen in 1 stap
* Java kent heeeel beperkte pattern matching: catch-clauses
* Geen NPE: helaas heeft Scala wel null, vanwege compatibility -> tradeoff
* voorbeelden van option: Map.get, List.find, parseInt, etc.
#61 * Twee doelen: selecteren goede case, en binden van variabelen in 1 stap
* Java kent heeeel beperkte pattern matching: catch-clauses
* Geen NPE: helaas heeft Scala wel null, vanwege compatibility -> tradeoff
* voorbeelden van option: Map.get, List.find, parseInt, etc.