Your SlideShare is downloading. ×
0
Scala on Android

Real World Experiences at Bump Technologies
Who are we? 

    

L

Indy Khare Michael Galpin

 

0.3 of Bump Android Team
Bump two phones together to share photos,  contacts,  and apps! 

 

529.30 E 1.7 mus-n: oo»u «r -- l. / «-4 7:01 . ... 
a...
Choose somumn;  to sum or gusl
hump ro runner: 

DUITID

rrr--orocnru
Choose aomelhmg lo um:  or pm
bump ro Lnnnru

UUITID

lI(IIIr0|0&Il
Choose samernuug lo um:  or . .m
hump ro runner: 

DUITID

rrr--orocnru
Choose somumn;  to sum or gusl
hump ro runner: 

Match! 

DUITID

rrr--orocnru
Choose samernuug lo und or . .m
hump ro runner: 

   
 

DUITID

rr¢-uoroonru
Connect Wllh Randall
Flagg?  ‘ T

| 
Connect wrlh Mrchool
Galpn? 

DUITID

ruc--onoc-rt
Why Scala?
Why Scala? 

 

Developer Productivity
def actionListToHistoryRecords(pbs:  Iterable[EBAgxignfl: gpngL1,
source:  His: gLyRg; gLd*Source. Source, 

enclosingthann...
Why Scala? 

    

Attract top talent
Chal| enge: Tooling

. /'“"r‘

  
U‘ ( 3)  J 

7’ -J’ I -
q.  7- -’ ‘ ‘ _  - (/ 
V.  ' -1, 5:, ‘--,1
Developer Productivity? 

*9 Gotta use Ant

4* Slow
0 scalac
[‘_é. <,h 6  ___ 1 7%  P Fog U 3. r
   
gr .3  ». a2;. «.L ; ...
Split Architecture

The Cloud
Split Architecture
Challenge:  Build
Build:  Release

javac (protobuf)
fsc
javac (app)
proguard
dex
Build:  Development

javac (protobuf)

fsc
javac (app)
proguard
dex

(1 time)
Challenge:  Parcelables

public class Servicekesult implements Parcelable {

public static final Parcelable. Creator<Servi...
V‘
l
V I
T u
I
-i
‘I I

/ ‘B.  I’ I If —i
’ x
/ f' .  ‘ . ' l
4 ~ "
.  - M - . '.
_ _ _  ‘~ , .I*'i
-I
.  - '
More Challenges

lifilmi ll} :1?; ,:iilj, ci[%l> 3
Jfilr;  lg‘: /l: .l»‘. l.1.“llf‘ir. ;%ilI; Jxfl f

9 Inner classes

.3,...
Contact Us

it htt : //bu. m / o enin

s
G http: //devblog. bu. mp/     

it indy@bu. mp

w michael@bu. mp ;  g d .
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Upcoming SlideShare
Loading in...5
×

Scala on Android: Experiences at Bump Technologies

3,337

Published on

This was a talk given at the Scala Days 2011 conference. It talks about how Scala is used on the Bump Android app.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,337
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
44
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Example of some dense Scala code from Bump. Imagine what this would look like in Java.\n
  • That&amp;#x2019;s Indy driving. Michael is in the passenger seat. Obviously this picture was taken a few months ago when he had more hair.\n
  • \n
  • ADT and Scala plugins do not play well together. You can get them to not step on each other so much, but your life will still suck.\n
  • ADT and Scala plugins do not play well together. You can get them to not step on each other so much, but your life will still suck.\n
  • ADT and Scala plugins do not play well together. You can get them to not step on each other so much, but your life will still suck.\n
  • ADT and Scala plugins do not play well together. You can get them to not step on each other so much, but your life will still suck.\n
  • ADT and Scala plugins do not play well together. You can get them to not step on each other so much, but your life will still suck.\n
  • But wait, didn&amp;#x2019;t we pick Scala because of the promised developer productivity?\n
  • How we got our agility back\n
  • How we got our agility back\n
  • How we got our agility back\n
  • How we got our agility back\n
  • How we got our agility back\n
  • How we got our agility back\n
  • \n
  • Scalac compiler pukes on the Java code produced by the protocol buffers Java compiler, hence initial javac step. Pro Guard rips out Scala code from scala-library.jar that we don&amp;#x2019;t need. Dex is the Android compiler. It takes Java class files and produces Dalvik byte code.\n
  • Build everything, rip out app code, put the rest in a jar, and then use Eclipse/IntelliJ.\n
  • Android Parcelables require a public static field called PARCELABLE. A val in a companion object offers equivalent functionality, but is compiled into a method, not a field. Scala team hacked the compiler for Android as result: https://lampsvn.epfl.ch/trac/scala/changeset/22628\n
  • ~7M total downloads. 4 star rating. Featured on the Android Market. \n
  • Tricky to access non-static inner classes defined in Java, such as android.os.PowerManager.WakeLock\nCan&amp;#x2019;t send Scala collections between processes\nClosures -&gt; Mystery classes -&gt; Many allocations and leaked memory\nHard to debug crashes that happen on a line with multiple statements, closures, etc.\n
  • Hiring. Hiring. Hiring. Hiring. Hiring. Hiring. Hiring. Hiring. Hiring. Hiring. Hiring. Hiring. Hiring. Hiring. \n
  • Transcript of "Scala on Android: Experiences at Bump Technologies"

    1. 1. Scala on Android Real World Experiences at Bump Technologies
    2. 2. Who are we? L Indy Khare Michael Galpin 0.3 of Bump Android Team
    3. 3. Bump two phones together to share photos, contacts, and apps! 529.30 E 1.7 mus-n: oo»u «r -- l. / «-4 7:01 . ... as . __e a as . L W, _ mud . V - - I l I I7. _ ~: | :1 L—U 1] 2': l:| J; . lx[—, N ha ‘ V’ "‘ , V‘ L7’! ‘ 33“ CI -7’ st ' ‘ . . hi‘ < i 1- Z_. g‘. ‘ Connect withjohn ~ g. _‘ -‘— . Android? ‘Pp’ ‘ _ _ T‘ : Bump U w W___, _ _fl 3:, Solitaire Z| yIu~'7;-/ . my hm, Am“ I Thr' P(‘H0(II( Tdhlv I i }u , m.: ryrsms Q ‘__ Mouw Trap Dave Foster Bump to share yr Thirwu’ ( "‘I—Ju-L i_
    4. 4. Choose somumn; to sum or gusl hump ro runner: DUITID rrr--orocnru
    5. 5. Choose aomelhmg lo um: or pm bump ro Lnnnru UUITID lI(IIIr0|0&Il
    6. 6. Choose samernuug lo um: or . .m hump ro runner: DUITID rrr--orocnru
    7. 7. Choose somumn; to sum or gusl hump ro runner: Match! DUITID rrr--orocnru
    8. 8. Choose samernuug lo und or . .m hump ro runner: DUITID rr¢-uoroonru
    9. 9. Connect Wllh Randall Flagg? ‘ T | Connect wrlh Mrchool Galpn? DUITID ruc--onoc-rt
    10. 10. Why Scala?
    11. 11. Why Scala? Developer Productivity
    12. 12. def actionListToHistoryRecords(pbs: Iterable[EBAgxignfl: gpngL1, source: His: gLyRg; gLd*Source. Source, enclosingthannel: String, enclosingld: String): Array[Hi§:9LyRg; g;g1 = { (pbs 9rour>By { _. .qs1;ActionIxm= ._} map { _ match { case ((8AMPacketType. PHOT0, v)) = > Iterab1e(Some(new PhotoHistoryRecord(v, source, enc1osingChanne1, enc1osingId))) case ((8AMPacketType. CHAT, v)) = > v map { pb = > Some(new ChatHistoryRecord(pb, source)) } case ((BAMPacketType. APP, v)) = > Iterab1e(Some(new AppHistoryRecord(v, source))) case ((8AMPacketType. CONTACT, v)) = > v map { pb = > Some(new ContactHistoryRecord(pb, source, enclosingthannel, enc1osingId)) } case ((8AMPacketType. CAPABILITY_NOTICE, v)) = > v map { pb = > Some(new Htm1HistoryRecord(pb, source)) } case ((BAMPacketType. WEB_APP, v)) = > v. map(pb = > { Some(new WebAppHistoryRecord(pb, source)) }) case (Ct, v)) = > { List(None) } } }). f1atten. f1atten. toArray }
    13. 13. Why Scala? Attract top talent
    14. 14. Chal| enge: Tooling . /'“"r‘ U‘ ( 3) J 7’ -J’ I - q. 7- -’ ‘ ‘ _ - (/ V. ' -1, 5:, ‘--,1
    15. 15. Developer Productivity? *9 Gotta use Ant 4* Slow 0 scalac [‘_é. <,h 6 ___ 1 7% P Fog U 3. r gr .3 ». a2;. «.L ; ; la-set '8 dex
    16. 16. Split Architecture The Cloud
    17. 17. Split Architecture
    18. 18. Challenge: Build
    19. 19. Build: Release javac (protobuf) fsc javac (app) proguard dex
    20. 20. Build: Development javac (protobuf) fsc javac (app) proguard dex (1 time)
    21. 21. Challenge: Parcelables public class Servicekesult implements Parcelable { public static final Parcelable. Creator<ServiceResult> CREATOR = C1a5S Higtorykecord extends pa, ce1ab1e { new Parcelable, Creator<ServiceResult>() ( public ServiceResult createFromParce1(Parcel in) { de; w, iteTopa, ce1(°ut: pa, (e1_ flags: Int); Unit } return new ServiceResult(in); def describecontents = 0 } public ServiceResult[] newArray(int size) ( _ _ return new ServiceResult[size]; °bJ§‘* H‘5t°'Y5'°“P { _ ina va = new arce a e. rector is ory roup } r 1 ICREATOR P lbl c [H t G ]O{ }; def createFromParcel(in: Parcel): Historyfiroup = new HistoryGroup(in) deF newArray(size: Int): Array[HistoryGroup] = new Array[History6roup](size) -i-. ’i~. --»i- rlv } public int describeContents() { } return 0; } JflvPl' up public void writeToParcel(Parce1 out, int Flags) { out. writeBundle(resu1t); out. writeString(errorMsg); out. writeInt(errorCode. ordinal());
    22. 22. V‘ l V I T u I -i ‘I I / ‘B. I’ I If —i ’ x / f' . ‘ . ' l 4 ~ " . - M - . '. _ _ _ ‘~ , .I*'i -I . - '
    23. 23. More Challenges lifilmi ll} :1?; ,:iilj, ci[%l> 3 Jfilr; lg‘: /l: .l»‘. l.1.“llf‘ir. ;%ilI; Jxfl f 9 Inner classes .3, *9 Collections :5 ': ‘ (conversions) w Memory usage ATsszfo3i''m'5v '* Debugging
    24. 24. Contact Us it htt : //bu. m / o enin s G http: //devblog. bu. mp/ it indy@bu. mp w michael@bu. mp ; g d .
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×