Upload
egor-pushkin
View
96
Download
3
Tags:
Embed Size (px)
Citation preview
Cross CompilingTechnology Behind
Client API 2.0
Copyright (c) 2015 Glympse, Inc.Creative Commons Attribution 4.0 International License
Egor [email protected]
Platform ArchitectGlympse, Inc.
Introduction "Language shapes the way we think, and determines what we can think about."
Benjamin Lee Whorf
Copyright (c) 2015 Glympse, Inc.
Platformmobile OS
Languageparadigm
Possibilitiesflexibility
Defines
Defines
Define
1 Based on market state in Q2 20152 Only mobile platforms are considered3 With focus on native application development
Topical mobile operating systems- Android- iOS- BlackBerry- Windows Phone- Tizen
1Predominant programming languages- Java- ObjectiveC- Swift- C++- C#
2, 3Cross-platform development techniques- Browser-based frameworks- Scripting / VM approach- Portable code (mostly C++)
3
Goals● Minimize the efforts towards the development of
cross-platform SDK (for mobile and desktop platforms)
● Provide consistent public API across all platforms Common documentation
● Maintain portable, stable and performant code baseNative, line to line identical code across all platforms (languages)Efficient debugging / troubleshootingLow cost adoption of new platforms
● Shared infrastructure toolsUnit testsSimulators
Copyright (c) 2015 Glympse, Inc.
Requirements● Support of the following programming languages
C++ / Java / C#● No sacrifices in performance!● Code must be readable/debuggable across all platforms● Native code should be executed on each platform
This includes public interface, which is of prime importance from the standpoint of integration into 3rd party applications
● The following components must be sharedBusiness logicObject modelBackend interaction (protocol, flow)Persistence (local databases, configuration)Resource handling (images)
Copyright (c) 2015 Glympse, Inc.
Fundamentals● Code translation is used as a part of porting process
Shared code is written in C++ and is translated to Java and C#
● Lowest common denominator approachWith regards to language features
● Platform-specific features are hidden behindOS Abstraction LayerBe smart on where to draw the line (shared code vs platform-specific)Library should remain functional, if some features are not supported by the OS
● Component-oriented architecture● Focus on OOP and design patterns
With elements of generic programming
Copyright (c) 2015 Glympse, Inc.
Library Structure
Object Model Foundation
CoreMemory
ManagementCommon Interfaces
Strings / Containers
APIDomain-specific public interfaces
Business Logic
Lib
Object Model
Backend Interaction
External Services
Persistence
Image Cache
JSON / WebSocket
Battery Manager
Job Queue Engine
Network Manager
OSAL PublicPublic interfaces of OS-dependent module
Concurrency
OSAL
Core GPS
Contacts / Calendar
Storage
Debug PUSHBattery
Networking
Images
Copyright (c) 2015 Glympse, Inc.
Translation Process
Core
API
Lib
OSAL Public
OSAL
Portable Code
Platform Specific
LIbrary(C++ code)
Translator
Javacode
jar archive
C#code dll library
.a library
Android AL
WinPhone AL
iOS AL BB AL
.a library
WinAPI AL
.lib library
The majority of code belongs to this layer
Tizen
.a library
Copyright (c) 2015 Glympse, Inc.
Code Analysis#ifdef ...#define
namespace ...{class Class : public IInterface{ private: Member _member;
public: virtual void method() { methodCall(); for ( ... ; ... ; ... ) { } }};}
#endif ...
package ...;
import ...;import ...;
class Class implements IInterface{ private Member _member;
public void method() { methodCall(); for ( ... ; ... ; ... ) { } }}
header
footer
class statement
class member
class method
for statement
JavaC++
Copyright (c) 2015 Glympse, Inc.
● JSON ParserPowers JSON serialization
● Job QueueProvides background execution support
● Resource ManagerAbstracts content extraction and caching
● WebSocket ImplementationRFC 6455 compliant
● Unit Testing EnginePortable tests
Examples of reusable components implemented in common code
Portable Components
Copyright (c) 2015 Glympse, Inc.
JSON Parser
● SAX supportNested handlersPartial DOM extraction
● DOM supportImplemented on top of SAXPartial DOM extraction
● Flexible cancellation support● Advanced performance optimization techniques
Intermediate strings are not created Values are only parsed on demand
● Error handling (with recovery)
1JSON Parser
IJSONParser
IJSONHandler
Handler X
JSON Tokener
JSON Token
IJSONHandlerStack
JSONSerializer
DOM
SAX* 1 *
IPrimitive
Primitive
Copyright (c) 2015 Glympse, Inc.
● Configurable pool of worker threads● Flexible completion notifications● Cancellation support● Retry mechanism with configurable backoff policy● HTTP(s) support
Job
Job Queue1 *
Worker Thread
IJob
Http JobIHttpConnectionHttp Connection
IRunnable
IThreadThread
11
1*
IHandlerHandler
1
1
1
1
Job Queue
Copyright (c) 2015 Glympse, Inc.
Drawable
Job Queue
Job
Image
0,11
1
*
Image Cache
Memory Cache
Disk Cache
Load Image Job
Content Resolver
Content Provider
1
Web Image Provider
Person Avatar Provider Contacts Provider
11
1
1
1
*
*
*
1
OS Bitmap
0,11
Content Resolver
Contacts Manager
● Customizable content extraction Based on URIs and external providers
● Advanced image handling and caching
Resource Manager
Copyright (c) 2015 Glympse, Inc.
Libraries and tools built with the use of cross compiling technology
● Glympse Client SDKGlympse flagship platform shares 80k lines of common code across 5 topical mobile operating systems (iOS, Android, Windows Phone, BlackBerry and Tizen).
● RPC componentTransport layer built on top of Glympse Client SDK enabling interprocess communication capabilities heavily utilized in wearables and automotive applications.
● Glympse Map controlLibrary powering Glympse viewing experience in native applications. Map control supports variety of rendering backends (including Apple MapKit, Google Map SDK, HERE Map SDK, WinPhone Map SDK, Mapquest SDK) and shares business logic across all platforms.
● Dispatch libraryComponent is designed to power B2C applications (aka Glympse EnRoute) built on top of Glympse Core.
● Remote Debugger componentDebugging tool enabling remote monitoring of application object model.
Glympse Products
Copyright (c) 2015 Glympse, Inc.
Codebase Stats
Copyright (c) 2015 Glympse, Inc.
● 87% of codebase for specific OS is shared with other OSes● Multiple levels of code validation, verification
The code can be analyzed using variety of compilers and utilities● Code coverage grows exponentially
Porting the same code to OSes causes different patterns of adoption● Free of charge automation
.Net platforms natively supports scripting● Beyond the library itself
Cross-platform tools (bots / simulators / explorers)Cross-platform unit testing
● Beyond the mobileAbility to share library code with desktop applicationsAbility to share business logic and specific components with server side applications (JSON parser)
Conclusion
Copyright (c) 2015 Glympse, Inc.
● Multi directional translationInvolves fully-functional lexical analysis Dramatically extends flexibility and minimizes limitations
● Support language-specific featuresModern C++ features, anonymous classes, etc.
● Support scripting languages (JavaScript, Python)Allows code sharing between native and Web (HTML5) platforms
Technology Evolution (Next Steps)
Copyright (c) 2015 Glympse, Inc.
● Translator source codehttps://github.com/Glympse/CrossCompiling
● Translator online demohttps://github.com/Glympse/CrossCompilingConsole
References
Copyright (c) 2015 Glympse, Inc.