rapid and expressive prototyping on cell phones via script

27
Rapid and Expressive Prototyping on Cell Phones via Script Embedding Jingtao Wang Computer Science Division [email protected]

Upload: peterbuck

Post on 25-May-2015

473 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Rapid and Expressive Prototyping on Cell Phones via Script

Rapid and Expressive Prototyping on Cell Phones via Script Embedding

Jingtao WangComputer Science [email protected]

Page 2: Rapid and Expressive Prototyping on Cell Phones via Script

Agenda

Motivation Challenges in creating cell phone app Overview of popular mobile development

platforms Low threshold and high ceiling, the script

embedding approach Summary

Page 3: Rapid and Expressive Prototyping on Cell Phones via Script

The Popularization of Cell Phones

Page 4: Rapid and Expressive Prototyping on Cell Phones via Script

Cell Phone is THE Portable Computing Device

Global penetration reached 50% (3.3 Billion) on 11/29/2007

59 countries had cell phone market share over 100% Luxembourg 158% Hong Kong 140% Italy 122% United States 81% China ~ 42% India 23% (largest growth market)

There are only around 850 million PCs in the world.

* Data from Informa Telecoms & Media

Page 5: Rapid and Expressive Prototyping on Cell Phones via Script

Opportunities and Challenges of Cell Phones

The bright side Portable, always with you Always on, always connected to the internet Seamless integration with one’s social networks High market penetration throughout the world

The dark side Limited resources (CPU, memory, screen, input modality) Highly diversified hardware and software implementations Incomplete development tools and libraries Proprietary hardware/software decrease competition and add

costs in development and distribution

Page 6: Rapid and Expressive Prototyping on Cell Phones via Script

Threshold and Ceiling

Sophistication (Ceiling)

C/C++

Goal

HTML

Difficulty(Threshold)

MFC/Qt

Flash

ActionScript

Component Framework

Page 7: Rapid and Expressive Prototyping on Cell Phones via Script

An Overview of Mobile Development Platforms - 1

Mainstream (non-smart) Phones (more than 90% market share) J2ME (Java 2 Micro Edition) BREW (Binary Runtime Environment for Wireless) Flash Lite HTML, WAP/WML

Page 8: Rapid and Expressive Prototyping on Cell Phones via Script

An Overview of Mobile Development Platforms - 2

Smart Phones (less than 10% market share) Windows Mobile (Embedded Visual C++, .Net Framework Compact

Edition) Linux (C/C++, Java, J2ME) Symbian (C++, Python) Palm (C/C++, J2ME) Flash Lite BREW HTML/AJAX, WAP/WML

Page 9: Rapid and Expressive Prototyping on Cell Phones via Script

J2ME

Best availability on different platforms Can leverage knowledge and resources from desktop

Java Good debugging support Poor UI framework/libraries Inconsistent behaviors in different devices (write once,

debug everywhere) Poor performance (no JIT on most devices) Low ceiling (can only do what the built-in libraries allow

one to do) Signature required to access certain functions

Page 10: Rapid and Expressive Prototyping on Cell Phones via Script

BREW

Using C/C++ as the host language Excellent performance (applications run as compiled native code) Small target application size and little overhead High ceiling (can access all the capabilities of the phone) The only widely available native API for non-smart phones Steep learning curve Bad UI library More costs for the development environments and the development

process Hard to debug (different behaviors between the simulator and the

real device) Troublesome coding restrictions Signature required to run any applications on a cell phone

Page 11: Rapid and Expressive Prototyping on Cell Phones via Script

Flash Lite

Flash Lite 2.x similar to Flash 7.0 Excellent IDE/Emulator support Powerful functions for animation/vector graphics Low learning threshold Low runtime performance Hard to access functions not provided, low ceiling “ActionScript Stuck”

Page 12: Rapid and Expressive Prototyping on Cell Phones via Script

HTML, WAP/WML

Available on almost all cell phones Low learning threshold Easy to debug (functions implemented on the server

side) Low ceiling Limited interactivity function support Almost impossible to access local resources of the cell

phone High latency, requires network connection

Page 13: Rapid and Expressive Prototyping on Cell Phones via Script

Windows Mobile – Embedded Visual C++

