SlideShare a Scribd company logo
1 of 27
Download to read offline
SPRECHEN SIE SCALA?
 Heiko Seeberger, WeigleWilczek
 rheinjug Düsseldorf, 18.03.2010
WARUM SCALA?
WARUM SCALA?


Which Programming Language would you use
 now on top of JVM, except Java? - Scala.
                                       James Gosling
WARUM SCALA?


Scala, it must be stated, is the current
  heir apparent to the Java throne.
                                           Charles Nutter
WARUM SCALA?


I can honestly say if someone had shown me ... Scala ...
 back in 2003 I'd probably have never created Groovy.
                                               James Strachan
obje
          eift                  kt-fu                                   pis iert
a   us ger                           nkti
                                            ona                tisc h ty
                                                l         sta



leich                                                                          ark
      tgew                                                                 sst
            icht
                 ig       WAS IST SCALA?                   au   sdr uck



knap                                                inte
                                                        rope
        p un
             d pr                       ati sch             rabe
                 äzis
                      e       p ragm                            l   mit
                                                                           Java
Seit 2003




                         Version 2.8


            AUSGEREIFT
OBJEKT-FUNKTIONAL
Any



       AnyVal                                         AnyRef



Int                Unit                 ScalaObject



Long            scala.* val             scala.* ref            java.* ref



                                                      Null



                              Nothing




        ALLES IST EIN OBJEKT
Keine Seiteneffekte


         1, 2, 3         f        a, b, c




                      Funktionen höherer Ordnung


    FUNKTIONALE PROGRAMMIERUNG
STATISCH TYPISIERT
Semicolon Inference           Type Inference




Infix Operator Notation   Implicit Conversions


             LEICHTGEWICHTIG
AUSDRUCKSSTARK

"Calling Person.toString" when {
  "first and last name are not-empty" should {
    "return first name blank last name" in {
      val person = new Person("John", "Doe")
      person.toString should be ("John Doe")
    }
  }
}
KNAPP UND PRÄZISE
public class Person {                          // Java

    private final String firstName;
    private final String lastName;

    public class Person(val firstName: String,
           Person(String firstName, String lastName) {
                        val lastName: String)
      this.firstName = firstName;
      this.lastName = lastName;
    }

    public String getFirstName() {
      return firstName;
    }

    public String getLastName() {
      return lastName;
    }
}
PRAGMATISCH
INTEROPERABEL MIT JAVA

scala> import org.apache.log4j._
import org.apache.log4j._

scala> val testLogger = Logger getLogger "test"
testLogger: org.apache.log4j.Logger = ...




                  Wichtig!
LIVE DEMO: HELLO WORLD
Klas
                         sen-
  as sen                     Para                         thoden
Kl                                m   eter            M  e




           LIVE DEMO: OO-GRUNDLAGEN

Defa                                         Com
     ult-Ar                                     pan
           gum              Fe lder                ion
                                                          Obje
              ente                                            cts
rkz eug
        st- We
      Te




LIVE DEMO: SCALATEST

      DSL
         -Bei
                 spie
                     l
Für
             Libr
                 ary-E
                      ntw
                         icklu
                              ng




LIVE DEMO: IMPLICIT CONVERSIONS

                         pra che
                  rbare S
           Skalie
Unv
Type                                      erän
       Infe                ato ren        Obje
                                               derl
                                                    iche
           renc
                e     O per                    kte




         LIVE DEMO: FUNKTIONALE LISTE

            nen g   Funk
        ktio nun
   Fun Ord
                        tion
                            slite                    tio nen
       rer                       rale         Funk
 h öhe
Meh
   rfac
       hver
           erbu
               ng r
                      icht
                             ig ge
                                  mac
                                     ht



 LIVE DEMO: TRAITS

                               ns
                        c atio
                  M odifi
         ackabe
      St
Upp                                          ma cht   Low
    er B                               i g ge             er Bo
         ound                     i cht                        und
               s       eri cs r                                    s
                    Gen



              LIVE DEMO: TYP-PARAMETER

      i anz
                          Kov
                             aria                             ari anz
In var                            nz                      trav
                                                      Kon
Swit
                tern          ch   rich                                    tern
             Pat                       tig g                           Pat
    d card                                     ema           nst ant
Wil                                                c ht    Co




         LIVE DEMO: PATTERN MATCHING

Vari                                                ern   Seq
     able                                       att           u ence
            Patt                          t or P                       Patt
                e   rn         st ruc                                       ern
                           Con
pra che
                    er S
                in d
     L ite rale




LIVE DEMO: XML-SUPPORT

        XPa
             th-A
                  bfra
                       gen
