+ All Categories
Home > Software > New Android Languages

New Android Languages

Date post: 26-Jul-2015
Category:
Upload: javier-gamarra
View: 337 times
Download: 2 times
Share this document with a friend
Popular Tags:
99
NEW ANDROID LANGUAGES JAVIER GAMARRA :: @NHPATT
Transcript

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

@ N H PAT T @ A G I L E C Y L ( 0 9 / 0 5 ! ) @ L I F E R AY

by wiredforlego

S E L F - E S T E E M

K C Y. M E / 2 2 N A N

G R O O V Y

S C A L A

X T E N D

S W I F T

K O T L I N

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 ” ?

• Scala

• Kotlin

• Groovy

• Clojure

• Go

• Ceylon

• XTend

• JS

• C++

• C#

• PHP

• Python

• Ruby

• Swift

• QT

• Perl

• Pascal

• Smalltalk

A N Y L A N G U A G E …

T H AT ’ S W H Y

• JS

• C++

• C#

• PHP

• Scala

• Kotlin

• Groovy

• Go

• Ceylon

• XTend

H O W ?

• Small TODO app

• Uploaded soon to github

• Big post coming to nhpatt.com

X T E N D - W H AT ?

• xtend & xtendroid

• 2011!

X T E N D - H O W ?

• Eclipse IDE + SDK, Android Studio incoming?

• About 40 minutes

X T E N D - C O D E

@AndroidActivity(R.layout.activity_main) class MainActivity {

@OnCreate def init(Bundle savedInstanceState) { }

}

X T E N D - C O D E

myButton.onClickListener = [ toast("My message"); ]

X T E N D - C O D E

val toUpperCaseFunction = [String s|s.toUpperCase]

X T E N D - T H I N G S

• Extension methods

• Lambda expressions

• Implicits

• Operator overloading

• Compiles to Java Code

X T E N D - O P I N I O N

• Perfect for consulting companies

• Everything does too much

• Java+

G R O O V Y - W H AT ?

• dynamic (2003) & static (2012!)

G R O O V Y - H O W ?

• Android Studio, Groovy Gradle Plugin

• In groovy folder

• About 30 minutes

• SwissKnife

G R O O V Y - C O D E

def message = findViewById(R.id.message) as TextViewmessage.text = messageText;

G R O O V Y - C O D E

button.onClickListener = {startActivity(intent)}

@OnClick

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)

G R O O V Y - S TAT I C

G R O O V Y - R U N T I M E

G R O O V Y - O P I N I O N

• Java++

• Dynamic code?

• I like groovy but…

C E Y L O N - W H AT ?

• Ceylon

• Gavin King

• 2011

C E Y L O N - H O W ?

• Eclipse IDE + Ceylon Plugin + PAIN

• About 6 hours (eclipse hell + ceylon hell)

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

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

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)); }

C E Y L O N - T H I N G S

• Type system

• Mixins

• String?

• Packages and modules inside Ceylon

S C A L A - W H AT ?

• Scala

• 2003

S C A L A - H O W ?

• Gradle plugin?

• Post 47 degrees: Idea + plugins + SBT + activator…

• About 1 hour

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

S C A L A - T H I N G S

• Types

• Multiple programming styles

• Optional

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)

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)

S C A L A - M A C R O I D

// the layout goes here

setContentView {

getUi {

l[LinearLayout](

w[Button],

w[TextView]

)

}

}

G O - W H AT ?

• Go

• 2009

G O - W H AT ?

“ 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 r e p l a c e m e n t o f t h e A n d r o i d A P I w i t h t h e G o A P I ? “

“ I l l o g i c a l , i r r e s p o n s i b l e , i n s a n e p e o p l e a r e 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 r e t o o a f r a i d o f r e a l I D E s f o r J a v a . ”

J a k e W h a r t o n

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)

G O - C O D E

• 2 ways:

• Shared Library (JNI…)

• All go

G O - C O D E

• var State

• func Run

• type Callbacks (Start, Stop, Draw)

• Stubs

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

K O T L I N - W H AT ?

• Kotlin

• 2011

K O T L I N - H O W ?

• Android Studio plugin

• About 10 minutes

K O T L I N - T H I N G S

• Traits

• Interoperability with Java!

• Extension Methods

• Null?

T R O L L I N G K O T L I N

• class Leiva : Untrollable

K O T L I N - O P I N I O N

• I love Kotlin.

• Really easy learning curve.

• Few programmers doing Kotlin :(

J AVA 8

• JDK7: <>, multi-catch, strings in switches, try with resources…

• And java NIO/invokedynamic?

J AVA 8

• And Java 8? (Lambdas/default methods/new date API…)

R E T R O L A M B D A - W H AT ?

• Lambdas

• Default Methods

• Static Methods on interfaces

R E T R O L A M B D A - H O W ?

• Gradle Plugin

• About 30 minutes

R E T R O L A M B D A - C O D E

(View v) -> Toast.makeText(this, “Hi!”, LENGTH_SHORT).

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.

A N D T H E T R O P H I E S G O T O …

N O T A N E W Q U E S T I O N

T H AT M E A N S S O M E T H I N G

A N Y Q U E S T I O N S ?

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

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

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

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

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

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.

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


Recommended