Basic Wicket
                              and Scala



                                Daan van Etten
                   ...
Hi!


Wednesday, March 25, 2009
Goal:
         After this talk, you
          can start coding
          Wicket in Scala.
Wednesday, March 25, 2009
Overview


Wednesday, March 25, 2009
Scala
Wednesday, March 25, 2009
What is

                            Scala ?
Wednesday, March 25, 2009
Hello, World!


Wednesday, March 25, 2009
Functional
                             concepts

Wednesday, March 25, 2009
+
Wednesday, March 25, 2009
?
Wednesday, March 25, 2009
Simple project


Wednesday, March 25, 2009
maven

Wednesday, March 25, 2009
Java Scala

Wednesday, March 25, 2009
Wednesday, March 25, 2009
Who am I?


Wednesday, March 25, 2009
Wednesday, March 25, 2009
Daan van Etten




Wednesday, March 25, 2009
Daan van Etten




                                        gineer
                                  are En
               ...
Daan van Etten
                                            eer
                                        ngin
              ...
Daan van Etten
                                            er
                                   e Engine
                ...
Daan van Etten
                                            er
                                   e Engine
                ...
Daan van Etten
                                            er
                                   e Engine
                ...
Let’s begin


Wednesday, March 25, 2009
What is

                            Scala ?
Wednesday, March 25, 2009
Scala




Wednesday, March 25, 2009
Scala

                            History


Wednesday, March 25, 2009
Scala


                            1958
Wednesday, March 25, 2009
Scala

              Martin Odersky


Wednesday, March 25, 2009
Scala




Wednesday, March 25, 2009
Scala

                            Compilers


Wednesday, March 25, 2009
Scala

                            Functional
                            languages

