SlideShare ist ein Scribd-Unternehmen logo
1 von 40
Downloaden Sie, um offline zu lesen
Experiences with
                Languages other than Java

                                         Kristian Domagala
                                    CITEC Technology Day
                                         10th October, 2008




Experiences with languages other than Java 1

© Workingmouse Pty Ltd 2008. All rights reserved
Background
          Technology
      ●


                Java/J2EE
            –

                Web client/server
            –

                WS*/XML/XSD
            –

          Processes
      ●


                Agile
            –

                TDD
            –




Experiences with languages other than Java 2

© Workingmouse Pty Ltd 2008. All rights reserved
What is Ruby?
          Dynamically typed
      ●


          Interpreted
      ●


          Object Oriented
      ●


          Supports common functional idioms
      ●


          Meta-programming
      ●


          Promotes testing to replace type safety
      ●




Experiences with languages other than Java 3

© Workingmouse Pty Ltd 2008. All rights reserved
Object Oriented
  class Person                 class Employee < Person
    attr_reader :name            def initialize(name,email,salary)
    def initialize(name,email)     super(name,email)
      @name = name                 @salary = salary
      @email = email             end
    end                          def increase_salary(pct)
    def email                      @salary *= pct
      @email                     end
    end                        end
  end

                 emp = Employee.new(quot;Fredquot;,quot;f@xyz.comquot;, 50000)
                 puts emp.name + quot;: quot; + emp.email
                 emp.increase_salary(1.05)



Experiences with languages other than Java 4

© Workingmouse Pty Ltd 2008. All rights reserved
Dynamic typing
            class Person                            class Business
              ...                                     ...
              def email                               def email
                @email                                  @email
              end                                     end
            end                                     end

                      def spam(obj)
                        send_spam_to(obj.email)
                      end
                      spam(person)
                      spam(business)

Experiences with languages other than Java 5

© Workingmouse Pty Ltd 2008. All rights reserved
Mixins (multiple inheritance)
                              module Payable
                                def pay(amount)
                                  account.deposit(amount)
                                end
                              end

      class Employee < Person                       class Business
        include Payable                               include Payable
        attr_reader :account                          attr_reader :account
        ...                                           ...
      end                                           end
                              employee.pay(1000)
                              business.pay(100)

Experiences with languages other than Java 6

© Workingmouse Pty Ltd 2008. All rights reserved
Meta-programming
          Redefine class/method behaviour at runtime
      ●


                method_missing
            –

                eval
            –




Experiences with languages other than Java 7

© Workingmouse Pty Ltd 2008. All rights reserved
RSpec
      describe quot;Sending spamquot; do
        it quot;should send to the person's email addressquot; do
          person_mock = mock(quot;personquot;)
          person_mock.should_receive(:email)
                .and_return(quot;fred@xyz.comquot;)
          spammer.should_receive(:send_spam_to)
                .with(quot;fred@xyz.comquot;)
                .and_return(true)

          spammer.spam(person_mock).should == true
        end
      end

Experiences with languages other than Java 8

© Workingmouse Pty Ltd 2008. All rights reserved
What is Rails?
          Web application framework featuring
      ●


                MVC
            –

                Active record
            –

                Template engine
            –

                Web server
            –

                Code generators
            –

          Extensible through plugins
      ●


          Open source since 2004
      ●




Experiences with languages other than Java 9

© Workingmouse Pty Ltd 2008. All rights reserved
Convention over Configuration
          Controllers
      ●


                public methods -> actions -> views
            –

          Model
      ●


                class-name -> table, attribute -> column
            –

                auto fields like id, created_at, version
            –

          Minimal configuration required
      ●


          Conventions can be overridden
      ●




Experiences with languages other than Java 10

© Workingmouse Pty Ltd 2008. All rights reserved
Rails projects at Workingmouse




Experiences with languages other than Java 11

© Workingmouse Pty Ltd 2008. All rights reserved
Rails projects at Workingmouse




Experiences with languages other than Java 12

© Workingmouse Pty Ltd 2008. All rights reserved
Experiences
          Code base not very discoverable
      ●


                Difficult to locate references and definitions
            –

                Unsure what effect code changes will have until
            –
                runtime




Experiences with languages other than Java 13