Excellent performance Intermediate learning curve for existing C/C++

programmers Relatively steep learning curve for non-C/C++

programmers Easy to access hardware features Excellent UI framework and UI builder Excellent IDE/debugger support Excellent emulator support Limited device penetration

Page 14: Rapid and Expressive Prototyping on Cell Phones via Script

Windows Mobile – .Net Framework Compact Edition

Medium to Good performance Low learning threshold Excellent UI framework and UI builder Excellent IDE/debugger support Excellent emulator support Extra space overhead (2 mb) Limited device penetration

Page 15: Rapid and Expressive Prototyping on Cell Phones via Script

Symbian – C++

Excellent performance High learning threshold Reasonable UI framework High ceiling High market share among smart phones Poor IDE/debugger support Troublesome coding restrictions Poor simulator support Limited device penetration in the U.S.

Page 16: Rapid and Expressive Prototyping on Cell Phones via Script

Symbian – Python

Poor performance Low learning threshold Reasonable UI framework Relatively high ceiling Poor IDE/debugger support Poor simulator support Additional runtime overhead (> 1mb) Limited device penetration in the U.S.

Page 17: Rapid and Expressive Prototyping on Cell Phones via Script

Palm

Huge paradigm shift between version 1.x – 4.x and 5.x +

Only device specific simulator after 5.xGradually becoming obsolete

Page 18: Rapid and Expressive Prototyping on Cell Phones via Script

Android and iPhone

Android Customized version of Java (between Java desktop

and J2ME) Good UI framework (when compared with J2ME) Limited media capture capability as J2ME Calling native functions is discouraged

iPhone HTML + AJAX based web app running on browsers Native app (Objective C)

Page 19: Rapid and Expressive Prototyping on Cell Phones via Script

Native Code vs. Dynamic Script

Native Code Excellent runtime speed High threshold, high ceiling Easy to access the low level hardware Difficult to program and difficult to debug

Dynamic (Interpreted) Script Slow runtime speed Easy to learn, low ceiling Easy to debug, easy to share Hard to access extra features of the hardware

Can we take advantages of nice things from both approaches?

Page 20: Rapid and Expressive Prototyping on Cell Phones via Script

Embedding Scripts to the Host Application

HostProgram

EmbeddedInterpreter

color = REDb = button { label = ‘OK’, x = 10, y = 20}

Wrapped Library

Page 21: Rapid and Expressive Prototyping on Cell Phones via Script

Choice of the Embedded Script Engine

Lua is a powerful, fast, light-weight, embeddable scripting language Originated in 1993, now developed by Lablua Designed as a lightweight embedded script

language A leading scripting language in the games industry See www.lua.org

Has been ported to BREW, Windows Mobile and Symbian

Page 22: Rapid and Expressive Prototyping on Cell Phones via Script

Approximate Runtime Performance

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

•Not intended to be a comprehensive evaluation•Benchmarking programs (sorting, factorial computing, string operations)

Page 23: Rapid and Expressive Prototyping on Cell Phones via Script

Some Sample Codes

function HelloWorld () io.write ("hello World") trace ("trace working now") end

HelloWorld()

function fat (n) if n == 0 then return 1 else return n*fat(n-1) endend

Function max(a, b) local m = a if b > a then m = b end return mend

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

Page 24: Rapid and Expressive Prototyping on Cell Phones via Script

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", 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++

Page 25: Rapid and Expressive Prototyping on Cell Phones via Script

Scaffolding Mobile Development via Script Embedding

Average users Use form-guided code generation templates to customize an

application Download and share new functions

Group development Only one member responsible for C/C++ programming,

expose additional native functions to script programmers via glue function

Other members fast prototyping in script

Runtime performance sensitive application Identify performance bottlenecks in the script implementation,

reemployment them in C/C++ and export them to the script

Page 26: Rapid and Expressive Prototyping on Cell Phones via Script

Summary

Building applications for cell phones is challenging due to highly diversified environment and toolkits

Trade-offs between low learning threshold and high ceiling need to be carefully considered

Script embedding is a solution to leverage nice features from both worlds

Page 27: Rapid and Expressive Prototyping on Cell Phones via Script

Thanks!

Any questions?