SlideShare uma empresa Scribd logo
1 de 44
Baixar para ler offline
Do More with Less:
          Building Android Apps with Scala
          Tony Hillerson • Tack Mobile
          AnDevCon III
          @thillerson @tackmobile




PRESENTATION                             ANDEVCON • MAY 14, 2012
ABOUT ME




Tony Hillerson
Software Architect & Partner   Mobile design and development
                               company based in Denver, CO.
•   O’Reilly Screencasts
•   Computer Nerd              @tackmobile
•   Co-creator of FieldTest    tackmobile.com


@thillerson
tony@tackmobile.com




PRESENTATION                                                   tackmobile.com
Why Would I Consider Scala?
    •   Write less boilerplate code
    •   More powerful features than Java
    •   Move towards Functional paradigms




PRESENTATION                                tackmobile.com
N.B. I Am Not a Scala Expert
    •   You can probably stump me
    •   This talk is about how you can explore what
        Scala might do for you




PRESENTATION                                     tackmobile.com
My Goals
    •   Introduce you to Scala
    •   Introduce you to Scala with Android
    •   Give you a few good reasons to use Scala
    •   Encourage you to become a Polyglot




PRESENTATION                                       tackmobile.com
Be a Polyglot



PRESENTATION                   tackmobile.com
“              Learn one new
               language per year
               - The Pragmatic Programmers



PRESENTATION                                 tackmobile.com
Seven
Languages in
Seven Weeks
http://pragprog.com/book/
btlang/seven-languages-in-
        seven-weeks




PRESENTATION                 tackmobile.com
What is Scala?



PRESENTATION                    ANDEVCON • MAY 14, 2012
What is Scala?
    •   JVM Language
    •   Take advantage of any Java library
    •   Bridges the divide between OO and
        Functional spaces




PRESENTATION                                 tackmobile.com
scala-lang.org




PRESENTATION      tackmobile.com
REPL
    •   Read Execute Print Loop
    •   Command line: scala
    •   Test code quickly




PRESENTATION                      tackmobile.com
Strongly, Statically Typed
    •   Compile time type checking
    •   Restrictions on how types can be used
        together
    •   For comparison:
         •     Javascript - Weakly typed, Dynamic
         •     Ruby - Strongly typed, Dynamic




PRESENTATION                                        tackmobile.com
≠ Boilerplate
 •   Perens are (sometimes) optional
 •   Semicolons are (mostly) optional
 •   Types are inferred, thus:
     ArrayList<GameTileMotionDescriptor> descriptors = new
     ArrayList<GameTileMotionDescriptor>();

     VS.
     val descriptors = new ArrayBuffer[GameTileMotionDescriptor]




PRESENTATION                                                       tackmobile.com
More OO than Java
    •   Everything is an object
    •   Operators are actually methods
    •   For instance, override the “+” method




PRESENTATION                                    tackmobile.com
Functional Language
    •   Functions are first class citizens
    •   High order functions: Functions that
        operate on functions
    •   Avoids mutable state
    •   Could get pretty academic
    •   Scala bridges the gap between OO and
        Functional



PRESENTATION                                   tackmobile.com
A Javascript Function

var doSomething = function(data) {
  doSomethingElseWithData(data);
}




PRESENTATION                     tackmobile.com
A Scala Function
def doSomething(data:A):B = {
  doSomethingElseWithData(data)
}




PRESENTATION                      tackmobile.com
Concurrent
    •   Optional immutable state
    •   Actors - Higher concept than Threads/
        Thread Pools




PRESENTATION                                    tackmobile.com
Example Conversion
               Project



PRESENTATION                   ANDEVCON • MAY 14, 2012
Slider Puzzle




PRESENTATION     tackmobile.com
Experiment: Convert from Java to Scala
    •   Android
         • https://github.com/thillerson/Android-Slider-Puzzle

    •   Scala
         • https://github.com/thillerson/scala-android-slider-puzzle



    • Mixed results.

    • I have a lot to learn about Scala




