SlideShare una empresa de Scribd logo
1 de 40
Descargar para leer sin conexión
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

Más contenido relacionado

Similar a 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
 

Similar a 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
 

Último

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 

Último (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

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