SlideShare uma empresa Scribd logo
1 de 27
Baixar para ler 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

Mais conteúdo relacionado

Mais de 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
 

Mais de 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
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
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
 

Último (20)

Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 

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