• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Scala for android
 

Scala for android

on

  • 2,414 views

 

Statistics

Views

Total Views
2,414
Views on SlideShare
2,409
Embed Views
5

Actions

Likes
7
Downloads
33
Comments
0

2 Embeds 5

http://www.m.techgig.com 3
http://www.techgig.com 2

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Scala for android Scala for android Presentation Transcript

    • Do More with Less: Building Android Apps with Scala Tony Hillerson • Tack Mobile AnDevCon III @thillerson @tackmobilePRESENTATION ANDEVCON • MAY 14, 2012
    • ABOUT METony HillersonSoftware Architect & Partner Mobile design and development company based in Denver, CO.• O’Reilly Screencasts• Computer Nerd @tackmobile• Co-creator of FieldTest tackmobile.com@thillersontony@tackmobile.comPRESENTATION tackmobile.com
    • Why Would I Consider Scala? • Write less boilerplate code • More powerful features than Java • Move towards Functional paradigmsPRESENTATION 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 youPRESENTATION 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 PolyglotPRESENTATION tackmobile.com
    • Be a PolyglotPRESENTATION tackmobile.com
    • “ Learn one new language per year - The Pragmatic ProgrammersPRESENTATION tackmobile.com
    • SevenLanguages inSeven Weekshttp://pragprog.com/book/btlang/seven-languages-in- seven-weeksPRESENTATION 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 spacesPRESENTATION tackmobile.com
    • scala-lang.orgPRESENTATION tackmobile.com
    • REPL • Read Execute Print Loop • Command line: scala • Test code quicklyPRESENTATION 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, DynamicPRESENTATION 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 “+” methodPRESENTATION 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 FunctionalPRESENTATION tackmobile.com
    • A Javascript Functionvar doSomething = function(data) { doSomethingElseWithData(data);}PRESENTATION tackmobile.com
    • A Scala Functiondef doSomething(data:A):B = { doSomethingElseWithData(data)}PRESENTATION tackmobile.com
    • Concurrent • Optional immutable state • Actors - Higher concept than Threads/ Thread PoolsPRESENTATION tackmobile.com
    • Example Conversion ProjectPRESENTATION ANDEVCON • MAY 14, 2012
    • Slider PuzzlePRESENTATION 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 ScalaPRESENTATION 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/ ohlaunchPRESENTATION tackmobile.com
    • Scala with AndroidPRESENTATION ANDEVCON • MAY 14, 2012
    • SBT • Build tool (use for Java too) • https://github.com/harrah/xsbt/wiki/ Getting-Started-WelcomePRESENTATION tackmobile.com
    • android-plugin • https://github.com/jberkel/android-plugin/ wiki/getting-started • ADB/DDMS Integration • Build and ReleasePRESENTATION tackmobile.com
    • But I Need My Eclipse! • http://www.assembla.com/wiki/show/scala- ide/Developing_for_AndroidPRESENTATION tackmobile.com
    • Scala’s Features and IdiomsPRESENTATION 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 programmingPRESENTATION tackmobile.com
    • Methods • Declaration conventions • Suffix notation • Infix notationPRESENTATION tackmobile.com
    • Looping • for ( item <- items ) • rangesPRESENTATION tackmobile.com
    • Scala Collections • Scala really shines on collections • A good introduction to functional powerPRESENTATION tackmobile.com
    • Anonymous Function Syntax • ( args ) => ReturnType • ( x:Int ) => x * xPRESENTATION tackmobile.com
    • Inheritance in Java • Single Inheritance • Restricting!PRESENTATION tackmobile.com
    • Inheritance in C++ • Multiple Inheritance • Mind BlownPRESENTATION tackmobile.com
    • Traits • Mixin pattern • Abstract/Interface + implementationPRESENTATION 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.htmlPRESENTATION tackmobile.com
    • ResourcesPRESENTATION ANDEVCON • MAY 14, 2012
    • Books on Scala • http://www.scala-lang.org/node/959PRESENTATION tackmobile.com
    • Positronic • Framework for Android in Scala • Makes use of Actors • http://rst.github.com/tutorial.htmlPRESENTATION tackmobile.com
    • Assembla • http://www.assembla.com/wiki/show/scala- ide/Developing_for_AndroidPRESENTATION tackmobile.com
    • SevenLanguages inSeven Weekshttp://pragprog.com/book/btlang/seven-languages-in- seven-weeksPRESENTATION tackmobile.com
    • Recap • Scala is perfect for Android • Consider expanding your mind • Be a PolyglotPRESENTATION tackmobile.com
    • Thank You @thillerson @tackmobilePRESENTATION ANDEVCON • MAY 14, 2012