© Workingmouse Pty Ltd 2008. All rights reserved
Experiences
          Upgrades to framework/plug-ins risky
      ●


                Test coverage not always adequate
            –

          Introduction of plug-ins risky
      ●


                Can break assumptions on both sides
            –




Experiences with languages other than Java 14

© Workingmouse Pty Ltd 2008. All rights reserved
Experiences
          Things aren't always what they appear to be
      ●


                Item.tags
            –

                      Array of Tag?
                  ●


                      Array of tag names?
                  ●


                      Comma separated list of tag names?
                  ●




Experiences with languages other than Java 15

© Workingmouse Pty Ltd 2008. All rights reserved
Experiences
          Few “best practices” universally agreed on
      ●


                Rails is very accessible
            –

                Strong, sometimes highly opinionated, community
            –

                Plethora of tutorials/blogs
            –

                      difficult to sieve through
                  ●


                      not always good advice!
                  ●




Experiences with languages other than Java 16

© Workingmouse Pty Ltd 2008. All rights reserved
Common rebuttal
          Not enough tests!
      ●


                Where do you stop?
            –

                      TDD process doesn't catch all bugs
                  ●



                Maintaining tests
            –

                Language doesn't force tests
            –

                      Code coverage tools not always adequate
                  ●




Experiences with languages other than Java 17

© Workingmouse Pty Ltd 2008. All rights reserved
Experiences
          Still, able to get something up and running
      ●

          quickly




Experiences with languages other than Java 18

© Workingmouse Pty Ltd 2008. All rights reserved
IDE support
          Eclipse/IDEA
      ●


                syntax highlighting
            –

                some code-completion
            –

                some search capabilities
            –

                limited to ability due to dynamic language features
            –

          Interactive Ruby/Rails shells
      ●


                Read Evaluate Print Loop capability
            –




Experiences with languages other than Java 19

© Workingmouse Pty Ltd 2008. All rights reserved
Appropriateness
          Can be good for
      ●


                “green-fields” small project development
            –

                prototyping
            –

          Had issues with
      ●


                long running and non-trivial projects, especially
            –

                      maintenance
                  ●


                      unfamiliarity of code
                  ●




Experiences with languages other than Java 20

© Workingmouse Pty Ltd 2008. All rights reserved
Tips for starting
          Up front study & experimentation
      ●


                Books
            –

                      Agile Web Development with Rails (tutorial)
                  ●


                      The Rails Way (reference)
                  ●



          Communication
      ●


                Pairing/spending time with experienced people
            –

          Research
      ●


                Investigate basis of claims
            –

                Get both sides of the story
            –

Experiences with languages other than Java 21

© Workingmouse Pty Ltd 2008. All rights reserved
Questions?




Experiences with languages other than Java 22

© Workingmouse Pty Ltd 2008. All rights reserved
What is Scala?
          Statically typed
      ●


          Object Oriented
      ●


          Functional
      ●


          Compiles to JVM byte code (.class files)
      ●


          Open source
      ●


                First release in 2003
            –

                2.0 released in 2006
            –



Experiences with languages other than Java 23

© Workingmouse Pty Ltd 2008. All rights reserved
Relation to Java
          By design, Scala can do virtually everything that
      ●

          Java can do
                classes, methods, interfaces, statics
            –

                      no forced exception handling
                  ●



                call Java APIs
            –

          Even the (arguably) bad stuff
      ●


                nulls, down-casting, reflection
            –




Experiences with languages other than Java 24

© Workingmouse Pty Ltd 2008. All rights reserved
Example
        class Person(
            val firstName:String,
            val lastName:String,
            val birthYear:Int,
            private var height: Int) {

            val name = firstName + quot; quot; + lastName

            def age(year: Int) = birthYear + year
            def debug {
              println(name + birthYear + height)
            }
        }


Experiences with languages other than Java 25

© Workingmouse Pty Ltd 2008. All rights reserved
Language features
          Type inferencer
      ●


          First class functions and closures
      ●


          XML literals
      ●


          Type-safe tuples (allows multiple return values)
      ●


          Traits (allows multiple inheritance)
      ●




Experiences with languages other than Java 26