FRAGEN / DISKUSSION
DANKE


seeberger@weiglewilczek.com

     XING Scala-Gruppe

More Related Content

More from Heiko Seeberger

Eclipse Magazin 12 - Design by Contract
Eclipse Magazin 12 - Design by ContractEclipse Magazin 12 - Design by Contract
Eclipse Magazin 12 - Design by Contract
Heiko Seeberger
 
Eclipse Magazin 16 - Die Stärke der Drei
Eclipse Magazin 16 - Die Stärke der DreiEclipse Magazin 16 - Die Stärke der Drei
Eclipse Magazin 16 - Die Stärke der Drei
Heiko Seeberger
 
Eclipse Magazin15 - Performance Logging
Eclipse Magazin15 - Performance LoggingEclipse Magazin15 - Performance Logging
Eclipse Magazin15 - Performance Logging
Heiko Seeberger
 
Eclipse Magazin 14 - Getting hooked on Equinox
Eclipse Magazin 14 - Getting hooked on EquinoxEclipse Magazin 14 - Getting hooked on Equinox
Eclipse Magazin 14 - Getting hooked on Equinox
Heiko Seeberger
 
Eclipse Magazin 12 - Security does matter
Eclipse Magazin 12 - Security does matterEclipse Magazin 12 - Security does matter
Eclipse Magazin 12 - Security does matter
Heiko Seeberger
 
EclipseCon 08 - Agile RCP
EclipseCon 08 - Agile RCPEclipseCon 08 - Agile RCP
EclipseCon 08 - Agile RCP
Heiko Seeberger
 
W-JAX 07 - AOP im Einsatz mit OSGi und RCP
W-JAX 07 - AOP im Einsatz mit OSGi und RCPW-JAX 07 - AOP im Einsatz mit OSGi und RCP
W-JAX 07 - AOP im Einsatz mit OSGi und RCP
Heiko Seeberger
 

More from Heiko Seeberger (20)

Java Magazin - Lift
Java Magazin - LiftJava Magazin - Lift
Java Magazin - Lift
 
JavaSPEKTRUM - Scala 3
JavaSPEKTRUM - Scala 3JavaSPEKTRUM - Scala 3
JavaSPEKTRUM - Scala 3
 
JavaSPEKTRUM - Scala 2
JavaSPEKTRUM - Scala 2JavaSPEKTRUM - Scala 2
JavaSPEKTRUM - Scala 2
 
JavaSPEKTRUM - Scala 1
JavaSPEKTRUM - Scala 1JavaSPEKTRUM - Scala 1
JavaSPEKTRUM - Scala 1
 
W-JAX 09 - ScalaModules
W-JAX 09 - ScalaModulesW-JAX 09 - ScalaModules
W-JAX 09 - ScalaModules
 
W-JAX 09 - Lift
W-JAX 09 - LiftW-JAX 09 - Lift
W-JAX 09 - Lift
 
JM 08/09 - Beginning Scala Review
JM 08/09 - Beginning Scala ReviewJM 08/09 - Beginning Scala Review
JM 08/09 - Beginning Scala Review
 
JM 08/09 - ScalaModules
JM 08/09 - ScalaModulesJM 08/09 - ScalaModules
JM 08/09 - ScalaModules
 
OSGi DevCon Europe 09 - OSGi on Scala
OSGi DevCon Europe 09 - OSGi on ScalaOSGi DevCon Europe 09 - OSGi on Scala
OSGi DevCon Europe 09 - OSGi on Scala
 
JAX 09 - OSGi on Scala
JAX 09 - OSGi on ScalaJAX 09 - OSGi on Scala
JAX 09 - OSGi on Scala
 
JAX 09 - OSGi Service Components Models
JAX 09 - OSGi Service Components ModelsJAX 09 - OSGi Service Components Models
JAX 09 - OSGi Service Components Models
 
JAX 08 - Agile RCP
JAX 08 - Agile RCPJAX 08 - Agile RCP
JAX 08 - Agile RCP
 
Eclipse Magazin 12 - Design by Contract
Eclipse Magazin 12 - Design by ContractEclipse Magazin 12 - Design by Contract
Eclipse Magazin 12 - Design by Contract
 
JUGM 07 - AspectJ
JUGM 07 - AspectJJUGM 07 - AspectJ
JUGM 07 - AspectJ
 
Eclipse Magazin 16 - Die Stärke der Drei
Eclipse Magazin 16 - Die Stärke der DreiEclipse Magazin 16 - Die Stärke der Drei
Eclipse Magazin 16 - Die Stärke der Drei
 
