SlideShare une entreprise Scribd logo
1  sur  12

Cross-platform and performance?
Tech talk
Options for portable applications

  Java

  Mono

  HTML5 (Javascript)

  Python



  C++ ?
Capabilities of C++

Pros:
 Best performance (excepting assembly)

 Lower resource requirements

 Free from VM bugs

 Only constrained by platform (not VM)

 Your language!

Cons:
Applications for C++

Resource demanding applications

 Image and video editing

 Sound processing

 Document rendering

 Scripting engines

 Games
Code portability

What makes code less portable?

 Use of platform specific APIs

 Platform’s methodology

Code for portability

 Focus use of platform APIs into less places

 Split platform dependent and independent code
Layer Cake


Application Code ->

Common API ->

Platform implementation ->

Operating System
C++ Libraries

                   LoadImage(const
LoadImage(const      char* path)
  char* path)

                        libpng

    libpng

                    Custom fopen

   Platform
    fopen
                    Platform fopen
Substituting std lib functions

  LoadImage      fopen            _open         fopen
   App Code      newlib            glue           OS


                17 system calls to support
_exit             isatty               stat
close             kill                 times
environ           link                 unlink
execve            lseek                wait
fork              open                 write
fstat             read
getpid            sbrk
Prelinking Libraries

Relocatable link
 ld –r



Control symbol visibilty
 -B reduce



Second link against platform library
Separate Binary

 Application library entirely platform independent

Link to platform library at runtime?



Virtualized environment without the overhead
Dynamic Code Loading
Executable and Linkable Format (ELF) Binary
Embedded Execution Environment

    Marmalade SDK key feature

      Wide range of mobile platforms

    Access to platform features such as: SMS,
       Accelerometer & Gyro, Camera, Location services,
       threads, sound recording, etc.

Contenu connexe

Plus de Ciklum Ukraine

Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven DevelopmentCiklum Ukraine
 
Back to the future: ux trends 2015
Back to the future: ux trends 2015Back to the future: ux trends 2015
Back to the future: ux trends 2015Ciklum Ukraine
 
Developing high load systems using C++
Developing high load systems using C++Developing high load systems using C++
Developing high load systems using C++Ciklum Ukraine
 
Collection view layout
Collection view layoutCollection view layout
Collection view layoutCiklum Ukraine
 
Introduction to auto layout
Introduction to auto layoutIntroduction to auto layout
Introduction to auto layoutCiklum Ukraine
 
Unit Testing: Special Cases
Unit Testing: Special CasesUnit Testing: Special Cases
Unit Testing: Special CasesCiklum Ukraine
 
Model-View-Controller: Tips&Tricks
Model-View-Controller: Tips&TricksModel-View-Controller: Tips&Tricks
Model-View-Controller: Tips&TricksCiklum Ukraine
 
Future of Outsourcing report published in The Times featuring Ciklum's CEO To...
Future of Outsourcing report published in The Times featuring Ciklum's CEO To...Future of Outsourcing report published in The Times featuring Ciklum's CEO To...
Future of Outsourcing report published in The Times featuring Ciklum's CEO To...Ciklum Ukraine
 
Михаил Попчук "Cкрытые резервы команд или 1+1=3"
Михаил Попчук "Cкрытые резервы команд или 1+1=3"Михаил Попчук "Cкрытые резервы команд или 1+1=3"
Михаил Попчук "Cкрытые резервы команд или 1+1=3"Ciklum Ukraine
 
"To be, rather than to seem” interview with Ciklum VP of HR Marina Vyshegorod...
"To be, rather than to seem” interview with Ciklum VP of HR Marina Vyshegorod..."To be, rather than to seem” interview with Ciklum VP of HR Marina Vyshegorod...
"To be, rather than to seem” interview with Ciklum VP of HR Marina Vyshegorod...Ciklum Ukraine
 
"Marmalade" presentation at Ciklum event "Defining your Mobile Strategy"
"Marmalade" presentation at Ciklum event "Defining your Mobile Strategy""Marmalade" presentation at Ciklum event "Defining your Mobile Strategy"
"Marmalade" presentation at Ciklum event "Defining your Mobile Strategy"Ciklum Ukraine
 
Ciklum Mobile Development Capability: Project Clients' References
Ciklum Mobile Development Capability: Project Clients' ReferencesCiklum Mobile Development Capability: Project Clients' References
Ciklum Mobile Development Capability: Project Clients' ReferencesCiklum Ukraine
 
Mecom Group's Digital Innovation and IT Sourcing Strategy
Mecom Group's Digital Innovation and IT Sourcing StrategyMecom Group's Digital Innovation and IT Sourcing Strategy
Mecom Group's Digital Innovation and IT Sourcing StrategyCiklum Ukraine
 

Plus de Ciklum Ukraine (20)

Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Back to the future: ux trends 2015
Back to the future: ux trends 2015Back to the future: ux trends 2015
Back to the future: ux trends 2015
 