© Workingmouse Pty Ltd 2008. All rights reserved
XML literals
        val bookElt =
            <book title=quot;Scala for dummiesquot; year=quot;2008quot;>
              <author>Martin Odersky</author>
              <author>Tony Morris</author>
            </book>

        println(quot;Title: quot; + bookElt.attribute(quot;titlequot;))
        (bookElt  quot;authorquot;).foreach{a => println(a)}




Experiences with languages other than Java 27

© Workingmouse Pty Ltd 2008. All rights reserved
Type-safe tuples
      def nameAndYear(person:Person) =
        (person.name, person.birthYear)

      val ny = nameAndYear(person)
      val firstInitial = ny._1.charAt(0)
      val genX = (1968 until 1979).contains(ny._2)




Experiences with languages other than Java 28

© Workingmouse Pty Ltd 2008. All rights reserved
Multiple inheritance
                              trait Payable {
                                def account:Account
                                def pay(amount:Int) {
                                  account.deposit(amount)
                                }
                              }

    class Employee extends Person                     class Business
        with Payable {                                    extends Payable {
      def account = ...                                 def account = ...
    }                                                 }
                                 employee.pay(1000)
                                 business.pay(100)

Experiences with languages other than Java 29

© Workingmouse Pty Ltd 2008. All rights reserved
Type system
          Useful for detecting common bugs
      ●


                Simple things like NullPointerExceptions
            –

                Through to enforcing concurrency constraints
            –

          Constraints can be better implied with types
      ●


          Removes some of the need for defensive
      ●

          programming
                fail fast often done at the compiler
            –




Experiences with languages other than Java 30

© Workingmouse Pty Ltd 2008. All rights reserved
Scala projects at Workingmouse
          Scoodi Ads engine
      ●


          Scoodi online help webapp
      ●


          Slinky web application framework
      ●




Experiences with languages other than Java 31

© Workingmouse Pty Ltd 2008. All rights reserved
Experiences
          To get full benefit, need to change the way you
      ●

          think
          Functional programming concepts difficult to get
      ●

          a grasp of, but very powerful once understood




Experiences with languages other than Java 32

© Workingmouse Pty Ltd 2008. All rights reserved
Experiences
          Easy to trace code definitions and usage
      ●


                Type system helps find dead code and prevents
            –
                invalid changes and assumptions
          Sometimes difficult to get compiling
      ●


                but more often than not, once it compiled it was
            –
                correct




Experiences with languages other than Java 33

© Workingmouse Pty Ltd 2008. All rights reserved
Experiences
          Scala to Java integration is practical
      ●


                sometimes more type annotations and down-
            –
                casting required
          Java to Scala integration theoretically possible
      ●


                practical implications can make it infeasible
            –




Experiences with languages other than Java 34

© Workingmouse Pty Ltd 2008. All rights reserved
Java integration example
        import javax.servlet.http._

        class MyServlet extends HttpServlet {
          override def service(
              req: HttpServletRequest,
              resp: HttpServletResponse) {

                 val name = req.getParameter(quot;namequot;)
                 ...
             }
        }


Experiences with languages other than Java 35

© Workingmouse Pty Ltd 2008. All rights reserved
IDE support
          Eclipse/IDEA
      ●


                primitive support (syntax highlighting)
            –

                plug-ins actively developed (esp IDEA)
            –

                      buggy for our use
                  ●



          Interactive Scala shell
      ●


                REPL capability
            –

                Can also use for invoking Java libraries
            –




Experiences with languages other than Java 36

© Workingmouse Pty Ltd 2008. All rights reserved
Appropriateness
          Can be used anywhere that Java is used
      ●


          Added benefits
      ●


                better expressiveness with 1st class functions
            –

                safer code with type system and APIs that
            –
                encourage immutability
                better rate of code reuse with higher kinds
            –

                less verbosity with syntax and inferencer
            –




Experiences with languages other than Java 37

© Workingmouse Pty Ltd 2008. All rights reserved
Tips for starting
          Workingmouse Scala training course :-)
      ●


          Start by imitating Java
      ●


                Explicitly specifying types will help most compilation
            –
                issues
          Full benefit of functional aspects made easier
      ●

          by learning a pure functional language as well




Experiences with languages other than Java 38

© Workingmouse Pty Ltd 2008. All rights reserved
Questions?




Experiences with languages other than Java 39