Eclipse Magazin15 - Performance Logging
Eclipse Magazin15 - Performance LoggingEclipse Magazin15 - Performance Logging
Eclipse Magazin15 - Performance Logging
 
Eclipse Magazin 14 - Getting hooked on Equinox
Eclipse Magazin 14 - Getting hooked on EquinoxEclipse Magazin 14 - Getting hooked on Equinox
Eclipse Magazin 14 - Getting hooked on Equinox
 
Eclipse Magazin 12 - Security does matter
Eclipse Magazin 12 - Security does matterEclipse Magazin 12 - Security does matter
Eclipse Magazin 12 - Security does matter
 
EclipseCon 08 - Agile RCP
EclipseCon 08 - Agile RCPEclipseCon 08 - Agile RCP
EclipseCon 08 - Agile RCP
 
W-JAX 07 - AOP im Einsatz mit OSGi und RCP
W-JAX 07 - AOP im Einsatz mit OSGi und RCPW-JAX 07 - AOP im Einsatz mit OSGi und RCP
W-JAX 07 - AOP im Einsatz mit OSGi und RCP
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

RheinJUG 2010 - Sprechen Sie Scala?

  • 1. SPRECHEN SIE SCALA? Heiko Seeberger, WeigleWilczek rheinjug Düsseldorf, 18.03.2010
  • 3. WARUM SCALA? Which Programming Language would you use now on top of JVM, except Java? - Scala. James Gosling
  • 4. WARUM SCALA? Scala, it must be stated, is the current heir apparent to the Java throne. Charles Nutter
  • 5. WARUM SCALA? I can honestly say if someone had shown me ... Scala ... back in 2003 I'd probably have never created Groovy. James Strachan
  • 6. obje eift kt-fu pis iert a us ger nkti ona tisc h ty l sta leich ark tgew sst icht ig WAS IST SCALA? au sdr uck knap inte rope p un d pr ati sch rabe äzis e p ragm l mit Java
  • 7. Seit 2003 Version 2.8 AUSGEREIFT
  • 9. Any AnyVal AnyRef Int Unit ScalaObject Long scala.* val scala.* ref java.* ref Null Nothing ALLES IST EIN OBJEKT
  • 10. Keine Seiteneffekte 1, 2, 3 f a, b, c Funktionen höherer Ordnung FUNKTIONALE PROGRAMMIERUNG
  • 12. Semicolon Inference Type Inference Infix Operator Notation Implicit Conversions LEICHTGEWICHTIG
  • 13. AUSDRUCKSSTARK "Calling Person.toString" when { "first and last name are not-empty" should { "return first name blank last name" in { val person = new Person("John", "Doe") person.toString should be ("John Doe") } } }
  • 14. KNAPP UND PRÄZISE public class Person { // Java private final String firstName; private final String lastName; public class Person(val firstName: String, Person(String firstName, String lastName) { val lastName: String) this.firstName = firstName; this.lastName = lastName; } public String getFirstName() { return firstName; } public String getLastName() { return lastName; } }
  • 16. INTEROPERABEL MIT JAVA scala> import org.apache.log4j._ import org.apache.log4j._ scala> val testLogger = Logger getLogger "test" testLogger: org.apache.log4j.Logger = ... Wichtig!
  • 18. Klas sen- as sen Para thoden Kl m eter M e LIVE DEMO: OO-GRUNDLAGEN Defa Com ult-Ar pan gum Fe lder ion Obje ente cts
  • 19. rkz eug st- We Te LIVE DEMO: SCALATEST DSL -Bei spie l
  • 20. Für Libr ary-E ntw icklu ng LIVE DEMO: IMPLICIT CONVERSIONS pra che rbare S Skalie
  • 21. Unv Type erän Infe ato ren Obje derl iche renc e O per kte LIVE DEMO: FUNKTIONALE LISTE nen g Funk ktio nun Fun Ord tion slite tio nen rer rale Funk h öhe
  • 22. Meh rfac hver erbu ng r icht ig ge mac ht LIVE DEMO: TRAITS ns c atio M odifi ackabe St
  • 23. Upp ma cht Low er B i g ge er Bo ound i cht und s eri cs r s Gen LIVE DEMO: TYP-PARAMETER i anz Kov aria ari anz In var nz trav Kon
  • 24. Swit tern ch rich tern Pat tig g Pat d card ema nst ant Wil c ht Co LIVE DEMO: PATTERN MATCHING Vari ern Seq able att u ence Patt t or P Patt e rn st ruc ern Con
  • 25. pra che er S in d L ite rale LIVE DEMO: XML-SUPPORT XPa th-A bfra gen