Upgrade to Pro — share decks privately, control downloads, hide ads and more …

New Android Languages

New Android Languages

Talk about 8 programming languages that can be used in Android development.

For the Droidcon Spain 2015.

Javier Gamarra

April 24, 2015
Tweet

More Decks by Javier Gamarra

Other Decks in Programming

Transcript

  1. N E W A N D R O I D

    L A N G U A G E S J A V I E R G A M A R R A : : @ N H PA T T
  2. @ N H PAT T @ A G I L

    E C Y L ( 0 9 / 0 5 ! ) @ L I F E R AY by wiredforlego
  3. S W I F T F O R A N

    D R O I D ? by Andreas
  4. H O W M A N Y L A N

    G U A G E S H AV E A N D R O I D “ S U P P O R T ” ?
  5. • Scala • Kotlin • Groovy • Clojure • Go

    • Ceylon • XTend • JS • C++ • C# • PHP • Python • Ruby • Swift • QT • Perl • Pascal • Smalltalk
  6. • JS • C++ • C# • PHP • Scala

    • Kotlin • Groovy • Go • Ceylon • XTend
  7. X T E N D - W H AT ?

    • xtend & xtendroid • 2011!
  8. X T E N D - H O W ?

    • Eclipse IDE + SDK, Android Studio incoming? • About 40 minutes
  9. X T E N D - C O D E

    @AndroidActivity(R.layout.activity_main) class MainActivity { @OnCreate def init(Bundle savedInstanceState) { } }
  10. X T E N D - C O D E

    myButton.onClickListener = [ toast("My message"); ]
  11. X T E N D - C O D E

    val toUpperCaseFunction = [String s|s.toUpperCase]
  12. X T E N D - T H I N

    G S • Extension methods • Lambda expressions • Implicits • Operator overloading • Compiles to Java Code
  13. X T E N D - O P I N

    I O N • Perfect for consulting companies • Everything does too much • Java+
  14. G R O O V Y - W H AT

    ? • dynamic (2003) & static (2012!)
  15. G R O O V Y - H O W

    ? • Android Studio, Groovy Gradle Plugin • In groovy folder • About 30 minutes • SwissKnife
  16. G R O O V Y - C O D

    E def message = findViewById(R.id.message) as TextView
 message.text = messageText;
  17. G R O O V Y - C O D

    E button.onClickListener = {startActivity(intent)} @OnClick
  18. G R O O V Y - T H I

    N G S • Dynamic code & static code (@CompileStatic) • Traits • Better apis • Great gradle integration (dagger support coming)
  19. G R O O V Y - O P I

    N I O N • Java++ • Dynamic code? • I like groovy but…
  20. C E Y L O N - W H AT

    ? • Ceylon • Gavin King • 2011
  21. C E Y L O N - H O W

    ? • Eclipse IDE + Ceylon Plugin + PAIN • About 6 hours (eclipse hell + ceylon hell)
  22. A N D R O I D D O C

    U M E N TAT I O N
  23. A N D R O I D D O C

    U M E N TAT I O N
  24. C E Y L O N - C O D

    E shared actual void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.\Ilayout.activity_main); assert (is TextView textView = findViewById(R.\Iid.action_settings)); }
  25. C E Y L O N - T H I

    N G S • Type system • Mixins • String? • Packages and modules inside Ceylon
  26. C E Y L O N - O P I

    N I O N • Not ready. Future? • Doubt so.
  27. S C A L A - W H AT ?

    • Scala • 2003
  28. S C A L A - H O W ?

    • Gradle plugin? • Post 47 degrees: Idea + plugins + SBT + activator… • About 1 hour
  29. T R O L L I N G S C

    A L A • findView without casts -> a trait • scala one liners -> hard to read by others but nice in collections • scala -> 2.8M with proguard -> heaviest environment • NPE -> with optionals, great solution IMHO • implicit context -> magic everywhere • traits -> quite common (kotlin, ceylon, ‘groovy’…) • no getters/setters -> quite common • pattern matching -> it’s nice but pure functional style • case classes -> a glorified switch/if
  30. S C A L A - T H I N

    G S • Types • Multiple programming styles • Optional
  31. S C A L A - O P I N

    I O N • I love scala, way better than Java, but… • Paradigm swift • Programmers (25 in TIOBE)
  32. S C A L A - S C A L

    O I D new SVerticalLayout { STextView("Sign in").textSize(24.5 sp).<<.marginBottom(25 dip).>> STextView("ID") SEditText() STextView("Password") SEditText() inputType TEXT_PASSWORD SButton("Sign in") this += new SLinearLayout { SButton("Help") SButton("Sign up") }.wrap }.padding(20 dip)
  33. S C A L A - M A C R

    O I D // the layout goes here setContentView { getUi { l[LinearLayout]( w[Button], w[TextView] ) } }
  34. “ W h o s e b e t t

    i n g t h i s y e a r s I / O w i l l a n n o u n c e t h e re p l a c e m e n t o f t h e A n d ro i d A P I w i t h t h e G o A P I ? “
  35. “ I l l o g i c a l

    , i r re s p o n s i b l e , i n s a n e p e o p l e a re b e t t i n g t h i s . ” “ G o , f o r C p e o p l e w h o h a t e C + + b u t a re t o o a f r a i d o f re a l I D E s f o r J a v a . ” J a k e W h a r t o n
  36. G O - H O W ? • Docker image

    (docker -> boot2docker -> missing steps -> worst hello world ever!) • About 2 hours (image is 4GB! + docker errors + no documentation)
  37. G O - C O D E • 2 ways:

    • Shared Library (JNI…) • All go
  38. G O - C O D E • var State

    • func Run • type Callbacks (Start, Stop, Draw) • Stubs
  39. G O - O P I N I O N

    • API for OpenGL/business logic • Not ready for “classic” app. • I’m worried about iOS support
  40. K O T L I N - W H AT

    ? • Kotlin • 2011
  41. K O T L I N - H O W

    ? • Android Studio plugin • About 10 minutes
  42. K O T L I N - T H I

    N G S • Traits • Interoperability with Java! • Extension Methods • Null?
  43. T R O L L I N G K O

    T L I N • class Leiva : Untrollable
  44. K O T L I N - O P I

    N I O N • I love Kotlin. • Really easy learning curve. • Few programmers doing Kotlin :(
  45. J AVA 8 • JDK7: <>, multi-catch, strings in switches,

    try with resources… • And java NIO/invokedynamic?
  46. R E T R O L A M B D

    A asdasdasd by Marcos Bessa
  47. R E T R O L A M B D

    A - W H AT ? • Lambdas • Default Methods • Static Methods on interfaces
  48. R E T R O L A M B D

    A - H O W ? • Gradle Plugin • About 30 minutes
  49. R E T R O L A M B D

    A - C O D E (View v) -> Toast.makeText(this, “Hi!”, LENGTH_SHORT).
  50. R E T R O L A M B D

    A - O P I N I O N • An incomplete hack. • Nice if you don’t have any other option.
  51. A N D T H E T R O P

    H I E S G O T O …
  52. G O F O R B E I N G

    T H E M O S T H Y P E D by David Luders
  53. C E Y L O N F O R N

    O T B E I N G T H E R E by David Luders
  54. S C A L A C O N S O

    L AT I O N P R I Z E by David Luders
  55. F I N A L W O R D S

    by jmiguel rodriguez
  56. T H AT M E A N S S O

    M E T H I N G
  57. N O T O N LY S Y N TA

    C T I C S U G A R asdasdasd by Steve Maw
  58. D A R T A N Y O N E

    ? by Sasha Nilov
  59. E N D * * ¿ A L G U

    I E N Q U I E R E Q U E L E M O N T E U N E N T O R N O ? asdasdasd by Gord McKenna
  60. T H A N K S ! - > K

    C Y. M E / 2 2 N D 2 by Ale Art
  61. O K … K O T L I N V

    S S C A L A , F I G H T !
  62. O K … K O T L I N V

    S S C A L A , F I G H T !
  63. O K … K O T L I N V

    S S C A L A , F I G H T !
  64. O K … K O T L I N V

    S S C A L A , F I G H T !
  65. O K … K O T L I N V

    S S C A L A , F I G H T ! • Kotlin ppl are nice: comparison to scala -> if u are already using Scala or need sth on that list… • A good, external, comparison
  66. O K … K O T L I N V

    S S C A L A , F I G H T ! • The main design goals behind “Kotlin” are: • To create a Java-compatible language, • That compiles at least as fast as Java, • Make it safer than Java, i.e. statically check for common pitfalls such as null pointer dereference, • Make it more concise than Java by supporting variable type inference, higher-order functions (closures), extension functions, mixins and first- class delegation, etc; • And, keeping the useful level of expressiveness (see above), make it way simpler than the most mature competitor – Scala.
  67. N E W A N D R O I D

    L A N G U A G E S J A V I E R G A M A R R A : : @ N H PA T T