Developing high load systems using C++
Developing high load systems using C++Developing high load systems using C++
Developing high load systems using C++
 
Collection view layout
Collection view layoutCollection view layout
Collection view layout
 
Introduction to auto layout
Introduction to auto layoutIntroduction to auto layout
Introduction to auto layout
 
Groovy on Android
Groovy on AndroidGroovy on Android
Groovy on Android
 
Unit Testing: Special Cases
Unit Testing: Special CasesUnit Testing: Special Cases
Unit Testing: Special Cases
 
Material design
Material designMaterial design
Material design
 
Kanban development
Kanban developmentKanban development
Kanban development
 
Mobile sketching
Mobile sketching Mobile sketching
Mobile sketching
 
More UX in our life
More UX in our lifeMore UX in our life
More UX in our life
 
Model-View-Controller: Tips&Tricks
Model-View-Controller: Tips&TricksModel-View-Controller: Tips&Tricks
Model-View-Controller: Tips&Tricks
 
Unit Tesing in iOS
Unit Tesing in iOSUnit Tesing in iOS
Unit Tesing in iOS
 
Future of Outsourcing report published in The Times featuring Ciklum's CEO To...
Future of Outsourcing report published in The Times featuring Ciklum's CEO To...Future of Outsourcing report published in The Times featuring Ciklum's CEO To...
Future of Outsourcing report published in The Times featuring Ciklum's CEO To...
 
Михаил Попчук "Cкрытые резервы команд или 1+1=3"
Михаил Попчук "Cкрытые резервы команд или 1+1=3"Михаил Попчук "Cкрытые резервы команд или 1+1=3"
Михаил Попчук "Cкрытые резервы команд или 1+1=3"
 
"To be, rather than to seem” interview with Ciklum VP of HR Marina Vyshegorod...
"To be, rather than to seem” interview with Ciklum VP of HR Marina Vyshegorod..."To be, rather than to seem” interview with Ciklum VP of HR Marina Vyshegorod...
"To be, rather than to seem” interview with Ciklum VP of HR Marina Vyshegorod...
 
Why to join Ciklum?
Why to join Ciklum?Why to join Ciklum?
Why to join Ciklum?
 
"Marmalade" presentation at Ciklum event "Defining your Mobile Strategy"
"Marmalade" presentation at Ciklum event "Defining your Mobile Strategy""Marmalade" presentation at Ciklum event "Defining your Mobile Strategy"
"Marmalade" presentation at Ciklum event "Defining your Mobile Strategy"
 
Ciklum Mobile Development Capability: Project Clients' References
Ciklum Mobile Development Capability: Project Clients' ReferencesCiklum Mobile Development Capability: Project Clients' References
Ciklum Mobile Development Capability: Project Clients' References
 
Mecom Group's Digital Innovation and IT Sourcing Strategy
Mecom Group's Digital Innovation and IT Sourcing StrategyMecom Group's Digital Innovation and IT Sourcing Strategy
Mecom Group's Digital Innovation and IT Sourcing Strategy
 

Dernier

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Dernier (20)

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

CiklumCPPSat24032012IvanBelyy&StevenJeram-CrossPlatform&Performance

  • 2. Options for portable applications  Java  Mono  HTML5 (Javascript)  Python  C++ ?
  • 3. Capabilities of C++ Pros:  Best performance (excepting assembly)  Lower resource requirements  Free from VM bugs  Only constrained by platform (not VM)  Your language! Cons:
  • 4. Applications for C++ Resource demanding applications  Image and video editing  Sound processing  Document rendering  Scripting engines  Games
  • 5. Code portability What makes code less portable?  Use of platform specific APIs  Platform’s methodology Code for portability  Focus use of platform APIs into less places  Split platform dependent and independent code
  • 6. Layer Cake Application Code -> Common API -> Platform implementation -> Operating System
  • 7. C++ Libraries LoadImage(const LoadImage(const char* path) char* path) libpng libpng Custom fopen Platform fopen Platform fopen
  • 8. Substituting std lib functions LoadImage fopen _open fopen App Code newlib glue OS 17 system calls to support _exit isatty stat close kill times environ link unlink execve lseek wait fork open write fstat read getpid sbrk
  • 9. Prelinking Libraries Relocatable link  ld –r Control symbol visibilty  -B reduce Second link against platform library
  • 10. Separate Binary  Application library entirely platform independent Link to platform library at runtime? Virtualized environment without the overhead
  • 11. Dynamic Code Loading Executable and Linkable Format (ELF) Binary
  • 12. Embedded Execution Environment  Marmalade SDK key feature  Wide range of mobile platforms  Access to platform features such as: SMS, Accelerometer & Gyro, Camera, Location services, threads, sound recording, etc.