PRESENTATION                                                           tackmobile.com
Mike Burns
    •   Thoughtbot
    •   Android and Scala at Android Open
    •   http://robots.thoughtbot.com/post/
        5836463058/scala-a-better-java-for-android
    •   Ohlaunch - https://github.com/mike-burns/
        ohlaunch




PRESENTATION                                    tackmobile.com
Scala with Android



PRESENTATION                        ANDEVCON • MAY 14, 2012
SBT
    •   Build tool (use for Java too)
    •   https://github.com/harrah/xsbt/wiki/
        Getting-Started-Welcome




PRESENTATION                                   tackmobile.com
android-plugin
    •   https://github.com/jberkel/android-plugin/
        wiki/getting-started
    •   ADB/DDMS Integration
    •   Build and Release




PRESENTATION                                    tackmobile.com
But I Need My Eclipse!


    •   http://www.assembla.com/wiki/show/scala-
        ide/Developing_for_Android




PRESENTATION                                  tackmobile.com
Scala’s Features
               and Idioms



PRESENTATION                      ANDEVCON • MAY 14, 2012
vals and vars
    •   var - A variable definition. Required to be
        initialized when in a function
    •   val - A value definition. Once set, cannot be
        changed
         •     Basically a “final”
    •   Important consideration for concurrent
        programming



PRESENTATION                                          tackmobile.com
Methods
    •   Declaration conventions
    •   Suffix notation
    •   Infix notation




PRESENTATION                      tackmobile.com
Looping
    •   for ( item <- items )
    •   ranges




PRESENTATION                    tackmobile.com
Scala Collections
    •   Scala really shines on collections
    •   A good introduction to functional power




PRESENTATION                                      tackmobile.com
Anonymous Function Syntax
    •   ( args ) => ReturnType
    •   ( x:Int ) => x * x




PRESENTATION                     tackmobile.com
Inheritance in Java
    •   Single Inheritance
    •   Restricting!




PRESENTATION                 tackmobile.com
Inheritance in C++
    •   Multiple Inheritance
    •   Mind Blown




PRESENTATION                   tackmobile.com
Traits
    •   Mixin pattern
    •   Abstract/Interface + implementation




PRESENTATION                                  tackmobile.com
Extending the Language
           class UnlessClass[T](block: => T) {
             def unless(b: Boolean): Unit = {
               if (!b) block
             }
           }

           implicit def
           toUnlessClass[T](block: => T): UnlessClass[T] = {
             new UnlessClass[T](block)
           }



                                             ...
                           foo unless flag

               http://naturalsoftware.blogspot.com/2009/05/ruby-unless-scala.html
PRESENTATION                                                                        tackmobile.com
Resources



PRESENTATION               ANDEVCON • MAY 14, 2012
Books on Scala
    •   http://www.scala-lang.org/node/959




PRESENTATION                                 tackmobile.com
Positronic
    •   Framework for Android in Scala
    •   Makes use of Actors
    •   http://rst.github.com/tutorial.html




PRESENTATION                                  tackmobile.com
Assembla


    •   http://www.assembla.com/wiki/show/scala-
        ide/Developing_for_Android




PRESENTATION                                  tackmobile.com
Seven
Languages in
Seven Weeks
http://pragprog.com/book/
btlang/seven-languages-in-
        seven-weeks




PRESENTATION                 tackmobile.com
Recap
    •   Scala is perfect for Android
    •   Consider expanding your mind
    •   Be a Polyglot




PRESENTATION                           tackmobile.com
Thank You
          @thillerson @tackmobile




PRESENTATION                        ANDEVCON • MAY 14, 2012

Mais conteúdo relacionado

Mais procurados

Introduction to Scala for Java Developers
Introduction to Scala for Java DevelopersIntroduction to Scala for Java Developers
Introduction to Scala for Java DevelopersSolix JJ
 
Case class scala
Case class scalaCase class scala
Case class scalaMatt Hicks
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to ScalaJohan Andrén
 
Funtional Ruby - Mikhail Bortnyk
Funtional Ruby - Mikhail BortnykFuntional Ruby - Mikhail Bortnyk
Funtional Ruby - Mikhail BortnykRuby Meditation
 