Wednesday, March 25, 2009
Scala

                            Functional
                            languages
                            (more abou...
Scala




Wednesday, March 25, 2009
Scala

                            Generic
                             Java

Wednesday, March 25, 2009
Scala




Wednesday, March 25, 2009
Scala

                             Java 5
                            Generics

Wednesday, March 25, 2009
Scala

                            New javac


Wednesday, March 25, 2009
Scala


                            2001
Wednesday, March 25, 2009
Scala

                            Scala


Wednesday, March 25, 2009
Scala

                            First release


Wednesday, March 25, 2009
Scala


                            2003
Wednesday, March 25, 2009
Scala

            Object Oriented


Wednesday, March 25, 2009
Scala

                            Functional


Wednesday, March 25, 2009
Scala

                            Statically typed




Wednesday, March 25, 2009
Scala

                            Type inference




Wednesday, March 25, 2009
Scala

                            Type inference

                    var foo = 8



Wednesday, March 25, 2009
Scala

                            Type inference

                    var foo = 8
                    foo = “bar”

Wednes...
Scala

                            Type inference
                                    type mismatch;
                    v...
Scala

                  Every value is an object




Wednesday, March 25, 2009
Scala

                  Every value is an object

                            var foo = 8



Wednesday, March 25, 2009
Scala

                  Every value is an object

                         var foo = 8
                def bar(a: String)...
Scala

                            Every operation is a
                               method call



Wednesday, March 25,...
Scala

                            Every operation is a
                               method call

                      ...
Scala

                            Every operation is a
                               method call

                      ...
Scala

                     Compiles to
                    Java bytecode

Wednesday, March 25, 2009
Scala

                            Runs on the
                             Java VM

Wednesday, March 25, 2009
Scala

                            Scalable
              From small scripts to large systems


Wednesday, March 25, 2009
Scala

                            Hello, World!


Wednesday, March 25, 2009
Scala
         object HelloWorld {
           def main(args: Array[String]) {
             println(quot;Hello, world!quot;...
Scala


                            20 seconds

Wednesday, March 25, 2009
Scala




Wednesday, March 25, 2009
Scala




Wednesday, March 25, 2009
Scala




Wednesday, March 25, 2009
Scala




Wednesday, March 25, 2009
Scala

                            Functional
                             concepts

Wednesday, March 25, 2009
Scala




Wednesday, March 25, 2009
Scala
                            Design goals:

                            Embrace immutability
                        ...
Scala

                            Cleaner code




Wednesday, March 25, 2009
Scala

                               Cleaner code
                            More ne-grained reuse


Wednesday, March 25...
Scala

                            Cleaner code
                       More ne-grained reuse
                      No Iter...
Scala

                            Better optimizations




Wednesday, March 25, 2009
Scala

                            Better optimizations
                                 Multi-core!



Wednesday, March 2...
Scala

                            Better optimizations
                                 Multi-core!
                     ...
Scala

                            Better optimizations
                                 Multi-core!
                     ...
Scala

                             What about
                            the functions?



Wednesday, March 25, 2009
Scala

                            Every operation is a
                               method call



Wednesday, March 25,...
Scala

                            Every operation is a
                               method call

                      ...
Scala

                            Every operation is a
                               method call

                      ...
Scala
                            Function nesting




Wednesday, March 25, 2009
Scala
                            Function nesting
         def function1(x : Int) = {




Wednesday, March 25, 2009
Scala
                            Function nesting
         def function1(x : Int) = {
           def function2() = {




...
Scala
                            Function nesting
         def function1(x : Int) = {
           def function2() = {
    ...
Scala
                            Function nesting
         def function1(x : Int) = {
           def function2() = {
    ...
Scala
                            Function nesting
         def function1(x : Int) = {
           def function2() = {
    ...
Scala
                            Function nesting
         def function1(x : Int) = {
           def function2() = {
    ...
Scala
                            First-class functions




Wednesday, March 25, 2009
Scala
                            First-class functions
         def foo (cb: ()=>Unit): Unit = {




Wednesday, March 25,...
Scala
                            First-class functions
         def foo (cb: ()=>Unit): Unit = {
           while (true) ...
Scala
                            First-class functions
         def foo (cb: ()=>Unit): Unit = {
           while (true) ...
Scala
                            First-class functions
         def foo (cb: ()=>Unit): Unit = {
           while (true) ...
Scala
                            First-class functions
         def foo (cb: ()=>Unit): Unit = {
           while (true) ...
Scala
                            First-class functions
         def foo (cb: ()=>Unit): Unit = {
           while (true) ...
Scala
                     First-class functions in
                             libraries




Wednesday, March 25, 2009
Scala
                     First-class functions in
                             libraries
         val numbers = List(2,5...
Scala
                     First-class functions in
                             libraries
         val numbers = List(2,5...
Scala
                     First-class functions in
                             libraries
         val numbers = List(2,5...
Scala
                     First-class functions in
                             libraries
         val numbers = List(2,5...
Scala

                      Anonymous functions




Wednesday, March 25, 2009
Scala

                      Anonymous functions
         ((i:Int, j:Int) => i + j)(3, 4)




Wednesday, March 25, 2009
Scala

                      Anonymous functions
         ((i:Int, j:Int) => i + j)(3, 4)
         Java:
         int calc...
Scala

          Partially applied functions




Wednesday, March 25, 2009
Scala

          Partially applied functions
         def calc(x:Int, y:Int, z:Int)=x+y+z




Wednesday, March 25, 2009
Scala

          Partially applied functions
         def calc(x:Int, y:Int, z:Int)=x+y+z

         val calcPart = calc(1,...
Scala

          Partially applied functions
         def calc(x:Int, y:Int, z:Int)=x+y+z

         val calcPart = calc(1,...
+
Wednesday, March 25, 2009
+




Wednesday, March 25, 2009
+



                  Simple project


Wednesday, March 25, 2009
+



                            Hello, Wicket
                               World!
Wednesday, March 25, 2009
+
   object HelloWorld {
     def main(args: Array[String]) {
       println(quot;Hello, world!quot;)
     }
   }




Wedn...
+
   class HelloWorld extends WebApplication {
     def main(args: Array[String]) {
        println(quot;Hello, world!quot...
+
   class HelloWorld extends WebApplication {

   }




Wednesday, March 25, 2009
+
   class HelloWorld extends WebApplication {
     def getHomePage = classOf[HomePage]
   }




Wednesday, March 25, 2009
+
   class HelloWorld extends WebApplication {
     def getHomePage = classOf[HomePage]
   }
   class HomePage extends Web...
+
   class HelloWorld extends WebApplication {
     def getHomePage = classOf[HomePage]
   }
   class HomePage extends Web...
+
   class HelloWorld extends WebApplication {
     def getHomePage = classOf[HomePage]
   }
   class HomePage extends Web...
+
   class HelloWorld extends WebApplication {
     def getHomePage = classOf[HomePage]
   }
   class HomePage extends Web...
+
   class HelloWorld extends WebApplication {
     def getHomePage = classOf[HomePage]
   }
   class HomePage extends Web...
+
   class HelloWorld extends WebApplication {
     def getHomePage = classOf[HomePage]
   }
   class HomePage extends Web...
+
   class HelloWorld extends WebApplication {
     def getHomePage = classOf[HomePage]
   }
   class HomePage extends Web...
+
   class HelloWorld extends WebApplication {
     def getHomePage = classOf[HomePage]
   }
   class HomePage extends Web...
+
   class HelloWorld extends WebApplication {
     def getHomePage = classOf[HomePage]
   }
   class HomePage extends Web...
+
   <body>
    <p><b>Hello, Wicket World!</b></p>
    <form wicket:id=quot;formquot;>
     What's your name? <br/>
     <...
+




Wednesday, March 25, 2009
+




Wednesday, March 25, 2009
?
Wednesday, March 25, 2009
+




Wednesday, March 25, 2009
Wednesday, March 25, 2009
EASY
              REUSABLE
          NON-INTRUSIVE
                    SAFE
               EFFICIENT
               SCALA...
EASY


Wednesday, March 25, 2009
EASY
                            POJO-centric


Wednesday, March 25, 2009
EASY
                            POJO-centric


Wednesday, March 25, 2009
EASY
                            All code in Java


Wednesday, March 25, 2009
EASY
                            All code in Java
                                 or Scala

Wednesday, March 25, 2009
EASY
                        Maximum type safety and
                         compile-time problem
                       ...
EASY
                        Maximum type safety and
                         compile-time problem
                       ...
EASY
                            Minimum reliance on
                                special tools

Wednesday, March 25, 2...
EASY
                            Minimum reliance on
                                special tools

Wednesday, March 25, 2...
EASY


Wednesday, March 25, 2009
REUSABLE


Wednesday, March 25, 2009
REUSABLE
                             Function reuse


Wednesday, March 25, 2009
REUSABLE


Wednesday, March 25, 2009
NON-INTRUSIVE


Wednesday, March 25, 2009
NON-INTRUSIVE
                             HTML or other markup
                               not polluted with
         ...
NON-INTRUSIVE
                             HTML or other markup
                               not polluted with
         ...
NON-INTRUSIVE
                            But... Scala != Java


Wednesday, March 25, 2009
NON-INTRUSIVE
                            ?
Wednesday, March 25, 2009
SAFE


Wednesday, March 25, 2009
SAFE
                            Code is secure by default


Wednesday, March 25, 2009
SAFE
                            Code is secure by default


Wednesday, March 25, 2009
SAFE
                       All logic in Java (or Scala)
                       with maximum type safety

Wednesday, March...
SAFE
                       All logic in Java (or Scala)
                       with maximum type safety

Wednesday, March...
SAFE


Wednesday, March 25, 2009
EFFICIENT /
                            SCALABLE

Wednesday, March 25, 2009
EFFICIENT /
                             SCALABLE
                            Efficient and lightweight


Wednesday, March 2...
EFFICIENT /
                             SCALABLE
                            Efficient and lightweight


Wednesday, March 2...
EFFICIENT /
                            SCALABLE
                            Scala means reducing
                        ...
EFFICIENT /
                            SCALABLE
                            Scala means reducing
                        ...
EFFICIENT /
                            SCALABLE

Wednesday, March 25, 2009
Wednesday, March 25, 2009
EASY
              REUSABLE
          NON-INTRUSIVE
                    SAFE
               EFFICIENT
               SCALA...
Wednesday, March 25, 2009
Wednesday, March 25, 2009
maven

Wednesday, March 25, 2009
maven




Wednesday, March 25, 2009
maven

                        maven-scala-plugin



Wednesday, March 25, 2009
maven
   Under <build> <plugins>
   <plugin>
     <groupId>org.scala-tools</groupId>
     <artifactId>maven-scala-plugin</...
maven
   Under <pluginRepositories>

   <pluginRepository>
    <id>scala</id>
    <name>Scala Tools</name>
    <url>http:/...
maven
   Under <repositories>

   <repository>
    <id>scala</id>
    <name>Scala Tools</name>
    <url>http://scala-tools...
maven
   Under <dependencies>

   <dependency>
     <groupId>org.scala-lang</groupId>
     <artifactId>scala-library</arti...
maven

                            You can add this to any
                             Java+Maven project!



Wednesday, ...
maven

                            Project layout




Wednesday, March 25, 2009
maven
                            pom.xml
                            src
                                main
           ...
maven
                            pom.xml
                            src
                                main
           ...
maven
                            pom.xml
                            src
                                main
           ...
maven

                            Hello, Wicket World!
                              built in Maven



Wednesday, March 2...
maven




Wednesday, March 25, 2009
maven




Wednesday, March 25, 2009
Download the
                            demo project.




Wednesday, March 25, 2009
Java Scala

Wednesday, March 25, 2009
Java Scala




Wednesday, March 25, 2009
Java Scala


                               Java interface
                            implemented in Scala



Wednesday, ...
Java Scala

   public interface SomeInterface {
     void doSomething(String argument);
   }




Wednesday, March 25, 2009
Java Scala

   public interface SomeInterface {
     void doSomething(String argument);
   }

   class SomeImplementation ...
Java Scala

   public interface SomeInterface {

                                          ?
     void doSomething(String ...
Java Scala



            Scala does not have interfaces!




Wednesday, March 25, 2009
Java Scala



                            Scala has traits




Wednesday, March 25, 2009
Java Scala
                                extending a trait




   class SomeImplementation extends SomeInterface {
     ...
Java Scala



                            interface != trait



Wednesday, March 25, 2009
Java Scala


                             traits can have
                                 method
                        ...
Java Scala

   public interface SomeInterface {
     void doSomething(String argument);
   }

   trait SomeTrait {
     de...
Java Scala

   public interface SomeInterface {
     void doSomething(String argument);
   }

   trait SomeTrait {
     de...
Java Scala

   public interface SomeInterface {
     void doSomething(String argument);
   }

   class SomeImplementation ...
Java Scala

   public interface SomeInterface {
     void doSomething(String argument);
   }

   class SomeImplementation ...
Java Scala


   Error: class SomeImplementation needs to be abstract
   since method doSomething in trait SomeInterface of...
Java Scala


                       Java and Scala combined:
                         Circular dependencies



Wednesday, ...
Java Scala




Wednesday, March 25, 2009
Java Scala

   public interface SomeInterface {
     void doSomething(String argument);
   }




Wednesday, March 25, 2009
Java Scala

   public interface SomeInterface {
     void doSomething(String argument);
   }

   class SomeImplementation ...
Java Scala

   public interface SomeInterface {
     void doSomething(String argument);
   }

   class SomeImplementation ...
Java Scala


                      maven-scala-plugin



Wednesday, March 25, 2009
Java Scala


                      maven-scala-plugin

                            Handles circular
                      ...
Java Scala



                            How?



Wednesday, March 25, 2009
Java Scala




Wednesday, March 25, 2009
Java Scala

                               scalac
                            parses Java code
                           ...
Java Scala

   public interface SomeInterface {
     void doSomething(String argument);
   }

   class SomeImplementation ...
Wednesday, March 25, 2009
Wednesday, March 25, 2009
Wednesday, March 25, 2009
Scala home on the web.

                            Reference manuals, tutorials,
                                news, sp...
Interpreter, variables, methods, loops,
               arrays, lists, tuples, sets, maps, classes,
                      s...
Multiple articles covering a
                            feature by feature comparison
                                   ...
Series of 6 great articles
                              covering a lot of Scala.

                            Aimed at Ja...
Scala Wiki.

                   FAQ, code samples, design patterns,
                           Scala job openings

       ...
Official mailing lists

                            Subscribe: empty message to
                            scala-subscribe@...
All samples can be
                            downloaded at


                    http://stuq.nl

Wednesday, March 25, 20...
Get started with
             Scala and Wicket!

Wednesday, March 25, 2009
Thanks!


Wednesday, March 25, 2009
Upcoming SlideShare
Loading in...5
×

Basic Wicket and Scala

10,338

Published on

This presentation is about doing Scala with Wicket. The basics of Scala are handled with a simple Hello World application. After that I explain some functional concepts and show a basic Wicket application written in Scala.

Daan van Etten gave this presentation at the ApacheCon Wicket meetup in Amsterdam, March 24, 2009. You can find the mentioned source code at http://stuq.nl/weblog/2009-03-24/amsterdam-wicket-meetup-2009

Published in: Technology, News & Politics
2 Comments
37 Likes
Statistics
Notes
  • can i have a soft copy of this presentation ?
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Basic Wicket and Scala
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
10,338
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
2
Comments
2
Likes
37
Embeds 0
No embeds

No notes for slide




























  • http://www.artima.com/weblogs/viewpost.jsp?thread=163733
  • Lausanne


  • Pizza is an open-source superset of the Java programming language with the following new features:
    Generics
    Function pointers
    Class cases and pattern matching (a.k.a Algebraic types)




  • Started designing Scala in 2001
  • In 2001, the design for Scala started
  • Scala, whose design began in 2001, and which was first released in 2003. Scala is not an extension of Java, but it is completely interoperable with it. Scala translates to Java bytecodes, and the efficiency of its compiled programs usually equals Java's. A second implementation of Scala compiles to .NET. (this version is currently out of date, however).
    Scala was designed to be both object-oriented and functional. It is a pure object-oriented language in the sense that every value is an object. Objects are defined by classes, which can be composed using mixin composition. Scala is also a functional language in the sense that every function is a value. Functions can be nested, and they can operate on data using pattern matching.
  • 2003, first release of Scala
  • From the start, Scala is functional and object oriented, like Java
  • From the start, Scala is purely functional.
    functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data.

  • Like Java, unlike Groovy
  • This also works with functions
    def sayHello = System.out.println(\"hello world\")

  • This also works with functions
    def sayHello = System.out.println(\"hello world\")

  • This also works with functions
    def sayHello = System.out.println(\"hello world\")

  • This also works with functions
    def sayHello = System.out.println(\"hello world\")



  • The + is a method defined in class Int
  • The + is a method defined in class Int


  • The name Scala stands for &#x201C;scalable language.&#x201D; The language is so named because it was designed to grow with the demands of its users. You can apply Scala to a wide range of programming tasks, from writing small scripts to building large systems.






  • Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
  • Functional programming languages generally avoid state and try to have immutability






  • The + is a method defined in class Int
  • The + is a method defined in class Int
  • Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
  • Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
  • Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
  • Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
  • Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
  • Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
  • Higher order functions accept functions as parameters and return functions too.
  • Higher order functions accept functions as parameters and return functions too.
  • Higher order functions accept functions as parameters and return functions too.
  • Higher order functions accept functions as parameters and return functions too.
  • Higher order functions accept functions as parameters and return functions too.
  • Higher order functions accept functions as parameters and return functions too.
  • Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
  • Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
  • Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
  • Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
  • Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
  • Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
  • Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
  • Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
  • Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
















































































































  • Basic Wicket and Scala

    1. 1. Basic Wicket and Scala Daan van Etten http://stuq.nl Amsterdam, March 24, 2009 Wednesday, March 25, 2009
    2. 2. Hi! Wednesday, March 25, 2009
    3. 3. Goal: After this talk, you can start coding Wicket in Scala. Wednesday, March 25, 2009
    4. 4. Overview Wednesday, March 25, 2009
    5. 5. Scala Wednesday, March 25, 2009
    6. 6. What is Scala ? Wednesday, March 25, 2009
    7. 7. Hello, World! Wednesday, March 25, 2009
    8. 8. Functional concepts Wednesday, March 25, 2009
    9. 9. + Wednesday, March 25, 2009
    10. 10. ? Wednesday, March 25, 2009
    11. 11. Simple project Wednesday, March 25, 2009
    12. 12. maven Wednesday, March 25, 2009
    13. 13. Java Scala Wednesday, March 25, 2009
    14. 14. Wednesday, March 25, 2009
    15. 15. Who am I? Wednesday, March 25, 2009
    16. 16. Wednesday, March 25, 2009
    17. 17. Daan van Etten Wednesday, March 25, 2009
    18. 18. Daan van Etten gineer are En tw Sof Wednesday, March 25, 2009
    19. 19. Daan van Etten eer ngin ftware E So Wednesday, March 25, 2009
    20. 20. Daan van Etten er e Engine Softwar @work Wednesday, March 25, 2009
    21. 21. Daan van Etten er e Engine Softwar Wednesday, March 25, 2009
    22. 22. Daan van Etten er e Engine Softwar Wednesday, March 25, 2009
    23. 23. Let’s begin Wednesday, March 25, 2009
    24. 24. What is Scala ? Wednesday, March 25, 2009
    25. 25. Scala Wednesday, March 25, 2009
    26. 26. Scala History Wednesday, March 25, 2009
    27. 27. Scala 1958 Wednesday, March 25, 2009
    28. 28. Scala Martin Odersky Wednesday, March 25, 2009
    29. 29. Scala Wednesday, March 25, 2009
    30. 30. Scala Compilers Wednesday, March 25, 2009
    31. 31. Scala Functional languages Wednesday, March 25, 2009
    32. 32. Scala Functional languages (more about that later) Wednesday, March 25, 2009
    33. 33. Scala Wednesday, March 25, 2009
    34. 34. Scala Generic Java Wednesday, March 25, 2009
    35. 35. Scala Wednesday, March 25, 2009
    36. 36. Scala Java 5 Generics Wednesday, March 25, 2009
    37. 37. Scala New javac Wednesday, March 25, 2009
    38. 38. Scala 2001 Wednesday, March 25, 2009
    39. 39. Scala Scala Wednesday, March 25, 2009
    40. 40. Scala First release Wednesday, March 25, 2009
    41. 41. Scala 2003 Wednesday, March 25, 2009
    42. 42. Scala Object Oriented Wednesday, March 25, 2009
    43. 43. Scala Functional Wednesday, March 25, 2009
    44. 44. Scala Statically typed Wednesday, March 25, 2009
    45. 45. Scala Type inference Wednesday, March 25, 2009
    46. 46. Scala Type inference var foo = 8 Wednesday, March 25, 2009
    47. 47. Scala Type inference var foo = 8 foo = “bar” Wednesday, March 25, 2009
    48. 48. Scala Type inference type mismatch; var foo = 8 found: String(quot;barquot;) foo = “bar” required: Int Wednesday, March 25, 2009
    49. 49. Scala Every value is an object Wednesday, March 25, 2009
    50. 50. Scala Every value is an object var foo = 8 Wednesday, March 25, 2009
    51. 51. Scala Every value is an object var foo = 8 def bar(a: String)= println(a) Wednesday, March 25, 2009
    52. 52. Scala Every operation is a method call Wednesday, March 25, 2009
    53. 53. Scala Every operation is a method call 1+3-6 Wednesday, March 25, 2009
    54. 54. Scala Every operation is a method call 1+3-6 1.+(3).-(6) Wednesday, March 25, 2009
    55. 55. Scala Compiles to Java bytecode Wednesday, March 25, 2009
    56. 56. Scala Runs on the Java VM Wednesday, March 25, 2009
    57. 57. Scala Scalable From small scripts to large systems Wednesday, March 25, 2009
    58. 58. Scala Hello, World! Wednesday, March 25, 2009
    59. 59. Scala object HelloWorld { def main(args: Array[String]) { println(quot;Hello, world!quot;) } } Wednesday, March 25, 2009
    60. 60. Scala 20 seconds Wednesday, March 25, 2009
    61. 61. Scala Wednesday, March 25, 2009
    62. 62. Scala Wednesday, March 25, 2009
    63. 63. Scala Wednesday, March 25, 2009
    64. 64. Scala Wednesday, March 25, 2009
    65. 65. Scala Functional concepts Wednesday, March 25, 2009
    66. 66. Scala Wednesday, March 25, 2009
    67. 67. Scala Design goals: Embrace immutability Avoid state Wednesday, March 25, 2009
    68. 68. Scala Cleaner code Wednesday, March 25, 2009
    69. 69. Scala Cleaner code More ne-grained reuse Wednesday, March 25, 2009
    70. 70. Scala Cleaner code More ne-grained reuse No Iterator loops needed :-) Wednesday, March 25, 2009
    71. 71. Scala Better optimizations Wednesday, March 25, 2009
    72. 72. Scala Better optimizations Multi-core! Wednesday, March 25, 2009
    73. 73. Scala Better optimizations Multi-core! Lazy evaluation Wednesday, March 25, 2009
    74. 74. Scala Better optimizations Multi-core! Lazy evaluation Recursion Wednesday, March 25, 2009
    75. 75. Scala What about the functions? Wednesday, March 25, 2009
    76. 76. Scala Every operation is a method call Wednesday, March 25, 2009
    77. 77. Scala Every operation is a method call 1+3-6 Wednesday, March 25, 2009
    78. 78. Scala Every operation is a method call 1+3-6 1.+(3).-(6) Wednesday, March 25, 2009
    79. 79. Scala Function nesting Wednesday, March 25, 2009
    80. 80. Scala Function nesting def function1(x : Int) = { Wednesday, March 25, 2009
    81. 81. Scala Function nesting def function1(x : Int) = { def function2() = { Wednesday, March 25, 2009
    82. 82. Scala Function nesting def function1(x : Int) = { def function2() = { println(x) Wednesday, March 25, 2009
    83. 83. Scala Function nesting def function1(x : Int) = { def function2() = { println(x) } Wednesday, March 25, 2009
    84. 84. Scala Function nesting def function1(x : Int) = { def function2() = { println(x) } function2() Wednesday, March 25, 2009
    85. 85. Scala Function nesting def function1(x : Int) = { def function2() = { println(x) } function2() } Wednesday, March 25, 2009
    86. 86. Scala First-class functions Wednesday, March 25, 2009
    87. 87. Scala First-class functions def foo (cb: ()=>Unit): Unit = { Wednesday, March 25, 2009
    88. 88. Scala First-class functions def foo (cb: ()=>Unit): Unit = { while (true) { Wednesday, March 25, 2009
    89. 89. Scala First-class functions def foo (cb: ()=>Unit): Unit = { while (true) { cb(); Thread.sleep(1000); Wednesday, March 25, 2009
    90. 90. Scala First-class functions def foo (cb: ()=>Unit): Unit = { while (true) { cb(); Thread.sleep(1000); } Wednesday, March 25, 2009
    91. 91. Scala First-class functions def foo (cb: ()=>Unit): Unit = { while (true) { cb(); Thread.sleep(1000); } } Wednesday, March 25, 2009
    92. 92. Scala First-class functions def foo (cb: ()=>Unit): Unit = { while (true) { cb(); Thread.sleep(1000); } } foo(Unit : println(quot;hiquot;)) Wednesday, March 25, 2009
    93. 93. Scala First-class functions in libraries Wednesday, March 25, 2009
    94. 94. Scala First-class functions in libraries val numbers = List(2,5,8,9) Wednesday, March 25, 2009
    95. 95. Scala First-class functions in libraries val numbers = List(2,5,8,9) numbers.foreach( Wednesday, March 25, 2009
    96. 96. Scala First-class functions in libraries val numbers = List(2,5,8,9) numbers.foreach( (x: Int) => print(x) Wednesday, March 25, 2009
    97. 97. Scala First-class functions in libraries val numbers = List(2,5,8,9) numbers.foreach( (x: Int) => print(x) ) Wednesday, March 25, 2009
    98. 98. Scala Anonymous functions Wednesday, March 25, 2009
    99. 99. Scala Anonymous functions ((i:Int, j:Int) => i + j)(3, 4) Wednesday, March 25, 2009
    100. 100. Scala Anonymous functions ((i:Int, j:Int) => i + j)(3, 4) Java: int calc(int i, int j){ return i + j; }; calc(3, 4); Wednesday, March 25, 2009
    101. 101. Scala Partially applied functions Wednesday, March 25, 2009
    102. 102. Scala Partially applied functions def calc(x:Int, y:Int, z:Int)=x+y+z Wednesday, March 25, 2009
    103. 103. Scala Partially applied functions def calc(x:Int, y:Int, z:Int)=x+y+z val calcPart = calc(1, _:Int, 3) Wednesday, March 25, 2009
    104. 104. Scala Partially applied functions def calc(x:Int, y:Int, z:Int)=x+y+z val calcPart = calc(1, _:Int, 3) calcPart(4) Wednesday, March 25, 2009
    105. 105. + Wednesday, March 25, 2009
    106. 106. + Wednesday, March 25, 2009
    107. 107. + Simple project Wednesday, March 25, 2009
    108. 108. + Hello, Wicket World! Wednesday, March 25, 2009
    109. 109. + object HelloWorld { def main(args: Array[String]) { println(quot;Hello, world!quot;) } } Wednesday, March 25, 2009
    110. 110. + class HelloWorld extends WebApplication { def main(args: Array[String]) { println(quot;Hello, world!quot;) } } Wednesday, March 25, 2009
    111. 111. + class HelloWorld extends WebApplication { } Wednesday, March 25, 2009
    112. 112. + class HelloWorld extends WebApplication { def getHomePage = classOf[HomePage] } Wednesday, March 25, 2009
    113. 113. + class HelloWorld extends WebApplication { def getHomePage = classOf[HomePage] } class HomePage extends WebPage { } Wednesday, March 25, 2009
    114. 114. + class HelloWorld extends WebApplication { def getHomePage = classOf[HomePage] } class HomePage extends WebPage { } Wednesday, March 25, 2009
    115. 115. + class HelloWorld extends WebApplication { def getHomePage = classOf[HomePage] } class HomePage extends WebPage { var name = quot;quot; } Wednesday, March 25, 2009
    116. 116. + class HelloWorld extends WebApplication { def getHomePage = classOf[HomePage] } class HomePage extends WebPage { var name = quot;quot; val form = new Form(quot;formquot;) } Wednesday, March 25, 2009
    117. 117. + class HelloWorld extends WebApplication { def getHomePage = classOf[HomePage] } class HomePage extends WebPage { var name = quot;quot; val form = new Form(quot;formquot;) add(form) } Wednesday, March 25, 2009
    118. 118. + class HelloWorld extends WebApplication { def getHomePage = classOf[HomePage] } class HomePage extends WebPage { var name = quot;quot; val form = new Form(quot;formquot;) add(form) form.add(new TextField(quot;namequot;, } Wednesday, March 25, 2009
    119. 119. + class HelloWorld extends WebApplication { def getHomePage = classOf[HomePage] } class HomePage extends WebPage { var name = quot;quot; val form = new Form(quot;formquot;) add(form) form.add(new TextField(quot;namequot;, new PropertyModel(this, quot;namequot;))) } Wednesday, March 25, 2009
    120. 120. + class HelloWorld extends WebApplication { def getHomePage = classOf[HomePage] } class HomePage extends WebPage { var name = quot;quot; val form = new Form(quot;formquot;) add(form) form.add(new TextField(quot;namequot;, new PropertyModel(this, quot;namequot;))) form.add(new Label(quot;helloworldquot;, } Wednesday, March 25, 2009
    121. 121. + class HelloWorld extends WebApplication { def getHomePage = classOf[HomePage] } class HomePage extends WebPage { var name = quot;quot; val form = new Form(quot;formquot;) add(form) form.add(new TextField(quot;namequot;, new PropertyModel(this, quot;namequot;))) form.add(new Label(quot;helloworldquot;, new PropertyModel(this, quot;namequot;))) } Wednesday, March 25, 2009
    122. 122. + <body> <p><b>Hello, Wicket World!</b></p> <form wicket:id=quot;formquot;> What's your name? <br/> <input wicket:id=quot;namequot;/> <input type=quot;submitquot; value = quot;OKquot; /> <p>Your name is: <b><span wicket:id=quot;helloworldquot;/></b> </p> </form> </body> Wednesday, March 25, 2009
    123. 123. + Wednesday, March 25, 2009
    124. 124. + Wednesday, March 25, 2009
    125. 125. ? Wednesday, March 25, 2009
    126. 126. + Wednesday, March 25, 2009
    127. 127. Wednesday, March 25, 2009
    128. 128. EASY REUSABLE NON-INTRUSIVE SAFE EFFICIENT SCALABLE Wednesday, March 25, 2009
    129. 129. EASY Wednesday, March 25, 2009
    130. 130. EASY POJO-centric Wednesday, March 25, 2009
    131. 131. EASY POJO-centric Wednesday, March 25, 2009
    132. 132. EASY All code in Java Wednesday, March 25, 2009
    133. 133. EASY All code in Java or Scala Wednesday, March 25, 2009
    134. 134. EASY Maximum type safety and compile-time problem diagnosis Wednesday, March 25, 2009
    135. 135. EASY Maximum type safety and compile-time problem diagnosis Wednesday, March 25, 2009
    136. 136. EASY Minimum reliance on special tools Wednesday, March 25, 2009
    137. 137. EASY Minimum reliance on special tools Wednesday, March 25, 2009
    138. 138. EASY Wednesday, March 25, 2009
    139. 139. REUSABLE Wednesday, March 25, 2009
    140. 140. REUSABLE Function reuse Wednesday, March 25, 2009
    141. 141. REUSABLE Wednesday, March 25, 2009
    142. 142. NON-INTRUSIVE Wednesday, March 25, 2009
    143. 143. NON-INTRUSIVE HTML or other markup not polluted with programming semantics Wednesday, March 25, 2009
    144. 144. NON-INTRUSIVE HTML or other markup not polluted with programming semantics Wednesday, March 25, 2009
    145. 145. NON-INTRUSIVE But... Scala != Java Wednesday, March 25, 2009
    146. 146. NON-INTRUSIVE ? Wednesday, March 25, 2009
    147. 147. SAFE Wednesday, March 25, 2009
    148. 148. SAFE Code is secure by default Wednesday, March 25, 2009
    149. 149. SAFE Code is secure by default Wednesday, March 25, 2009
    150. 150. SAFE All logic in Java (or Scala) with maximum type safety Wednesday, March 25, 2009
    151. 151. SAFE All logic in Java (or Scala) with maximum type safety Wednesday, March 25, 2009
    152. 152. SAFE Wednesday, March 25, 2009
    153. 153. EFFICIENT / SCALABLE Wednesday, March 25, 2009
    154. 154. EFFICIENT / SCALABLE Efficient and lightweight Wednesday, March 25, 2009
    155. 155. EFFICIENT / SCALABLE Efficient and lightweight Wednesday, March 25, 2009
    156. 156. EFFICIENT / SCALABLE Scala means reducing the amount of code. Wednesday, March 25, 2009
    157. 157. EFFICIENT / SCALABLE Scala means reducing the amount of code. Wednesday, March 25, 2009
    158. 158. EFFICIENT / SCALABLE Wednesday, March 25, 2009
    159. 159. Wednesday, March 25, 2009
    160. 160. EASY REUSABLE NON-INTRUSIVE SAFE EFFICIENT SCALABLE Wednesday, March 25, 2009
    161. 161. Wednesday, March 25, 2009
    162. 162. Wednesday, March 25, 2009
    163. 163. maven Wednesday, March 25, 2009
    164. 164. maven Wednesday, March 25, 2009
    165. 165. maven maven-scala-plugin Wednesday, March 25, 2009
    166. 166. maven Under <build> <plugins> <plugin> <groupId>org.scala-tools</groupId> <artifactId>maven-scala-plugin</artifactId> <executions> <execution> <goals> <goal>compile</goal>         <goal>testCompile</goal>   </goals> </execution> </executions> Wednesday, March 25, 2009
    167. 167. maven Under <pluginRepositories> <pluginRepository> <id>scala</id> <name>Scala Tools</name> <url>http://scala-tools.org/repo-releases</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> Wednesday, March 25, 2009
    168. 168. maven Under <repositories> <repository> <id>scala</id> <name>Scala Tools</name> <url>http://scala-tools.org/repo-releases</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> Wednesday, March 25, 2009
    169. 169. maven Under <dependencies> <dependency> <groupId>org.scala-lang</groupId> <artifactId>scala-library</artifactId> <version>2.7.3</version> </dependency> Wednesday, March 25, 2009
    170. 170. maven You can add this to any Java+Maven project! Wednesday, March 25, 2009
    171. 171. maven Project layout Wednesday, March 25, 2009
    172. 172. maven pom.xml src main java test java Wednesday, March 25, 2009
    173. 173. maven pom.xml src main scala test scala Wednesday, March 25, 2009
    174. 174. maven pom.xml src main java scala test java scala Wednesday, March 25, 2009
    175. 175. maven Hello, Wicket World! built in Maven Wednesday, March 25, 2009
    176. 176. maven Wednesday, March 25, 2009
    177. 177. maven Wednesday, March 25, 2009
    178. 178. Download the demo project. Wednesday, March 25, 2009
    179. 179. Java Scala Wednesday, March 25, 2009
    180. 180. Java Scala Wednesday, March 25, 2009
    181. 181. Java Scala Java interface implemented in Scala Wednesday, March 25, 2009
    182. 182. Java Scala public interface SomeInterface { void doSomething(String argument); } Wednesday, March 25, 2009
    183. 183. Java Scala public interface SomeInterface { void doSomething(String argument); } class SomeImplementation extends SomeInterface { def doSomething(argument: String):Unit = { println(argument) } } Wednesday, March 25, 2009
    184. 184. Java Scala public interface SomeInterface { ? void doSomething(String argument); } class SomeImplementation extends SomeInterface { def doSomething(argument: String):unit = { println(argument) } } Wednesday, March 25, 2009
    185. 185. Java Scala Scala does not have interfaces! Wednesday, March 25, 2009
    186. 186. Java Scala Scala has traits Wednesday, March 25, 2009
    187. 187. Java Scala extending a trait class SomeImplementation extends SomeInterface { def doSomething(argument: String) : unit = { println(argument) } } Wednesday, March 25, 2009
    188. 188. Java Scala interface != trait Wednesday, March 25, 2009
    189. 189. Java Scala traits can have method implementations Wednesday, March 25, 2009
    190. 190. Java Scala public interface SomeInterface { void doSomething(String argument); } trait SomeTrait { def doSomething=(argument:String):Unit } Wednesday, March 25, 2009
    191. 191. Java Scala public interface SomeInterface { void doSomething(String argument); } trait SomeTrait { def doSomething(argument:String):Unit   def computeSomething = title.length * 10 } Wednesday, March 25, 2009
    192. 192. Java Scala public interface SomeInterface { void doSomething(String argument); } class SomeImplementation extends SomeInterface { def doSomething(argument: String):Unit = { println(argument) } } Wednesday, March 25, 2009
    193. 193. Java Scala public interface SomeInterface { void doSomething(String argument); } class SomeImplementation extends SomeInterface { } Wednesday, March 25, 2009
    194. 194. Java Scala Error: class SomeImplementation needs to be abstract since method doSomething in trait SomeInterface of type (java.lang.String)Unit is not defined. Wednesday, March 25, 2009
    195. 195. Java Scala Java and Scala combined: Circular dependencies Wednesday, March 25, 2009
    196. 196. Java Scala Wednesday, March 25, 2009
    197. 197. Java Scala public interface SomeInterface { void doSomething(String argument); } Wednesday, March 25, 2009
    198. 198. Java Scala public interface SomeInterface { void doSomething(String argument); } class SomeImplementation extends SomeInterface { def doSomething=(argument:String):Unit {...} } Wednesday, March 25, 2009
    199. 199. Java Scala public interface SomeInterface { void doSomething(String argument); } class SomeImplementation extends SomeInterface { def doSomething=(argument:String):Unit {...} } public class Other extends SomeImplementation { ... } Wednesday, March 25, 2009
    200. 200. Java Scala maven-scala-plugin Wednesday, March 25, 2009
    201. 201. Java Scala maven-scala-plugin Handles circular dependencies! Wednesday, March 25, 2009
    202. 202. Java Scala How? Wednesday, March 25, 2009
    203. 203. Java Scala Wednesday, March 25, 2009
    204. 204. Java Scala scalac parses Java code (since 2.7.2) Wednesday, March 25, 2009
    205. 205. Java Scala public interface SomeInterface { void doSomething(String argument); } class SomeImplementation extends SomeInterface { def doSomething=(argument:String):Unit {...} } public class Other extends SomeImplementation { ... } Wednesday, March 25, 2009
    206. 206. Wednesday, March 25, 2009
    207. 207. Wednesday, March 25, 2009
    208. 208. Wednesday, March 25, 2009
    209. 209. Scala home on the web. Reference manuals, tutorials, news, speci cations. http://www.scala-lang.org Wednesday, March 25, 2009
    210. 210. Interpreter, variables, methods, loops, arrays, lists, tuples, sets, maps, classes, singletons, traits, mixins. http://www.artima.com/scalazine/articles/steps.html Wednesday, March 25, 2009
    211. 211. Multiple articles covering a feature by feature comparison of Scala and Java http://blogs.sun.com/sundararajan/entry/scala_for_java_programmers Wednesday, March 25, 2009
    212. 212. Series of 6 great articles covering a lot of Scala. Aimed at Java developers. http://www.codecommit.com/blog/scala/roundup-scala-for-java-refugees Wednesday, March 25, 2009
    213. 213. Scala Wiki. FAQ, code samples, design patterns, Scala job openings http://scala.sygneca.com/ Wednesday, March 25, 2009
    214. 214. Official mailing lists Subscribe: empty message to scala-subscribe@listes.ep .ch http://www.scala-lang.org/node/199 Wednesday, March 25, 2009
    215. 215. All samples can be downloaded at http://stuq.nl Wednesday, March 25, 2009
    216. 216. Get started with Scala and Wicket! Wednesday, March 25, 2009
    217. 217. Thanks! Wednesday, March 25, 2009

    ×