Notes de l'éditeur

  1. Hello and welcome
  2. Most options are interpretted or byte-code based and compiled just-in-time.Pros:Rapid developmentLarge range supported platformsGood tools (debuggers / profiling / code analysis)Garbage collectionRobust (stability / execeptions / error reporting)Cons:Not suitable for all applicationsLimited to functionality exposed in VM (no direct access to OS)Performance (such as graphics (OpenGL) & sound processing) – particularly on embedded platformsResource requirementsFavorite libraries like boost, libjpeg, lua, sqlite
  3. No overhead / indirection by VMVM bugs are generally hard to workaround – can’t recompile librariesLess layers – less potential for bugsMost direct access to OS – they’re usually written in C/C++C++ is language you want to write in!Cons – no room here
  4. Anything involving large amounts of data processingDJ app. Image effects – Instagram - morphing.Rendering of html / pdfs / flashImplementation of VMsGames – Physics / 3D scenes / ray tracing / Stereo pictures- C++ may be used for just part of an application
  5. Choosing to use NSString vs.std::string or char*FileOutputStream vs. fopenEvery time you call a platform api your code is tied to systemObjective-C – initWithData / User defaults / CoreFoundation / Serialization methodsAndroid – Manifests / widespread use XML / Object persistenceWe should separate platform dependent and independent partsGood encapsulation (such as model-view-controller) is good for portabilityMake wrapper classes to encapsulate platform code
  6. Each layer talks to next layer down. Layers below need no knowledge of layers aboveOnce these layers are separated, they can be compiled independently.VM based languages use platform independent Byte code. VM provides common API.
  7. For C++, traditionally, can be done with libraries which are linked together.Using a standard library like libpng.We want intercept fopen because otherwise would have to vary “path” by platform(Or add profiling. Or add custom memory allocation routine for malloc).Don’t want to have to replace fopen() with my_fopen()How do we use custom fopen() ?
  8. Replacing fopen means changing our C standard library used by our compilerWhen using gcc or llvm we can use newlib as our C standard library (libc.a & libm.a & …)http://wiki.osdev.org/Porting_NewlibNewlibcan be compiled „stand alone” –meaningwithoutany platform specificcde.Thisiscommonlydone for „bare-metal” / „bareboard” targetsAll you need to support a set of 17 system calls that act as ‘glue’ between newlib and the OS
  9. Problem is we now have two libraries containing fopen – newlib & platforms – how to get the right one?Prelink application to newlib. This technique is commonly used to remove dependencies on 3rd party libraries by combining these dependencies into a single conglomerate libraryIt pulls in as many symbol definitions as it can (but doesn’t complain about undefined symbols)In XCode this is known as “Single-Object Prelink of static libraries”. Prelink is very fucking intimate thing for every particular platformWant to hide most symbols (such as our custom fopen) within library.Some symbols need to remain visible – such as the entry point for the applicationWe run “ld” again passing prelinked application library and platform library (loader).Platforms used this for are Sony PSP, Nintendo DS, LG TV (Linux based), etc.
  10. Linking at runtime we can reuse a single application binary. No need to rebuild for new platform.Bugs in application library are platform independent (can be debugged on any system).Moving to new platform, new bugs can only be in platform layer.We’re effectively creating a virtual environment for our application.We can take complete control of memory heaps, file system & add profiling metrics.
  11. Unlike many proprietary executable file formats, ELF is flexible and extensible, and it is not bound to any particular processor or architecture. This has allowed it to be adopted by many different operating systems on many different platforms. The ELF file format is also used as a generic object and executable format for binary images used with embedded processors like AVR.The Windows analogue is PE – Portable Executable....On Darwin it's Mach-Ohttp://www.symantec.com/connect/articles/dynamic-linking-linux-and-windows-part-onePosition Independent CodePosition independent code can be copied to any memory location without modification and then executed, unlike relocatable code which requires special processing by a runtime linker to make it suitable for execution at a given location.Global offset TableELF linkers support PIC Code through the GOT in each shared library. The GOT contains absolute addresses to all of the static data referenced in the program. The address of the GOT is normally stored in a register (EBX) which is a relative address from the code that references it.Procedure Linkage Table (PLT)Similar to how the GOT redirects any position-independent address calculations to absolute locations, the PLT redirects position-independent function calls to absolute locations.Apart from these two tables, the linker also refers to .dynsym, which contains all of the file's imported and exported symbols, .dynstr, which contains name strings for the symbols.
  12. This is one of the key features of Marmalade SDK, which we work on creating.It has a slightly modified ELF format called S3E for the ARM architecture. It is compressed and includes meta-data for configuration.Loaders are provided for a wide range of mobile platforms (such as iOS, Android, Bada, Symbian). Applications are compiled once and then can be deployed to all these platforms.Access is provided to platform features: SMS, Camera, Location Services, Accelerometer, Sound recording, threads, etc. Applications query available features at runtime rather than #ifdef conditional programming.