Better Framework Better Life
Better Framework Better LifeBetter Framework Better Life
Better Framework Better Lifejeffz
 
Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010ssoroka
 
Scala for java developers 6 may 2017 - yeni
Scala for java developers   6 may 2017 - yeniScala for java developers   6 may 2017 - yeni
Scala for java developers 6 may 2017 - yeniBaris Dere
 
Merged Automation Talk - Pete Carapetyan - Feb 2016
Merged Automation Talk - Pete Carapetyan - Feb 2016 Merged Automation Talk - Pete Carapetyan - Feb 2016
Merged Automation Talk - Pete Carapetyan - Feb 2016 petecarapetyan
 
Introduction to Scala language
Introduction to Scala languageIntroduction to Scala language
Introduction to Scala languageAaqib Pervaiz
 
Contributing To Rails By Plugin Gem
Contributing To Rails By Plugin GemContributing To Rails By Plugin Gem
Contributing To Rails By Plugin GemDaniel Lv
 

Mais procurados (16)

Javaland keynote final
Javaland keynote finalJavaland keynote final
Javaland keynote final
 
JavaScript-Core
JavaScript-CoreJavaScript-Core
JavaScript-Core
 
Introduction to Scala for Java Developers
Introduction to Scala for Java DevelopersIntroduction to Scala for Java Developers
Introduction to Scala for Java Developers
 
Scala for C# Developers
Scala for C# DevelopersScala for C# Developers
Scala for C# Developers
 
Case class scala
Case class scalaCase class scala
Case class scala
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Funtional Ruby - Mikhail Bortnyk
Funtional Ruby - Mikhail BortnykFuntional Ruby - Mikhail Bortnyk
Funtional Ruby - Mikhail Bortnyk
 
Intro To Ror
Intro To RorIntro To Ror
Intro To Ror
 
Better Framework Better Life
Better Framework Better LifeBetter Framework Better Life
Better Framework Better Life
 
Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010
 
Big Data And No SQL
Big Data And No SQLBig Data And No SQL
Big Data And No SQL
 
Scala for java developers 6 may 2017 - yeni
Scala for java developers   6 may 2017 - yeniScala for java developers   6 may 2017 - yeni
Scala for java developers 6 may 2017 - yeni
 
Merged Automation Talk - Pete Carapetyan - Feb 2016
Merged Automation Talk - Pete Carapetyan - Feb 2016 Merged Automation Talk - Pete Carapetyan - Feb 2016
Merged Automation Talk - Pete Carapetyan - Feb 2016
 
Intro for RoR
Intro for RoRIntro for RoR
Intro for RoR
 
Introduction to Scala language
Introduction to Scala languageIntroduction to Scala language
Introduction to Scala language
 
Contributing To Rails By Plugin Gem
Contributing To Rails By Plugin GemContributing To Rails By Plugin Gem
Contributing To Rails By Plugin Gem
 

Semelhante a Scala for android

From java to scala at crowd mix
From java to scala at crowd mixFrom java to scala at crowd mix
From java to scala at crowd mixStefano Galarraga
 
Scala in Model-Driven development for Apparel Cloud Platform
Scala in Model-Driven development for Apparel Cloud PlatformScala in Model-Driven development for Apparel Cloud Platform
Scala in Model-Driven development for Apparel Cloud PlatformTomoharu ASAMI
 
Scala adoption by enterprises
Scala adoption by enterprisesScala adoption by enterprises
Scala adoption by enterprisesMike Slinn
 
Functional Scala 2022 - scalajs Alexis.pdf
Functional Scala 2022 - scalajs Alexis.pdfFunctional Scala 2022 - scalajs Alexis.pdf
Functional Scala 2022 - scalajs Alexis.pdfssusercd195b
 
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGNIntroducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGNManish Pandit
 
Develop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumDevelop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumNgoc Dao
 
Java to scala
Java to scalaJava to scala
Java to scalaGiltTech
 