© Workingmouse Pty Ltd 2008. All rights reserved
Thanks!



                               http://workingmouse.com
                               http://wiki.workingmouse.com




Experiences with languages other than Java 40

© Workingmouse Pty Ltd 2008. All rights reserved

Weitere ähnliche Inhalte

Ähnlich wie Rails Scala Citec Presentation

Groovy Testing Aug2009
Groovy Testing Aug2009Groovy Testing Aug2009
Groovy Testing Aug2009guest4a266c
 
Tales About Scala Performance
Tales About Scala PerformanceTales About Scala Performance
Tales About Scala PerformanceHaim Yadid
 
Language-Oriented Programming and Language Workbenches: Building Domain Langu...
Language-Oriented Programming and Language Workbenches: Building Domain Langu...Language-Oriented Programming and Language Workbenches: Building Domain Langu...
Language-Oriented Programming and Language Workbenches: Building Domain Langu...elliando dias
 
Javascript Framework Roundup FYB
Javascript Framework Roundup FYBJavascript Framework Roundup FYB
Javascript Framework Roundup FYBnukeevry1
 
Groovy Domain Specific Languages - SpringOne2GX 2012
Groovy Domain Specific Languages - SpringOne2GX 2012Groovy Domain Specific Languages - SpringOne2GX 2012
Groovy Domain Specific Languages - SpringOne2GX 2012Guillaume Laforge
 
Flex 3 Deep Dive
Flex 3 Deep DiveFlex 3 Deep Dive
Flex 3 Deep DiveEffective
 
[教材] 例外處理設計與重構實作班201309
[教材] 例外處理設計與重構實作班201309[教材] 例外處理設計與重構實作班201309
[教材] 例外處理設計與重構實作班201309teddysoft
 
BP203 limitless languages
BP203 limitless languagesBP203 limitless languages
BP203 limitless languagesMark Myers
 
Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007Guillaume Laforge
 
Domain Driven Design Javaday Roma2007
Domain Driven Design Javaday Roma2007Domain Driven Design Javaday Roma2007
Domain Driven Design Javaday Roma2007Antonio Terreno
 
201309 130917200320-phpapp01
201309 130917200320-phpapp01201309 130917200320-phpapp01
201309 130917200320-phpapp01Simon Lin
 
Quality Best Practices & Toolkit for Enterprise Flex
Quality Best Practices & Toolkit for Enterprise FlexQuality Best Practices & Toolkit for Enterprise Flex
Quality Best Practices & Toolkit for Enterprise FlexFrançois Le Droff
 
When To Use Ruby On Rails
When To Use Ruby On RailsWhen To Use Ruby On Rails
When To Use Ruby On Railsdosire
 
The Forces Driving Java
The Forces Driving JavaThe Forces Driving Java
The Forces Driving JavaSteve Elliott
 
Cr java concept by vikas jagtap
Cr java  concept by vikas jagtapCr java  concept by vikas jagtap
Cr java concept by vikas jagtapVikas Jagtap
 
JRuby - Enterprise 2.0
JRuby - Enterprise 2.0JRuby - Enterprise 2.0
JRuby - Enterprise 2.0Jan Sifra
 

Ähnlich wie Rails Scala Citec Presentation (20)

Groovy Testing Aug2009
Groovy Testing Aug2009Groovy Testing Aug2009
Groovy Testing Aug2009
 
Tales About Scala Performance
Tales About Scala PerformanceTales About Scala Performance
Tales About Scala Performance
 
Language-Oriented Programming and Language Workbenches: Building Domain Langu...
Language-Oriented Programming and Language Workbenches: Building Domain Langu...Language-Oriented Programming and Language Workbenches: Building Domain Langu...
Language-Oriented Programming and Language Workbenches: Building Domain Langu...
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 
Javascript Framework Roundup FYB
Javascript Framework Roundup FYBJavascript Framework Roundup FYB
Javascript Framework Roundup FYB
 
Groovy Domain Specific Languages - SpringOne2GX 2012
Groovy Domain Specific Languages - SpringOne2GX 2012Groovy Domain Specific Languages - SpringOne2GX 2012
Groovy Domain Specific Languages - SpringOne2GX 2012
 
Flex 3 Deep Dive
Flex 3 Deep DiveFlex 3 Deep Dive
Flex 3 Deep Dive
 
