Rapid and Expressive Prototyping on Cell Phones via Script ...


Published on

1 Comment
1 Like
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Rapid and Expressive Prototyping on Cell Phones via Script ...

  1. 1. Rapid and Expressive Prototyping on Cell Phones via Script Embedding Jingtao Wang Computer Science Division [email_address]
  2. 2. Agenda <ul><li>Motivation </li></ul><ul><li>Challenges in creating cell phone app </li></ul><ul><li>Overview of popular mobile development platforms </li></ul><ul><li>Low threshold and high ceiling, the script embedding approach </li></ul><ul><li>Summary </li></ul>
  3. 3. The Popularization of Cell Phones
  4. 4. Cell Phone is THE Portable Computing Device <ul><li>Global penetration reached 50% (3.3 Billion) on 11/29/2007 </li></ul><ul><li>59 countries had cell phone market share over 100% </li></ul><ul><ul><li>Luxembourg 158% </li></ul></ul><ul><ul><li>Hong Kong 140% </li></ul></ul><ul><ul><li>Italy 122% </li></ul></ul><ul><ul><li>United States 81% </li></ul></ul><ul><ul><li>China ~ 42% </li></ul></ul><ul><ul><li>India 23% (largest growth market) </li></ul></ul><ul><li>There are only around 850 million PCs in the world. </li></ul>* Data from Informa Telecoms & Media
  5. 5. Opportunities and Challenges of Cell Phones <ul><li>The bright side </li></ul><ul><ul><li>Portable, always with you </li></ul></ul><ul><ul><li>Always on, always connected to the internet </li></ul></ul><ul><ul><li>Seamless integration with one’s social networks </li></ul></ul><ul><ul><li>High market penetration throughout the world </li></ul></ul><ul><li>The dark side </li></ul><ul><ul><li>Limited resources (CPU, memory, screen, input modality) </li></ul></ul><ul><ul><li>Highly diversified hardware and software implementations </li></ul></ul><ul><ul><li>Incomplete development tools and libraries </li></ul></ul><ul><ul><li>Proprietary hardware/software decrease competition and add costs in development and distribution </li></ul></ul>
  6. 6. Threshold and Ceiling Sophistication (Ceiling) C/C++ Goal HTML Difficulty (Threshold) MFC/Qt Flash ActionScript Component Framework
  7. 7. An Overview of Mobile Development Platforms - 1 <ul><li>Mainstream (non-smart) Phones (more than 90% market share) </li></ul><ul><ul><li>J2ME (Java 2 Micro Edition) </li></ul></ul><ul><ul><li>BREW (Binary Runtime Environment for Wireless) </li></ul></ul><ul><ul><li>Flash Lite </li></ul></ul><ul><ul><li>HTML, WAP/WML </li></ul></ul>
  8. 8. An Overview of Mobile Development Platforms - 2 <ul><li>Smart Phones (less than 10% market share) </li></ul><ul><ul><li>Windows Mobile ( Embedded Visual C++ , .Net Framework Compact Edition) </li></ul></ul><ul><ul><li>Linux (C/C++, Java, J2ME) </li></ul></ul><ul><ul><li>Symbian ( C++ , Python) </li></ul></ul><ul><ul><li>Palm ( C/C++ , J2ME) </li></ul></ul><ul><ul><li>Flash Lite </li></ul></ul><ul><ul><li>BREW </li></ul></ul><ul><ul><li>HTML/AJAX, WAP/WML </li></ul></ul>
  9. 9. J2ME <ul><li>Best availability on different platforms </li></ul><ul><li>Can leverage knowledge and resources from desktop Java </li></ul><ul><li>Good debugging support </li></ul><ul><li>Poor UI framework/libraries </li></ul><ul><li>Inconsistent behaviors in different devices (write once, debug everywhere) </li></ul><ul><li>Poor performance (no JIT on most devices) </li></ul><ul><li>Low ceiling (can only do what the built-in libraries allow one to do) </li></ul><ul><li>Signature required to access certain functions </li></ul>
  10. 10. BREW <ul><li>Using C/C++ as the host language </li></ul><ul><li>Excellent performance (applications run as compiled native code) </li></ul><ul><li>Small target application size and little overhead </li></ul><ul><li>High ceiling (can access all the capabilities of the phone) </li></ul><ul><li>The only widely available native API for non-smart phones </li></ul><ul><li>Steep learning curve </li></ul><ul><li>Bad UI library </li></ul><ul><li>More costs for the development environments and the development process </li></ul><ul><li>Hard to debug (different behaviors between the simulator and the real device) </li></ul><ul><li>Troublesome coding restrictions </li></ul><ul><li>Signature required to run any applications on a cell phone </li></ul>
  11. 11. Flash Lite <ul><li>Flash Lite 2.x similar to Flash 7.0 </li></ul><ul><li>Excellent IDE/Emulator support </li></ul><ul><li>Powerful functions for animation/vector graphics </li></ul><ul><li>Low learning threshold </li></ul><ul><li>Low runtime performance </li></ul><ul><li>Hard to access functions not provided, low ceiling </li></ul><ul><li>“ ActionScript Stuck” </li></ul>
  12. 12. HTML, WAP/WML <ul><li>Available on almost all cell phones </li></ul><ul><li>Low learning threshold </li></ul><ul><li>Easy to debug (functions implemented on the server side) </li></ul><ul><li>Low ceiling </li></ul><ul><li>Limited interactivity function support </li></ul><ul><li>Almost impossible to access local resources of the cell phone </li></ul><ul><li>High latency, requires network connection </li></ul>
  13. 13. Windows Mobile – Embedded Visual C++ <ul><li>Excellent performance </li></ul><ul><li>Intermediate learning curve for existing C/C++ programmers </li></ul><ul><li>Relatively steep learning curve for non-C/C++ programmers </li></ul><ul><li>Easy to access hardware features </li></ul><ul><li>Excellent UI framework and UI builder </li></ul><ul><li>Excellent IDE/debugger support </li></ul><ul><li>Excellent emulator support </li></ul><ul><li>Limited device penetration </li></ul>
  14. 14. Windows Mobile – .Net Framework Compact Edition <ul><li>Medium to Good performance </li></ul><ul><li>Low learning threshold </li></ul><ul><li>Excellent UI framework and UI builder </li></ul><ul><li>Excellent IDE/debugger support </li></ul><ul><li>Excellent emulator support </li></ul><ul><li>Extra space overhead (2 mb) </li></ul><ul><li>Limited device penetration </li></ul>
  15. 15. Symbian – C++ <ul><li>Excellent performance </li></ul><ul><li>High learning threshold </li></ul><ul><li>Reasonable UI framework </li></ul><ul><li>High ceiling </li></ul><ul><li>High market share among smart phones </li></ul><ul><li>Poor IDE/debugger support </li></ul><ul><li>Troublesome coding restrictions </li></ul><ul><li>Poor simulator support </li></ul><ul><li>Limited device penetration in the U.S. </li></ul>
  16. 16. Symbian – Python <ul><li>Poor performance </li></ul><ul><li>Low learning threshold </li></ul><ul><li>Reasonable UI framework </li></ul><ul><li>Relatively high ceiling </li></ul><ul><li>Poor IDE/debugger support </li></ul><ul><li>Poor simulator support </li></ul><ul><li>Additional runtime overhead (> 1mb) </li></ul><ul><li>Limited device penetration in the U.S. </li></ul>
  17. 17. Palm <ul><li>Huge paradigm shift between version 1.x – 4.x and 5.x + </li></ul><ul><li>Only device specific simulator after 5.x </li></ul><ul><li>Gradually becoming obsolete </li></ul>
  18. 18. Android and iPhone <ul><li>Android </li></ul><ul><ul><li>Customized version of Java (between Java desktop and J2ME) </li></ul></ul><ul><ul><li>Good UI framework (when compared with J2ME) </li></ul></ul><ul><ul><li>Limited media capture capability as J2ME </li></ul></ul><ul><ul><li>Calling native functions is discouraged </li></ul></ul><ul><li>iPhone </li></ul><ul><ul><li>HTML + AJAX based web app running on browsers </li></ul></ul><ul><ul><li>Native app (Objective C) </li></ul></ul>
  19. 19. Native Code vs. Dynamic Script <ul><li>Native Code </li></ul><ul><ul><li>Excellent runtime speed </li></ul></ul><ul><ul><li>High threshold, high ceiling </li></ul></ul><ul><ul><li>Easy to access the low level hardware </li></ul></ul><ul><ul><li>Difficult to program and difficult to debug </li></ul></ul><ul><li>Dynamic (Interpreted) Script </li></ul><ul><ul><li>Slow runtime speed </li></ul></ul><ul><ul><li>Easy to learn, low ceiling </li></ul></ul><ul><ul><li>Easy to debug, easy to share </li></ul></ul><ul><ul><li>Hard to access extra features of the hardware </li></ul></ul><ul><li>Can we take advantages of nice things from both approaches? </li></ul>
  20. 20. Embedding Scripts to the Host Application Host Program Embedded Interpreter color = RED b = button { label = ‘OK’, x = 10, y = 20} Wrapped Library
  21. 21. Choice of the Embedded Script Engine <ul><li>Lua is a powerful, fast, light-weight, embeddable scripting language </li></ul><ul><ul><li>Originated in 1993, now developed by Lablua </li></ul></ul><ul><ul><li>Designed as a lightweight embedded script language </li></ul></ul><ul><ul><li>A leading scripting language in the games industry </li></ul></ul><ul><ul><li>See www.lua.org </li></ul></ul><ul><li>Has been ported to BREW, Windows Mobile and Symbian </li></ul>
  22. 22. Approximate Runtime Performance <ul><li>Not intended to be a comprehensive evaluation </li></ul><ul><li>Benchmarking programs (sorting, factorial computing, string operations) </li></ul>Vs. Runtime Speed Runtime Memory C/C++ 1/5 ~ 1/12 1.0 ~ 1.5 Python 1.9 ~ 3.5 2.1 ~ 3.3 JavaScript 2.3 ~ 18 1.7 ~ 9.7
  23. 23. Some Sample Codes function HelloWorld () io.write (&quot;hello World&quot;) trace (&quot;trace working now&quot;) end HelloWorld() function fat (n) if n == 0 then return 1 else return n*fat(n-1) end end Function max(a, b) local m = a if b > a then m = b end return m end 1 MOVE 2 0 0 ; R(2) = R(0) 2 LT 0 0 1 ; R(0) < R(1) 3 JMP 1 ; to 5 (4+1) 4 MOVE 2 1 0 ; R(2) = R(1) 5 RETURN 2 2 0 ; return R(2) 6 RETURN 0 1 0 ; return
  24. 24. Easy to Switch Between both Worlds LIBSHELL_API int LibSHELL_MessageBoxText(lua_State *L) { const char *szTitle = (const char *)luaL_checkudata(L, 1, AECHAR_TNAME); const char *szText = ( const char *)luaL_checkudata(L, 2, AECHAR_TNAME); ISHELL_MessageBoxText(GETAPPSHELL(), szTitle, szText); return 0; } …… lua_register(L, “messageBox&quot;, LibSHELL_MessageBoxText ); Exporting the ISHELL_MessageBoxText function from BREW to the script Void FireEvent(int id, const char * args) { if (g_strEventHandler != NULL) { char buf[254]; SPRINTF( buf, “%s(%d,%s)”, g_strEventHandler, id, args); lua_pcall(luaState, buf, LUA_MULTRET, 0); } return; } Calling a lua function (event handler) from C/C++
  25. 25. Scaffolding Mobile Development via Script Embedding <ul><li>Average users </li></ul><ul><ul><li>Use form-guided code generation templates to customize an application </li></ul></ul><ul><ul><li>Download and share new functions </li></ul></ul><ul><li>Group development </li></ul><ul><ul><li>Only one member responsible for C/C++ programming, expose additional native functions to script programmers via glue function </li></ul></ul><ul><ul><li>Other members fast prototyping in script </li></ul></ul><ul><li>Runtime performance sensitive application </li></ul><ul><ul><li>Identify performance bottlenecks in the script implementation, reemployment them in C/C++ and export them to the script </li></ul></ul>
  26. 26. Summary <ul><li>Building applications for cell phones is challenging due to highly diversified environment and toolkits </li></ul><ul><li>Trade-offs between low learning threshold and high ceiling need to be carefully considered </li></ul><ul><li>Script embedding is a solution to leverage nice features from both worlds </li></ul>
  27. 27. Thanks! <ul><li>Any questions? </li></ul>