Alternative Dispatcher Layer Overview
Alternative Dispatcher Layer OverviewAlternative Dispatcher Layer Overview
Alternative Dispatcher Layer OverviewSquare Cloud
 
Scala at Treasure Data
Scala at Treasure DataScala at Treasure Data
Scala at Treasure DataTaro L. Saito
 
Experience Converting from Ruby to Scala
Experience Converting from Ruby to ScalaExperience Converting from Ruby to Scala
Experience Converting from Ruby to ScalaJohn Nestor
 
Scala,a practicle approach
Scala,a practicle approachScala,a practicle approach
Scala,a practicle approachDeepak Kumar
 
An Introduction to Scala
An Introduction to ScalaAn Introduction to Scala
An Introduction to ScalaBrent Lemons
 

Semelhante a Scala for android (20)

From java to scala at crowd mix
From java to scala at crowd mixFrom java to scala at crowd mix
From java to scala at crowd mix
 
Scala in Model-Driven development for Apparel Cloud Platform
Scala in Model-Driven development for Apparel Cloud PlatformScala in Model-Driven development for Apparel Cloud Platform
Scala in Model-Driven development for Apparel Cloud Platform
 
Scala adoption by enterprises
Scala adoption by enterprisesScala adoption by enterprises
Scala adoption by enterprises
 
Stackato v4
Stackato v4Stackato v4
Stackato v4
 
Stackato v3
Stackato v3Stackato v3
Stackato v3
 
Stackato
StackatoStackato
Stackato
 
Functional Scala 2022 - scalajs Alexis.pdf
Functional Scala 2022 - scalajs Alexis.pdfFunctional Scala 2022 - scalajs Alexis.pdf
Functional Scala 2022 - scalajs Alexis.pdf
 
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGNIntroducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
 
Stackato v2
Stackato v2Stackato v2
Stackato v2
 
Develop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumDevelop realtime web with Scala and Xitrum
Develop realtime web with Scala and Xitrum
 
Java to scala
Java to scalaJava to scala
Java to scala
 
Polyglot Grails
Polyglot GrailsPolyglot Grails
Polyglot Grails
 
Stackato v6
Stackato v6Stackato v6
Stackato v6
 
Alternative Dispatcher Layer Overview
Alternative Dispatcher Layer OverviewAlternative Dispatcher Layer Overview
Alternative Dispatcher Layer Overview
 
Scala at Treasure Data
Scala at Treasure DataScala at Treasure Data
Scala at Treasure Data
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Experience Converting from Ruby to Scala
Experience Converting from Ruby to ScalaExperience Converting from Ruby to Scala
Experience Converting from Ruby to Scala
 
Scala,a practicle approach
Scala,a practicle approachScala,a practicle approach
Scala,a practicle approach
 
An Introduction to Scala
An Introduction to ScalaAn Introduction to Scala
An Introduction to Scala
 
Stackato v5
Stackato v5Stackato v5
Stackato v5
 

Mais de Tack Mobile

Assembly • Creative Mornings
Assembly • Creative MorningsAssembly • Creative Mornings
Assembly • Creative MorningsTack Mobile
 
Introduction to Hardware with littleBits
Introduction to Hardware with littleBitsIntroduction to Hardware with littleBits
Introduction to Hardware with littleBitsTack Mobile
 
Prototyping with Framer.js
Prototyping with Framer.jsPrototyping with Framer.js
Prototyping with Framer.jsTack Mobile
 
Adrift: The Making of an iOS Game
Adrift: The Making of an iOS GameAdrift: The Making of an iOS Game
Adrift: The Making of an iOS GameTack Mobile
 
Dynamic Sound for iOS Apps and Games
Dynamic Sound for iOS Apps and GamesDynamic Sound for iOS Apps and Games
Dynamic Sound for iOS Apps and GamesTack Mobile
 
Advanced Android Design Implementation
Advanced Android Design ImplementationAdvanced Android Design Implementation
Advanced Android Design ImplementationTack Mobile
 
Git for Android Developers
Git for Android DevelopersGit for Android Developers
Git for Android DevelopersTack Mobile
 