[教材] 例外處理設計與重構實作班201309
[教材] 例外處理設計與重構實作班201309[教材] 例外處理設計與重構實作班201309
[教材] 例外處理設計與重構實作班201309
 
Refactoring
RefactoringRefactoring
Refactoring
 
BP203 limitless languages
BP203 limitless languagesBP203 limitless languages
BP203 limitless languages
 
Ruby
RubyRuby
Ruby
 
Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007
 
Domain Driven Design Javaday Roma2007
Domain Driven Design Javaday Roma2007Domain Driven Design Javaday Roma2007
Domain Driven Design Javaday Roma2007
 
201309 130917200320-phpapp01
201309 130917200320-phpapp01201309 130917200320-phpapp01
201309 130917200320-phpapp01
 
Quality Best Practices & Toolkit for Enterprise Flex
Quality Best Practices & Toolkit for Enterprise FlexQuality Best Practices & Toolkit for Enterprise Flex
Quality Best Practices & Toolkit for Enterprise Flex
 
When To Use Ruby On Rails
When To Use Ruby On RailsWhen To Use Ruby On Rails
When To Use Ruby On Rails
 
The Forces Driving Java
The Forces Driving JavaThe Forces Driving Java
The Forces Driving Java
 
Cr java concept by vikas jagtap
Cr java  concept by vikas jagtapCr java  concept by vikas jagtap
Cr java concept by vikas jagtap
 
soa
soasoa
soa
 
JRuby - Enterprise 2.0
JRuby - Enterprise 2.0JRuby - Enterprise 2.0
JRuby - Enterprise 2.0
 

Kürzlich hochgeladen

Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 

Kürzlich hochgeladen (20)

Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 

