Your SlideShare is downloading. ×
0
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
Scala on Android: Experiences at Bump Technologies
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
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Scala on Android: Experiences at Bump Technologies

3,329

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.

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,329
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
44
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
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’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’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’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’t send Scala collections between processes\nClosures -> Mystery classes -> 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

    • 1. Scala on Android Real World Experiences at Bump Technologies
    • 2. Who are we? L Indy Khare Michael Galpin 0.3 of Bump Android Team
    • 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. Choose somumn; to sum or gusl hump ro runner: DUITID rrr--orocnru
    • 5. Choose aomelhmg lo um: or pm bump ro Lnnnru UUITID lI(IIIr0|0&Il
    • 6. Choose samernuug lo um: or . .m hump ro runner: DUITID rrr--orocnru
    • 7. Choose somumn; to sum or gusl hump ro runner: Match! DUITID rrr--orocnru
    • 8. Choose samernuug lo und or . .m hump ro runner: DUITID rr¢-uoroonru
    • 9. Connect Wllh Randall Flagg? ‘ T | Connect wrlh Mrchool Galpn? DUITID ruc--onoc-rt
    • 10. Why Scala?
    • 11. Why Scala? Developer Productivity
    • 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. Why Scala? Attract top talent
    • 14. Chal| enge: Tooling . /'“"r‘ U‘ ( 3) J 7’ -J’ I - q. 7- -’ ‘ ‘ _ - (/ V. ' -1, 5:, ‘--,1
    • 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. Split Architecture The Cloud
    • 17. Split Architecture
    • 18. Challenge: Build
    • 19. Build: Release javac (protobuf) fsc javac (app) proguard dex
    • 20. Build: Development javac (protobuf) fsc javac (app) proguard dex (1 time)
    • 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. V‘ l V I T u I -i ‘I I / ‘B. I’ I If —i ’ x / f' . ‘ . ' l 4 ~ " . - M - . '. _ _ _ ‘~ , .I*'i -I . - '
    • 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. Contact Us it htt : //bu. m / o enin s G http: //devblog. bu. mp/ it indy@bu. mp w michael@bu. mp ; g d .

    ×