Designing an Android App from Idea to Market
Designing an Android App from Idea to MarketDesigning an Android App from Idea to Market
Designing an Android App from Idea to MarketTack Mobile
 
Mobile Means Business
Mobile Means BusinessMobile Means Business
Mobile Means BusinessTack Mobile
 

Mais de Tack Mobile (9)

Assembly • Creative Mornings
Assembly • Creative MorningsAssembly • Creative Mornings
Assembly • Creative Mornings
 
Introduction to Hardware with littleBits
Introduction to Hardware with littleBitsIntroduction to Hardware with littleBits
Introduction to Hardware with littleBits
 
Prototyping with Framer.js
Prototyping with Framer.jsPrototyping with Framer.js
Prototyping with Framer.js
 
Adrift: The Making of an iOS Game
Adrift: The Making of an iOS GameAdrift: The Making of an iOS Game
Adrift: The Making of an iOS Game
 
Dynamic Sound for iOS Apps and Games
Dynamic Sound for iOS Apps and GamesDynamic Sound for iOS Apps and Games
Dynamic Sound for iOS Apps and Games
 
Advanced Android Design Implementation
Advanced Android Design ImplementationAdvanced Android Design Implementation
Advanced Android Design Implementation
 
Git for Android Developers
Git for Android DevelopersGit for Android Developers
Git for Android Developers
 
Designing an Android App from Idea to Market
Designing an Android App from Idea to MarketDesigning an Android App from Idea to Market
Designing an Android App from Idea to Market
 
Mobile Means Business
Mobile Means BusinessMobile Means Business
Mobile Means Business
 