Rails Scala Citec Presentation

  • 1. Experiences with Languages other than Java Kristian Domagala CITEC Technology Day 10th October, 2008 Experiences with languages other than Java 1 © Workingmouse Pty Ltd 2008. All rights reserved
  • 2. Background Technology ● Java/J2EE – Web client/server – WS*/XML/XSD – Processes ● Agile – TDD – Experiences with languages other than Java 2 © Workingmouse Pty Ltd 2008. All rights reserved
  • 3. What is Ruby? Dynamically typed ● Interpreted ● Object Oriented ● Supports common functional idioms ● Meta-programming ● Promotes testing to replace type safety ● Experiences with languages other than Java 3 © Workingmouse Pty Ltd 2008. All rights reserved
  • 4. Object Oriented class Person class Employee < Person attr_reader :name def initialize(name,email,salary) def initialize(name,email) super(name,email) @name = name @salary = salary @email = email end end def increase_salary(pct) def email @salary *= pct @email end end end end emp = Employee.new(quot;Fredquot;,quot;f@xyz.comquot;, 50000) puts emp.name + quot;: quot; + emp.email emp.increase_salary(1.05) Experiences with languages other than Java 4 © Workingmouse Pty Ltd 2008. All rights reserved
  • 5. Dynamic typing class Person class Business ... ... def email def email @email @email end end end end def spam(obj) send_spam_to(obj.email) end spam(person) spam(business) Experiences with languages other than Java 5 © Workingmouse Pty Ltd 2008. All rights reserved
  • 6. Mixins (multiple inheritance) module Payable def pay(amount) account.deposit(amount) end end class Employee < Person class Business include Payable include Payable attr_reader :account attr_reader :account ... ... end end employee.pay(1000) business.pay(100) Experiences with languages other than Java 6 © Workingmouse Pty Ltd 2008. All rights reserved
  • 7. Meta-programming Redefine class/method behaviour at runtime ● method_missing – eval – Experiences with languages other than Java 7 © Workingmouse Pty Ltd 2008. All rights reserved
  • 8. RSpec describe quot;Sending spamquot; do it quot;should send to the person's email addressquot; do person_mock = mock(quot;personquot;) person_mock.should_receive(:email) .and_return(quot;fred@xyz.comquot;) spammer.should_receive(:send_spam_to) .with(quot;fred@xyz.comquot;) .and_return(true) spammer.spam(person_mock).should == true end end Experiences with languages other than Java 8 © Workingmouse Pty Ltd 2008. All rights reserved
  • 9. What is Rails? Web application framework featuring ● MVC – Active record – Template engine – Web server – Code generators – Extensible through plugins ● Open source since 2004 ● Experiences with languages other than Java 9 © Workingmouse Pty Ltd 2008. All rights reserved
  • 10. Convention over Configuration Controllers ● public methods -> actions -> views – Model ● class-name -> table, attribute -> column – auto fields like id, created_at, version – Minimal configuration required ● Conventions can be overridden ● Experiences with languages other than Java 10 © Workingmouse Pty Ltd 2008. All rights reserved
  • 11. Rails projects at Workingmouse Experiences with languages other than Java 11 © Workingmouse Pty Ltd 2008. All rights reserved
  • 12. Rails projects at Workingmouse Experiences with languages other than Java 12 © Workingmouse Pty Ltd 2008. All rights reserved
  • 13. Experiences Code base not very discoverable ● Difficult to locate references and definitions – Unsure what effect code changes will have until – runtime Experiences with languages other than Java 13 © Workingmouse Pty Ltd 2008. All rights reserved
  • 14. Experiences Upgrades to framework/plug-ins risky ● Test coverage not always adequate – Introduction of plug-ins risky ● Can break assumptions on both sides – Experiences with languages other than Java 14 © Workingmouse Pty Ltd 2008. All rights reserved
  • 15. Experiences Things aren't always what they appear to be ● Item.tags – Array of Tag? ● Array of tag names? ● Comma separated list of tag names? ● Experiences with languages other than Java 15 © Workingmouse Pty Ltd 2008. All rights reserved
  • 16. Experiences Few “best practices” universally agreed on ● Rails is very accessible – Strong, sometimes highly opinionated, community – Plethora of tutorials/blogs – difficult to sieve through ● not always good advice! ● Experiences with languages other than Java 16 © Workingmouse Pty Ltd 2008. All rights reserved
  • 17. Common rebuttal Not enough tests! ● Where do you stop? – TDD process doesn't catch all bugs ● Maintaining tests – Language doesn't force tests – Code coverage tools not always adequate ● Experiences with languages other than Java 17 © Workingmouse Pty Ltd 2008. All rights reserved
  • 18. Experiences Still, able to get something up and running ● quickly Experiences with languages other than Java 18 © Workingmouse Pty Ltd 2008. All rights reserved
  • 19. IDE support Eclipse/IDEA ● syntax highlighting – some code-completion – some search capabilities – limited to ability due to dynamic language features – Interactive Ruby/Rails shells ● Read Evaluate Print Loop capability – Experiences with languages other than Java 19 © Workingmouse Pty Ltd 2008. All rights reserved
  • 20. Appropriateness Can be good for ● “green-fields” small project development – prototyping – Had issues with ● long running and non-trivial projects, especially – maintenance ● unfamiliarity of code ● Experiences with languages other than Java 20 © Workingmouse Pty Ltd 2008. All rights reserved
  • 21. Tips for starting Up front study & experimentation ● Books – Agile Web Development with Rails (tutorial) ● The Rails Way (reference) ● Communication ● Pairing/spending time with experienced people – Research ● Investigate basis of claims – Get both sides of the story – Experiences with languages other than Java 21 © Workingmouse Pty Ltd 2008. All rights reserved
  • 22. Questions? Experiences with languages other than Java 22 © Workingmouse Pty Ltd 2008. All rights reserved
  • 23. What is Scala? Statically typed ● Object Oriented ● Functional ● Compiles to JVM byte code (.class files) ● Open source ● First release in 2003 – 2.0 released in 2006 – Experiences with languages other than Java 23 © Workingmouse Pty Ltd 2008. All rights reserved
  • 24. Relation to Java By design, Scala can do virtually everything that ● Java can do classes, methods, interfaces, statics – no forced exception handling ● call Java APIs – Even the (arguably) bad stuff ● nulls, down-casting, reflection – Experiences with languages other than Java 24 © Workingmouse Pty Ltd 2008. All rights reserved
  • 25. Example class Person( val firstName:String, val lastName:String, val birthYear:Int, private var height: Int) { val name = firstName + quot; quot; + lastName def age(year: Int) = birthYear + year def debug { println(name + birthYear + height) } } Experiences with languages other than Java 25 © Workingmouse Pty Ltd 2008. All rights reserved
  • 26. Language features Type inferencer ● First class functions and closures ● XML literals ● Type-safe tuples (allows multiple return values) ● Traits (allows multiple inheritance) ● Experiences with languages other than Java 26 © Workingmouse Pty Ltd 2008. All rights reserved
  • 27. XML literals val bookElt = <book title=quot;Scala for dummiesquot; year=quot;2008quot;> <author>Martin Odersky</author> <author>Tony Morris</author> </book> println(quot;Title: quot; + bookElt.attribute(quot;titlequot;)) (bookElt quot;authorquot;).foreach{a => println(a)} Experiences with languages other than Java 27 © Workingmouse Pty Ltd 2008. All rights reserved
  • 28. Type-safe tuples def nameAndYear(person:Person) = (person.name, person.birthYear) val ny = nameAndYear(person) val firstInitial = ny._1.charAt(0) val genX = (1968 until 1979).contains(ny._2) Experiences with languages other than Java 28 © Workingmouse Pty Ltd 2008. All rights reserved
  • 29. Multiple inheritance trait Payable { def account:Account def pay(amount:Int) { account.deposit(amount) } } class Employee extends Person class Business with Payable { extends Payable { def account = ... def account = ... } } employee.pay(1000) business.pay(100) Experiences with languages other than Java 29 © Workingmouse Pty Ltd 2008. All rights reserved
  • 30. Type system Useful for detecting common bugs ● Simple things like NullPointerExceptions – Through to enforcing concurrency constraints – Constraints can be better implied with types ● Removes some of the need for defensive ● programming fail fast often done at the compiler – Experiences with languages other than Java 30 © Workingmouse Pty Ltd 2008. All rights reserved
  • 31. Scala projects at Workingmouse Scoodi Ads engine ● Scoodi online help webapp ● Slinky web application framework ● Experiences with languages other than Java 31 © Workingmouse Pty Ltd 2008. All rights reserved
  • 32. Experiences To get full benefit, need to change the way you ● think Functional programming concepts difficult to get ● a grasp of, but very powerful once understood Experiences with languages other than Java 32 © Workingmouse Pty Ltd 2008. All rights reserved
  • 33. Experiences Easy to trace code definitions and usage ● Type system helps find dead code and prevents – invalid changes and assumptions Sometimes difficult to get compiling ● but more often than not, once it compiled it was – correct Experiences with languages other than Java 33 © Workingmouse Pty Ltd 2008. All rights reserved
  • 34. Experiences Scala to Java integration is practical ● sometimes more type annotations and down- – casting required Java to Scala integration theoretically possible ● practical implications can make it infeasible – Experiences with languages other than Java 34 © Workingmouse Pty Ltd 2008. All rights reserved
  • 35. Java integration example import javax.servlet.http._ class MyServlet extends HttpServlet { override def service( req: HttpServletRequest, resp: HttpServletResponse) { val name = req.getParameter(quot;namequot;) ... } } Experiences with languages other than Java 35 © Workingmouse Pty Ltd 2008. All rights reserved
  • 36. IDE support Eclipse/IDEA ● primitive support (syntax highlighting) – plug-ins actively developed (esp IDEA) – buggy for our use ● Interactive Scala shell ● REPL capability – Can also use for invoking Java libraries – Experiences with languages other than Java 36 © Workingmouse Pty Ltd 2008. All rights reserved
  • 37. Appropriateness Can be used anywhere that Java is used ● Added benefits ● better expressiveness with 1st class functions – safer code with type system and APIs that – encourage immutability better rate of code reuse with higher kinds – less verbosity with syntax and inferencer – Experiences with languages other than Java 37 © Workingmouse Pty Ltd 2008. All rights reserved
  • 38. Tips for starting Workingmouse Scala training course :-) ● Start by imitating Java ● Explicitly specifying types will help most compilation – issues Full benefit of functional aspects made easier ● by learning a pure functional language as well Experiences with languages other than Java 38 © Workingmouse Pty Ltd 2008. All rights reserved
  • 39. Questions? Experiences with languages other than Java 39 © Workingmouse Pty Ltd 2008. All rights reserved
  • 40. Thanks! http://workingmouse.com http://wiki.workingmouse.com Experiences with languages other than Java 40 © Workingmouse Pty Ltd 2008. All rights reserved