Último

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
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
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Último (20)

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Scala for android

  • 1. Do More with Less: Building Android Apps with Scala Tony Hillerson • Tack Mobile AnDevCon III @thillerson @tackmobile PRESENTATION ANDEVCON • MAY 14, 2012
  • 2. ABOUT ME Tony Hillerson Software Architect & Partner Mobile design and development company based in Denver, CO. • O’Reilly Screencasts • Computer Nerd @tackmobile • Co-creator of FieldTest tackmobile.com @thillerson tony@tackmobile.com PRESENTATION tackmobile.com
  • 3. Why Would I Consider Scala? • Write less boilerplate code • More powerful features than Java • Move towards Functional paradigms PRESENTATION tackmobile.com
  • 4. N.B. I Am Not a Scala Expert • You can probably stump me • This talk is about how you can explore what Scala might do for you PRESENTATION tackmobile.com
  • 5. My Goals • Introduce you to Scala • Introduce you to Scala with Android • Give you a few good reasons to use Scala • Encourage you to become a Polyglot PRESENTATION tackmobile.com
  • 6. Be a Polyglot PRESENTATION tackmobile.com
  • 7. Learn one new language per year - The Pragmatic Programmers PRESENTATION tackmobile.com
  • 9. What is Scala? PRESENTATION ANDEVCON • MAY 14, 2012
  • 10. What is Scala? • JVM Language • Take advantage of any Java library • Bridges the divide between OO and Functional spaces PRESENTATION tackmobile.com
  • 11. scala-lang.org PRESENTATION tackmobile.com
  • 12. REPL • Read Execute Print Loop • Command line: scala • Test code quickly PRESENTATION tackmobile.com
  • 13. Strongly, Statically Typed • Compile time type checking • Restrictions on how types can be used together • For comparison: • Javascript - Weakly typed, Dynamic • Ruby - Strongly typed, Dynamic PRESENTATION tackmobile.com
  • 14. ≠ Boilerplate • Perens are (sometimes) optional • Semicolons are (mostly) optional • Types are inferred, thus: ArrayList<GameTileMotionDescriptor> descriptors = new ArrayList<GameTileMotionDescriptor>(); VS. val descriptors = new ArrayBuffer[GameTileMotionDescriptor] PRESENTATION tackmobile.com
  • 15. More OO than Java • Everything is an object • Operators are actually methods • For instance, override the “+” method PRESENTATION tackmobile.com
  • 16. Functional Language • Functions are first class citizens • High order functions: Functions that operate on functions • Avoids mutable state • Could get pretty academic • Scala bridges the gap between OO and Functional PRESENTATION tackmobile.com
  • 17. A Javascript Function var doSomething = function(data) { doSomethingElseWithData(data); } PRESENTATION tackmobile.com
  • 18. A Scala Function def doSomething(data:A):B = { doSomethingElseWithData(data) } PRESENTATION tackmobile.com
  • 19. Concurrent • Optional immutable state • Actors - Higher concept than Threads/ Thread Pools PRESENTATION tackmobile.com
  • 20. Example Conversion Project PRESENTATION ANDEVCON • MAY 14, 2012
  • 21. Slider Puzzle PRESENTATION tackmobile.com
  • 22. Experiment: Convert from Java to Scala • Android • https://github.com/thillerson/Android-Slider-Puzzle • Scala • https://github.com/thillerson/scala-android-slider-puzzle • Mixed results. • I have a lot to learn about Scala PRESENTATION tackmobile.com
  • 23. Mike Burns • Thoughtbot • Android and Scala at Android Open • http://robots.thoughtbot.com/post/ 5836463058/scala-a-better-java-for-android • Ohlaunch - https://github.com/mike-burns/ ohlaunch PRESENTATION tackmobile.com
  • 24. Scala with Android PRESENTATION ANDEVCON • MAY 14, 2012
  • 25. SBT • Build tool (use for Java too) • https://github.com/harrah/xsbt/wiki/ Getting-Started-Welcome PRESENTATION tackmobile.com
  • 26. android-plugin • https://github.com/jberkel/android-plugin/ wiki/getting-started • ADB/DDMS Integration • Build and Release PRESENTATION tackmobile.com
  • 27. But I Need My Eclipse! • http://www.assembla.com/wiki/show/scala- ide/Developing_for_Android PRESENTATION tackmobile.com
  • 28. Scala’s Features and Idioms PRESENTATION ANDEVCON • MAY 14, 2012
  • 29. vals and vars • var - A variable definition. Required to be initialized when in a function • val - A value definition. Once set, cannot be changed • Basically a “final” • Important consideration for concurrent programming PRESENTATION tackmobile.com
  • 30. Methods • Declaration conventions • Suffix notation • Infix notation PRESENTATION tackmobile.com
  • 31. Looping • for ( item <- items ) • ranges PRESENTATION tackmobile.com
  • 32. Scala Collections • Scala really shines on collections • A good introduction to functional power PRESENTATION tackmobile.com
  • 33. Anonymous Function Syntax • ( args ) => ReturnType • ( x:Int ) => x * x PRESENTATION tackmobile.com
  • 34. Inheritance in Java • Single Inheritance • Restricting! PRESENTATION tackmobile.com
  • 35. Inheritance in C++ • Multiple Inheritance • Mind Blown PRESENTATION tackmobile.com
  • 36. Traits • Mixin pattern • Abstract/Interface + implementation PRESENTATION tackmobile.com
  • 37. Extending the Language class UnlessClass[T](block: => T) { def unless(b: Boolean): Unit = { if (!b) block } } implicit def toUnlessClass[T](block: => T): UnlessClass[T] = { new UnlessClass[T](block) } ... foo unless flag http://naturalsoftware.blogspot.com/2009/05/ruby-unless-scala.html PRESENTATION tackmobile.com
  • 38. Resources PRESENTATION ANDEVCON • MAY 14, 2012
  • 39. Books on Scala • http://www.scala-lang.org/node/959 PRESENTATION tackmobile.com
  • 40. Positronic • Framework for Android in Scala • Makes use of Actors • http://rst.github.com/tutorial.html PRESENTATION tackmobile.com
  • 41. Assembla • http://www.assembla.com/wiki/show/scala- ide/Developing_for_Android PRESENTATION tackmobile.com
  • 43. Recap • Scala is perfect for Android • Consider expanding your mind • Be a Polyglot PRESENTATION tackmobile.com
  • 44. Thank You @thillerson @tackmobile PRESENTATION ANDEVCON • MAY 14, 2012